![]() Server : LiteSpeed System : Linux premium84.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64 User : claqxcrl ( 523) PHP Version : 8.1.32 Disable Function : NONE Directory : /home/claqxcrl/confenda.com/wp-content/plugins/poll-maker/poll/ |
<?php /** * Enqueue front end and editor JavaScript */ function ays_poll_gutenberg_scripts() { global $current_screen; if( ! $current_screen ){ return null; } if( ! $current_screen->is_block_editor ){ return null; } $blockPath = 'poll-maker-block.js'; wp_enqueue_script("jquery-effects-core"); wp_enqueue_script('ays_block_select2js', POLL_MAKER_AYS_ADMIN_URL . '/js/select2.min.js', array('jquery'), '4.0.6', true); // Enqueue the bundled block JS file wp_enqueue_script( 'poll-maker-block-js', POLL_MAKER_AYS_BASE_URL . "poll/" . $blockPath, array('jquery', 'wp-blocks', 'wp-i18n', 'wp-element', 'wp-components', 'wp-editor'), POLL_MAKER_AYS_VERSION, true ); wp_localize_script('ays-poll-gutenberg-block-js', 'ays_poll_block_ajax', array('aysDoShortCode' => admin_url('admin-ajax.php'))); wp_enqueue_style( POLL_MAKER_AYS_NAME . '-font-awesome', POLL_MAKER_AYS_ADMIN_URL . '/css/poll-maker-font-awesome-all.css', array(), POLL_MAKER_AYS_VERSION, 'all'); wp_enqueue_style('ays-block-animate', POLL_MAKER_AYS_ADMIN_URL . '/css/animate.min.css', array(), '2.0.6', 'all'); wp_enqueue_style('ays-block-select2', POLL_MAKER_AYS_ADMIN_URL . '/css/select2.min.css', array(), '4.0.6', 'all'); wp_enqueue_style(POLL_MAKER_AYS_NAME, POLL_MAKER_AYS_PUBLIC_URL . '/css/poll-maker-ays-public.css', array(), POLL_MAKER_AYS_VERSION, 'all'); // Enqueue the bundled block CSS file wp_enqueue_style( 'poll-maker-block-css', POLL_MAKER_AYS_BASE_URL . "poll/poll-maker-block.css", array(), POLL_MAKER_AYS_VERSION, 'all' ); } function ays_poll_gutenberg_block_register() { global $wpdb; $block_name = 'poll'; $block_namespace = 'poll-maker/' . $block_name; $sql = "SELECT * FROM {$wpdb->prefix}ayspoll_polls"; $results = $wpdb->get_results($sql, "ARRAY_A"); register_block_type( $block_namespace, array( 'render_callback' => 'pollmaker_render_callback', 'editor_script' => 'poll-maker-block-js', // The block script slug 'style' => 'poll-maker-block-css', 'attributes' => array( 'idner' => $results, 'metaFieldValue' => array( 'type' => 'integer', ), 'shortcode' => array( 'type' => 'string', ), 'className' => array( 'type' => 'string', ), 'openPopupId' => array( 'type' => 'string', ), ), ) ); } function pollmaker_render_callback($attributes) { $ays_html = "<p style='text-align:center;'>" . __('Please select poll') . "</p>"; if (isset($attributes["shortcode"]) && $attributes["shortcode"] != '') { $ays_html = do_shortcode($attributes["shortcode"]); } return $ays_html; } function ays_poll_versionCompare($version1, $operator, $version2) { $_fv = intval ( trim ( str_replace ( '.', '', $version1 ) ) ); $_sv = intval ( trim ( str_replace ( '.', '', $version2 ) ) ); if (strlen ( $_fv ) > strlen ( $_sv )) { $_sv = str_pad ( $_sv, strlen ( $_fv ), 0 ); } if (strlen ( $_fv ) < strlen ( $_sv )) { $_fv = str_pad ( $_fv, strlen ( $_sv ), 0 ); } return version_compare ( ( string ) $_fv, ( string ) $_sv, $operator ); } if (function_exists("register_block_type")) { global $wp_version; $version1 = $wp_version; $operator = '>='; $version2 = '5.2'; $versionCompare = ays_poll_versionCompare($version1, $operator, $version2); if ( $versionCompare ) { // Hook scripts function into block editor hook add_action('enqueue_block_assets', 'ays_poll_gutenberg_scripts'); add_action('init', 'ays_poll_gutenberg_block_register'); } }