function handle_load_exceptions($errno, $errstr, $errfile, $errline) { global $foogallery_currently_loading; $api = new FooGallery_Extensions_API(); $api->deactivate($foogallery_currently_loading, false, true); //don't execute PHP internal error handler return true; }
function create_menus() { add_media_page(__('Galleries', 'foogallery'), __('Galleries', 'foogallery'), 'upload_files', 'edit.php?post_type=' . FOOGALLERY_CPT_GALLERY); add_media_page(__('Add Gallery', 'foogallery'), __('Add Gallery', 'foogallery'), 'upload_files', 'post-new.php?post_type=' . FOOGALLERY_CPT_GALLERY); $api = new FooGallery_Extensions_API(); if ($api->is_active('albums')) { add_media_page(__('Albums', 'foogallery'), __('Albums', 'foogallery'), 'upload_files', 'edit.php?post_type=' . FOOGALLERY_CPT_ALBUM); add_media_page(__('Add Album', 'foogallery'), __('Add Album', 'foogallery'), 'upload_files', 'post-new.php?post_type=' . FOOGALLERY_CPT_ALBUM); } }
/** * Runs after FooGallery has been updated via the backend */ function perform_housekeeping() { //allow extensions or other plugins to do stuff when foogallery is updated // this will catch both manual and auto updates! do_action('foogallery_admin_new_version_detected'); //clear the cached extensions if foogallery was updated $api = new FooGallery_Extensions_API(); $api->clear_cached_extensions(); //we need to clear the foogallery css load optimizations when we update the plugin, to ensure the latest CSS files are loaded foogallery_clear_all_css_load_optimizations(); }
/** * Fired for each blog when the plugin is activated. * * @since 1.0.0 */ private static function single_activate($multisite = true) { if (false === get_option(FOOGALLERY_EXTENSIONS_AUTO_ACTIVATED_OPTIONS_KEY, false)) { $api = new FooGallery_Extensions_API(); $api->auto_activate_extensions(); update_option(FOOGALLERY_EXTENSIONS_AUTO_ACTIVATED_OPTIONS_KEY, true); } if (false === $multisite) { //Make sure we redirect to the welcome page set_transient(FOOGALLERY_ACTIVATION_REDIRECT_TRANSIENT_KEY, true, 30); } //force a version check on activation to make sure housekeeping is performed foogallery_perform_version_check(); }
/** * Fired for each blog when the plugin is activated. * * @since 1.0.0 */ private static function single_activate($multisite = true) { if (false === get_option(FOOGALLERY_EXTENSIONS_AUTO_ACTIVATED_OPTIONS_KEY, false)) { $api = new FooGallery_Extensions_API(); $api->auto_activate_extensions(); update_option(FOOGALLERY_EXTENSIONS_AUTO_ACTIVATED_OPTIONS_KEY, true); } if (false === $multisite) { //Make sure we redirect to the welcome page set_transient(FOOGALLERY_ACTIVATION_REDIRECT_TRANSIENT_KEY, true, 30); } }
<?php $instance = FooGallery_Plugin::get_instance(); $api = new FooGallery_Extensions_API(); $extensions = $api->get_all(); $has_errors = $api->has_extension_loading_errors(); $categories = $api->get_all_categories(); $show_message = safe_get_from_request('show_message'); if ('yes' === $show_message) { $result = get_transient(FOOGALLERY_EXTENSIONS_MESSAGE_TRANSIENT_KEY); } $tagline = apply_filters('foogallery_admin_extensions_tagline', sprintf(__('Extensions make %s even more awesome, without bloating the core plugin.', 'foogallery'), foogallery_plugin_name())); $show_foobot = apply_filters('foogallery_admin_show_foobot', true); ?> <style> .foogallery-badge-foobot { position: absolute; top: 5px; right: 0; background: url(<?php echo FOOGALLERY_URL; ?> assets/foobot_small.png) no-repeat; width: 82px; height: 150px; z-index: 100; } .foogallery-text { font-size: 18px; margin: 10px 0; }
/** * Runs after FooGallery has been updated via the backend * * @param $upgrader_object * @param $options */ function plugin_updated($upgrader_object, $options) { //only clear the extensions if foogallery was updated if (array_key_exists('plugin', $options) && 'foogallery/foogallery.php' === $options['plugin']) { $api = new FooGallery_Extensions_API(); $api->clear_cached_extensions(); } }
function alter_gallery_template_field($field, $gallery) { if ($field) { switch ($field['type']) { case 'thumb_link': $field['type'] = 'radio'; $field['choices'] = $this->get_thumb_link_field_choices(); break; case 'lightbox': $field['lightbox'] = true; $lightboxes = $this->get_lightbox_field_choices(); if (1 === count($lightboxes) && array_key_exists('none', $lightboxes)) { $field['type'] = 'html'; $field['desc'] = '<strong>' . __('You have no lightbox extensions activated!', 'foogallery') . '</strong><br />'; $api = new FooGallery_Extensions_API(); if ($api->is_downloaded(false, FOOGALLERY_FOOBOX_FREE_EXTENSION_SLUG)) { //just need to activate it $foobox_install_link = foogallery_build_admin_menu_url(array('page' => 'foogallery-extensions', 'extension' => FOOGALLERY_FOOBOX_FREE_EXTENSION_SLUG, 'action' => 'activate')); $field['desc'] .= '<a target="_blank" href="' . esc_url($foobox_install_link) . '">' . __('Activate FooBox FREE right now!', 'foogallery') . '</a>'; } else { //we need to download it $foobox_install_link = foogallery_build_admin_menu_url(array('page' => 'foogallery-extensions', 'extension' => FOOGALLERY_FOOBOX_FREE_EXTENSION_SLUG, 'action' => 'download')); $foobox_install_html = '<a target="_blank" href="' . esc_url($foobox_install_link) . '">' . __('Download and activate FooBox FREE', 'foogallery') . '</a>'; $field['desc'] .= sprintf(__('%s which works flawlessly with %s.', 'foogallery'), $foobox_install_html, foogallery_plugin_name()); } } else { $field['type'] = 'select'; $field['choices'] = $lightboxes; } break; } if (isset($field['help']) && $field['help']) { $field['type'] = 'help'; } } return $field; }
} // ...otherwise use phpinfo(). ob_start(); phpinfo(8); $info = ob_get_contents(); ob_end_clean(); $info = stristr($info, 'gd version'); preg_match('/\\d/', $info, $match); return $match[0]; } if (current_user_can('activate_plugins')) { $instance = FooGallery_Plugin::get_instance(); $info = $instance->get_plugin_info(); $title = apply_filters('foogallery_admin_systeminfo_title', sprintf(__('%s System Information', 'foogallery'), foogallery_plugin_name())); $support_text = apply_filters('foogallery_admin_systeminfo_supporttext', sprintf(__('Below is some information about your server configuration. You can use this info to help debug issues you may have with %s.'), foogallery_plugin_name())); $api = new FooGallery_Extensions_API(); //clear any extenasion cache $api->clear_cached_extensions(); $extension_slugs = $api->get_all_slugs(); //get all gallery templates $template_slugs = array(); foreach (foogallery_gallery_templates() as $template) { $template_slugs[] = $template['slug']; } //get all activated plugins $plugins = array(); foreach (get_option('active_plugins') as $plugin_slug => $plugin) { $plugins[] = $plugin; } $current_theme = wp_get_theme(); $debug_info = array(__('FooGallery version', 'foogallery') => $info['version'], __('WordPress version', 'foogallery') => $wp_version, __('Activated Theme', 'foogallery') => $current_theme['Name'], __('WordPress URL', 'foogallery') => get_site_url(), __('PHP version', 'foogallery') => phpversion(), __('PHP GD Loaded', 'foogallery') => extension_loaded('gd') && function_exists('gd_info') ? foogallery_gdversion() : __('Not found!', 'foogallery'), __('Extensions Endpoint', 'foogallery') => $api->get_extensions_endpoint(), __('Extensions Errors', 'foogallery') => $api->has_extension_loading_errors() == true ? $api->get_extension_loading_errors_response() : __('Nope, all good', 'foogallery'), __('Extensions', 'foogallery') => $extension_slugs, __('Extensions Active', 'foogallery') => array_keys($api->get_active_extensions()), __('Gallery Templates', 'foogallery') => $template_slugs, __('Lightboxes', 'foogallery') => apply_filters('foogallery_gallery_template_field_lightboxes', array()), __('Active Plugins', 'foogallery') => $plugins);
function handle_extension_action() { $action = safe_get_from_request('action'); $extension_slug = safe_get_from_request('extension'); $has_error = safe_get_from_request('has_error'); if ($action && $extension_slug) { $api = new FooGallery_Extensions_API(); $fatal_error_redirect = remove_query_arg('action'); wp_redirect(add_query_arg('has_error', 'yes', $fatal_error_redirect)); // we'll override this later if the plugin can be included without fatal error ob_start(); switch ($action) { case 'download': $result = $api->download($extension_slug); break; case 'activate': $result = $api->activate($extension_slug); break; case 'deactivate': $result = $api->deactivate($extension_slug); break; } //if we get here then no fatal error - cool! ob_end_clean(); //store the result in a short-lived transient if (isset($result)) { set_transient(FOOGALLERY_EXTENSIONS_MESSAGE_TRANSIENT_KEY, $result, 30); } //first, remove unwanted query args $redirect_url = remove_query_arg(array('extension', 'action')); //then add a query arg for our message $redirect_url = add_query_arg('show_message', 'yes', $redirect_url); //finally, allow extensions to override their own redirect $redirect_url = apply_filters('foogallery_extensions_redirect_url-' . $extension_slug, $redirect_url, $action); //redirect to this page, so the plugin can be properly activated/deactivated etc if ($redirect_url) { wp_redirect($redirect_url); die; } } else { if ('reload' === $action) { $api = new FooGallery_Extensions_API(); $api->reload(); //first, remove unwanted query args $redirect_url = remove_query_arg(array('extension', 'action')); if (!$api->has_extension_loading_errors()) { $result = array('message' => __('The extensions have been reloaded', 'foogallery'), 'type' => 'success'); set_transient(FOOGALLERY_EXTENSIONS_MESSAGE_TRANSIENT_KEY, $result, 30); //then add a query arg for our message $redirect_url = add_query_arg('show_message', 'yes', $redirect_url); } wp_redirect($redirect_url); die; } else { if ($has_error) { $api = new FooGallery_Extensions_API(); $api->deactivate($extension_slug, true, false); $result = array('message' => __('The extension could not be activated due to an error!', 'foogallery'), 'type' => 'error'); set_transient(FOOGALLERY_EXTENSIONS_MESSAGE_TRANSIENT_KEY, $result, 30); $api->add_to_error_extensions($extension_slug, __('Activation Error!', 'foogallery')); //first, remove unwanted query args $redirect_url = remove_query_arg(array('extension', 'action', 'has_error')); //then add a query arg for our message $redirect_url = add_query_arg('show_message', 'yes', $redirect_url); wp_redirect($redirect_url); } } } }