/** * Adds a gallery insert button into the editor * * @param string $buttons the existing media buttons * * @return string $buttons the amended media buttons */ public function add_media_button($buttons) { //render the gallery modal add_action('admin_footer', array($this, 'render_gallery_modal')); $foogallery = FooGallery_Plugin::get_instance(); $foogallery->register_and_enqueue_js('admin-foogallery-editor.js'); $buttons .= '<a href="#" class="button foogallery-modal-trigger" title="' . esc_attr(sprintf(__('Add Gallery From %s', 'foogallery'), foogallery_plugin_name())) . '" style="padding-left: .4em;">'; $buttons .= '<span class="wp-media-buttons-icon dashicons dashicons-format-gallery"></span> ' . sprintf(__('Add %s', 'foogallery'), foogallery_plugin_name()) . '</a>'; return $buttons; }
function foogallery_settings() { if (isset($_GET['settings-updated'])) { ?> <div id="message" class="updated"> <p><strong><?php printf(__('%s settings updated.', 'foogallery'), foogallery_plugin_name()); ?> </strong></p> </div> <?php } $instance = FooGallery_Plugin::get_instance(); $instance->admin_settings_render_page(); }
function admin_print_scripts() { $page = safe_get_from_request('page'); $foogallery = FooGallery_Plugin::get_instance(); $foogallery->register_and_enqueue_js('admin-page-' . $page . '.js'); }
/** * Get all blog ids of blogs in the current network that are: * - not archived * - not spam * - not deleted * * @since 1.0.0 * * @return array|false The blog ids, false if no matches. */ private static function get_blog_ids() { if (function_exists('wp_get_sites')) { $sites = wp_get_sites(); $blog_ids = array(); foreach ($sites as $site) { $blog_ids[] = $site['blog_id']; } return $blog_ids; } else { //pre WP 3.7 - do this the old way! global $wpdb; // get an array of blog ids $sql = "SELECT blog_id FROM {$wpdb->blogs} WHERE archived = '0' AND spam = '0' AND deleted = '0'"; return $wpdb->get_col($sql); } } } } FooGallery_Plugin::get_instance();
/** * Return the FooGallery saved setting, or a default value * * @param string $key The key for the setting * * @param bool $default The default if no value is saved or found * * @return mixed */ function foogallery_get_setting($key, $default = false) { $foogallery = FooGallery_Plugin::get_instance(); return $foogallery->options()->get($key, foogallery_get_default($key, $default)); }