/** * Enqueue scripts. */ public function admin_scripts() { $screen = get_current_screen(); $screen_id = $screen ? $screen->id : ''; $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; // Register Scripts. wp_register_script('social-icons-admin', SI()->plugin_url() . '/assets/js/admin/admin' . $suffix . '.js', array('jquery', 'jquery-ui-sortable', 'jquery-ui-widget', 'jquery-ui-core', 'jquery-tiptip'), SI_VERSION); wp_register_script('si-admin-meta-boxes', SI()->plugin_url() . '/assets/js/admin/meta-boxes' . $suffix . '.js', array('jquery', 'jquery-ui-datepicker', 'jquery-ui-sortable', 'jquery-tiptip'), SI_VERSION); wp_register_script('jquery-tiptip', SI()->plugin_url() . '/assets/js/jquery-tiptip/jquery.tipTip' . $suffix . '.js', array('jquery'), SI_VERSION, true); // Localize socicons. $socicons_params = array('allowed_socicons' => si_get_allowed_socicons(), 'supported_url_icon' => si_get_supported_url_icon()); // Social Icons admin pages. if (in_array($screen_id, si_get_screen_ids())) { wp_enqueue_script('social-icons-admin'); wp_enqueue_script('jquery-ui-sortable'); wp_enqueue_script('jquery-ui-autocomplete'); $params = array('ajax_url' => admin_url('admin-ajax.php')); wp_localize_script('social-icons-admin', 'social_icons_admin', $params); } // Meta boxes. if (in_array($screen_id, array('social_icon', 'edit-social_icon'))) { wp_register_script('si-admin-group-meta-boxes', SI()->plugin_url() . '/assets/js/admin/meta-boxes-group' . $suffix . '.js', array('si-admin-meta-boxes'), SI_VERSION); wp_localize_script('si-admin-group-meta-boxes', 'social_icons_admin_meta_boxes_group', $socicons_params); wp_enqueue_script('si-admin-group-meta-boxes'); } // Widgets Specific. if (in_array($screen_id, array('widgets', 'customize'))) { wp_register_script('si-admin-widgets', SI()->plugin_url() . '/assets/js/admin/widgets' . $suffix . '.js', array('jquery'), SI_VERSION); wp_localize_script('si-admin-widgets', 'social_icons_admin_widgets', $socicons_params); wp_enqueue_script('si-admin-widgets'); } }
/** * Register/enqueue frontend scripts. */ public static function load_scripts() { $assets_path = str_replace(array('http:', 'https:'), '', SI()->plugin_url()) . '/assets/'; // Register any scripts for later use, or used as dependencies self::register_style('social-icons-general', $assets_path . 'css/social-icons.css', array()); if (si_post_content_has_shortcode('social_icons_group') || apply_filters('social_icons_enable_stylesheets', true)) { // CSS Styles if ($enqueue_styles = self::get_styles()) { foreach ($enqueue_styles as $handle => $args) { self::enqueue_style($handle, $args['src'], $args['deps'], $args['version'], $args['media']); } } } }
/** * Change the admin footer text on Social Icons admin pages. * @param string $footer_text * @return string */ public function admin_footer_text($footer_text) { if (!current_user_can('manage_options')) { return; } $current_screen = get_current_screen(); $si_pages = si_get_screen_ids(); // Check to make sure we're on a Social Icons admin page if (isset($current_screen->id) && apply_filters('social_icons_display_admin_footer_text', in_array($current_screen->id, $si_pages))) { // Change the footer text if (!get_option('social_icons_admin_footer_text_rated')) { $footer_text = sprintf(__('If you like <strong>Social Icons</strong> please leave us a %s★★★★★%s rating. A huge thanks in advance!', 'social-icons'), '<a href="https://wordpress.org/support/view/plugin-reviews/social-icons?filter=5#postform" target="_blank" class="si-rating-link" data-rated="' . esc_attr__('Thanks :)', 'social-icons') . '">', '</a>'); si_enqueue_js("\n\t\t\t\t\tjQuery( 'a.si-rating-link' ).click( function() {\n\t\t\t\t\t\tjQuery.post( '" . SI()->ajax_url() . "', { action: 'social_icons_rated' } );\n\t\t\t\t\t\tjQuery( this ).parent().text( jQuery( this ).data( 'rated' ) );\n\t\t\t\t\t});\n\t\t\t\t"); } else { $footer_text = __('Thank you for creating with Social Icons.', 'social-icons'); } } return $footer_text; }
* @return string */ public function plugin_path() { return untrailingslashit(plugin_dir_path(__FILE__)); } /** * Get Ajax URL. * @return string */ public function ajax_url() { return admin_url('admin-ajax.php', 'relative'); } } } /** * Main instance of Social Icons. * * Returns the main instance of SI to prevent the need to use globals. * * @since 1.4.0 * @return Social_Icons */ function SI() { return Social_Icons::get_instance(); } // Global for backwards compatibility. $GLOBALS['social_icons'] = SI();