summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'themes/mantra/includes')
-rw-r--r--themes/mantra/includes/tgm.php7342
-rw-r--r--themes/mantra/includes/theme-comments.php284
-rw-r--r--themes/mantra/includes/theme-frontpage.php474
-rw-r--r--themes/mantra/includes/theme-functions.php960
-rw-r--r--themes/mantra/includes/theme-hooks.php318
-rw-r--r--themes/mantra/includes/theme-loop.php608
-rw-r--r--themes/mantra/includes/theme-setup.php862
-rw-r--r--themes/mantra/includes/theme-styles.php264
8 files changed, 5559 insertions, 5553 deletions
diff --git a/themes/mantra/includes/tgm.php b/themes/mantra/includes/tgm.php
index cf9d89b8..9e7f8e78 100644
--- a/themes/mantra/includes/tgm.php
+++ b/themes/mantra/includes/tgm.php
@@ -1,3671 +1,3671 @@
-<?php
-
-add_action( 'tgmpa_register', 'cryout_settings_plugin' );
-
-function cryout_settings_plugin() {
-
- $plugins = array(
-
- array(
- 'name' => 'Cryout Serious Theme Settings',
- 'slug' => 'cryout-theme-settings',
- 'required' => false,
- 'version' => '0.5.6',
- //'force_activation' => true,
- //'force_deactivation' => true,
- ),
-
- );
-
- $config = array(
- 'default_path' => '', // Default absolute path to pre-packaged plugins.
- 'menu' => 'mantra-extra-plugins', // Menu slug.
- 'has_notices' => true, // Show admin notices or not.
- 'dismissable' => true, // If false, a user cannot dismiss the nag message.
- 'dismiss_msg' => '', // If 'dismissable' is false, this message will be output at top of nag.
- 'is_automatic' => true, // Automatically activate plugins after installation or not.
- 'message' => '', // Message to output right before the plugins table.
- 'strings' => array(
- 'page_title' => __( 'Recommended Plugins', 'cryout' ),
- 'menu_title' => ucwords(_CRYOUT_THEME_NAME) . __( ' Plugins', 'cryout' ),
- 'installing' => __( 'Installing Plugin: %s', 'cryout' ), // %s = plugin name.
- 'oops' => __( 'Something went wrong with the plugin API.', 'cryout' ),
- 'notice_can_install_required' => _n_noop( ucwords(_CRYOUT_THEME_NAME) . ' requires the following plugin: %1$s.', ucwords(_CRYOUT_THEME_NAME) . ' requires the following plugins: %1$s.', 'cryout' ), // %1$s = plugin name(s).
- 'notice_can_install_recommended' => _n_noop( ucwords(_CRYOUT_THEME_NAME) . ' recommends the following plugin: %1$s.', ucwords(_CRYOUT_THEME_NAME) . ' recommends the following plugins: %1$s.', 'cryout' ), // %1$s = plugin name(s).
- 'notice_cannot_install' => _n_noop( 'Sorry, but you do not have the correct permissions to install the %s plugin. Contact the administrator of this site for help on getting the plugin installed.', 'Sorry, but you do not have the correct permissions to install the %s plugins. Contact the administrator of this site for help on getting the plugins installed.', 'cryout' ), // %1$s = plugin name(s).
- 'notice_can_activate_required' => _n_noop( 'The following required plugin is currently inactive: %1$s.', 'The following required plugins are currently inactive: %1$s.', 'cryout' ), // %1$s = plugin name(s).
- 'notice_can_activate_recommended' => _n_noop( 'The following recommended plugin is currently inactive: %1$s.', 'The following recommended plugins are currently inactive: %1$s.', 'cryout' ), // %1$s = plugin name(s).
- 'notice_cannot_activate' => _n_noop( 'Sorry, but you do not have the correct permissions to activate the %s plugin. Contact the administrator of this site for help on getting the plugin activated.', 'Sorry, but you do not have the correct permissions to activate the %s plugins. Contact the administrator of this site for help on getting the plugins activated.', 'cryout' ), // %1$s = plugin name(s).
- 'notice_ask_to_update' => _n_noop( 'The following plugin needs to be updated to its latest version to ensure maximum compatibility with this theme: %1$s.', 'The following plugins need to be updated to their latest version to ensure maximum compatibility with this theme: %1$s.', 'cryout' ), // %1$s = plugin name(s).
- 'notice_cannot_update' => _n_noop( 'Sorry, but you do not have the correct permissions to update the %s plugin. Contact the administrator of this site for help on getting the plugin updated.', 'Sorry, but you do not have the correct permissions to update the %s plugins. Contact the administrator of this site for help on getting the plugins updated.', 'cryout' ), // %1$s = plugin name(s).
- 'install_link' => _n_noop( 'Begin installing plugin', 'Begin installing plugins', 'cryout' ),
- 'activate_link' => _n_noop( 'Begin activating plugin', 'Begin activating plugins', 'cryout' ),
- 'return' => __( 'Return to Required Plugins Installer', 'cryout' ),
- 'plugin_activated' => __( 'Plugin activated successfully.', 'cryout' ),
- 'complete' => __( 'All plugins installed and activated successfully. %s', 'cryout' ), // %s = dashboard link.
- 'nag_type' => 'updated' // Determines admin notice type - can only be 'updated', 'update-nag' or 'error'.
- )
- );
-
- tgmpa( $plugins, $config );
-
-}
-
-
-/***************** TGM class below *******************/
-
-/**
- * Plugin installation and activation for WordPress themes.
- *
- * Please note that this is a drop-in library for a theme or plugin.
- * The authors of this library (Thomas, Gary and Juliette) are NOT responsible
- * for the support of your plugin or theme. Please contact the plugin
- * or theme author for support.
- *
- * @package TGM-Plugin-Activation
- * @version 2.5.2
- * @link http://tgmpluginactivation.com/
- * @author Thomas Griffin, Gary Jones, Juliette Reinders Folmer
- * @copyright Copyright (c) 2011, Thomas Griffin
- * @license GPL-2.0+
- *
- * @wordpress-plugin
- * Plugin Name: TGM Plugin Activation
- * Plugin URI:
- * Description: Plugin installation and activation for WordPress themes.
- * Version: 2.5.2
- * Author: Thomas Griffin, Gary Jones, Juliette Reinders Folmer
- * Author URI: http://tgmpluginactivation.com/
- * Text Domain: tgmpa
- * Domain Path: /languages/
- * Copyright: 2011, Thomas Griffin
- */
-
-/*
- Copyright 2011 Thomas Griffin (thomasgriffinmedia.com)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License, version 2, as
- published by the Free Software Foundation.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-*/
-
-if ( ! class_exists( 'TGM_Plugin_Activation' ) ) {
-
- /**
- * Automatic plugin installation and activation library.
- *
- * Creates a way to automatically install and activate plugins from within themes.
- * The plugins can be either bundled, downloaded from the WordPress
- * Plugin Repository or downloaded from another external source.
- *
- * @since 1.0.0
- *
- * @package TGM-Plugin-Activation
- * @author Thomas Griffin
- * @author Gary Jones
- */
- class TGM_Plugin_Activation {
- /**
- * TGMPA version number.
- *
- * @since 2.5.0
- *
- * @const string Version number.
- */
- const TGMPA_VERSION = '2.5.2';
-
- /**
- * Regular expression to test if a URL is a WP plugin repo URL.
- *
- * @const string Regex.
- *
- * @since 2.5.0
- */
- const WP_REPO_REGEX = '|^http[s]?://wordpress\.org/(?:extend/)?plugins/|';
-
- /**
- * Arbitrary regular expression to test if a string starts with a URL.
- *
- * @const string Regex.
- *
- * @since 2.5.0
- */
- const IS_URL_REGEX = '|^http[s]?://|';
-
- /**
- * Holds a copy of itself, so it can be referenced by the class name.
- *
- * @since 1.0.0
- *
- * @var TGM_Plugin_Activation
- */
- public static $instance;
-
- /**
- * Holds arrays of plugin details.
- *
- * @since 1.0.0
- *
- * @since 2.5.0 the array has the plugin slug as an associative key.
- *
- * @var array
- */
- public $plugins = array();
-
- /**
- * Holds arrays of plugin names to use to sort the plugins array.
- *
- * @since 2.5.0
- *
- * @var array
- */
- protected $sort_order = array();
-
- /**
- * Whether any plugins have the 'force_activation' setting set to true.
- *
- * @since 2.5.0
- *
- * @var bool
- */
- protected $has_forced_activation = false;
-
- /**
- * Whether any plugins have the 'force_deactivation' setting set to true.
- *
- * @since 2.5.0
- *
- * @var bool
- */
- protected $has_forced_deactivation = false;
-
- /**
- * Name of the unique ID to hash notices.
- *
- * @since 2.4.0
- *
- * @var string
- */
- public $id = 'tgmpa';
-
- /**
- * Name of the query-string argument for the admin page.
- *
- * @since 1.0.0
- *
- * @var string
- */
- protected $menu = 'tgmpa-install-plugins';
-
- /**
- * Parent menu file slug.
- *
- * @since 2.5.0
- *
- * @var string
- */
- public $parent_slug = 'themes.php';
-
- /**
- * Capability needed to view the plugin installation menu item.
- *
- * @since 2.5.0
- *
- * @var string
- */
- public $capability = 'edit_theme_options';
-
- /**
- * Default absolute path to folder containing bundled plugin zip files.
- *
- * @since 2.0.0
- *
- * @var string Absolute path prefix to zip file location for bundled plugins. Default is empty string.
- */
- public $default_path = '';
-
- /**
- * Flag to show admin notices or not.
- *
- * @since 2.1.0
- *
- * @var boolean
- */
- public $has_notices = true;
-
- /**
- * Flag to determine if the user can dismiss the notice nag.
- *
- * @since 2.4.0
- *
- * @var boolean
- */
- public $dismissable = true;
-
- /**
- * Message to be output above nag notice if dismissable is false.
- *
- * @since 2.4.0
- *
- * @var string
- */
- public $dismiss_msg = '';
-
- /**
- * Flag to set automatic activation of plugins. Off by default.
- *
- * @since 2.2.0
- *
- * @var boolean
- */
- public $is_automatic = false;
-
- /**
- * Optional message to display before the plugins table.
- *
- * @since 2.2.0
- *
- * @var string Message filtered by wp_kses_post(). Default is empty string.
- */
- public $message = '';
-
- /**
- * Holds configurable array of strings.
- *
- * Default values are added in the constructor.
- *
- * @since 2.0.0
- *
- * @var array
- */
- public $strings = array();
-
- /**
- * Holds the version of WordPress.
- *
- * @since 2.4.0
- *
- * @var int
- */
- public $wp_version;
-
- /**
- * Holds the hook name for the admin page.
- *
- * @since 2.5.0
- *
- * @var string
- */
- public $page_hook;
-
- /**
- * Adds a reference of this object to $instance, populates default strings,
- * does the tgmpa_init action hook, and hooks in the interactions to init.
- *
- * @internal This method should be `protected`, but as too many TGMPA implementations
- * haven't upgraded beyond v2.3.6 yet, this gives backward compatibility issues.
- * Reverted back to public for the time being.
- *
- * @since 1.0.0
- *
- * @see TGM_Plugin_Activation::init()
- */
- public function __construct() {
- // Set the current WordPress version.
- $this->wp_version = $GLOBALS['wp_version'];
-
- // Announce that the class is ready, and pass the object (for advanced use).
- do_action_ref_array( 'tgmpa_init', array( $this ) );
-
- // When the rest of WP has loaded, kick-start the rest of the class.
- add_action( 'init', array( $this, 'init' ) );
- }
-
- /**
- * Magic method to (not) set protected properties from outside of this class.
- *
- * @internal hackedihack... There is a serious bug in v2.3.2 - 2.3.6 where the `menu` property
- * is being assigned rather than tested in a conditional, effectively rendering it useless.
- * This 'hack' prevents this from happening.
- *
- * @see https://github.com/TGMPA/TGM-Plugin-Activation/blob/2.3.6/tgm-plugin-activation/class-tgm-plugin-activation.php#L1593
- *
- * @param string $name Name of an inaccessible property.
- * @param mixed $value Value to assign to the property.
- * @return void Silently fail to set the property when this is tried from outside of this class context.
- * (Inside this class context, the __set() method if not used as there is direct access.)
- */
- public function __set( $name, $value ) {
- return;
- }
-
- /**
- * Magic method to get the value of a protected property outside of this class context.
- *
- * @param string $name Name of an inaccessible property.
- * @return mixed The property value.
- */
- public function __get( $name ) {
- return $this->{$name};
- }
-
- /**
- * Initialise the interactions between this class and WordPress.
- *
- * Hooks in three new methods for the class: admin_menu, notices and styles.
- *
- * @since 2.0.0
- *
- * @see TGM_Plugin_Activation::admin_menu()
- * @see TGM_Plugin_Activation::notices()
- * @see TGM_Plugin_Activation::styles()
- */
- public function init() {
- /**
- * By default TGMPA only loads on the WP back-end and not in an Ajax call. Using this filter
- * you can overrule that behaviour.
- *
- * @since 2.5.0
- *
- * @param bool $load Whether or not TGMPA should load.
- * Defaults to the return of `is_admin() && ! defined( 'DOING_AJAX' )`.
- */
- if ( true !== apply_filters( 'tgmpa_load', ( is_admin() && ! defined( 'DOING_AJAX' ) ) ) ) {
- return;
- }
-
- // Load class strings.
- $this->strings = array(
- 'page_title' => __( 'Install Required Plugins', 'cryout' ),
- 'menu_title' => __( 'Install Plugins', 'cryout' ),
- 'installing' => __( 'Installing Plugin: %s', 'cryout' ),
- 'oops' => __( 'Something went wrong with the plugin API.', 'cryout' ),
- 'notice_can_install_required' => _n_noop(
- 'This theme requires the following plugin: %1$s.',
- 'This theme requires the following plugins: %1$s.',
- 'cryout'
- ),
- 'notice_can_install_recommended' => _n_noop(
- 'This theme recommends the following plugin: %1$s.',
- 'This theme recommends the following plugins: %1$s.',
- 'cryout'
- ),
- 'notice_cannot_install' => _n_noop(
- 'Sorry, but you do not have the correct permissions to install the %1$s plugin.',
- 'Sorry, but you do not have the correct permissions to install the %1$s plugins.',
- 'cryout'
- ),
- 'notice_ask_to_update' => _n_noop(
- 'The following plugin needs to be updated to its latest version to ensure maximum compatibility with this theme: %1$s.',
- 'The following plugins need to be updated to their latest version to ensure maximum compatibility with this theme: %1$s.',
- 'cryout'
- ),
- 'notice_ask_to_update_maybe' => _n_noop(
- 'There is an update available for: %1$s.',
- 'There are updates available for the following plugins: %1$s.',
- 'cryout'
- ),
- 'notice_cannot_update' => _n_noop(
- 'Sorry, but you do not have the correct permissions to update the %1$s plugin.',
- 'Sorry, but you do not have the correct permissions to update the %1$s plugins.',
- 'cryout'
- ),
- 'notice_can_activate_required' => _n_noop(
- 'The following required plugin is currently inactive: %1$s.',
- 'The following required plugins are currently inactive: %1$s.',
- 'cryout'
- ),
- 'notice_can_activate_recommended' => _n_noop(
- 'The following recommended plugin is currently inactive: %1$s.',
- 'The following recommended plugins are currently inactive: %1$s.',
- 'cryout'
- ),
- 'notice_cannot_activate' => _n_noop(
- 'Sorry, but you do not have the correct permissions to activate the %1$s plugin.',
- 'Sorry, but you do not have the correct permissions to activate the %1$s plugins.',
- 'cryout'
- ),
- 'install_link' => _n_noop(
- 'Begin installing plugin',
- 'Begin installing plugins',
- 'cryout'
- ),
- 'update_link' => _n_noop(
- 'Begin updating plugin',
- 'Begin updating plugins',
- 'cryout'
- ),
- 'activate_link' => _n_noop(
- 'Begin activating plugin',
- 'Begin activating plugins',
- 'cryout'
- ),
- 'return' => __( 'Return to Required Plugins Installer', 'cryout' ),
- 'dashboard' => __( 'Return to the dashboard', 'cryout' ),
- 'plugin_activated' => __( 'Plugin activated successfully.', 'cryout' ),
- 'activated_successfully' => __( 'The following plugin was activated successfully:', 'cryout' ),
- 'plugin_already_active' => __( 'No action taken. Plugin %1$s was already active.', 'cryout' ),
- 'plugin_needs_higher_version' => __( 'Plugin not activated. A higher version of %s is needed for this theme. Please update the plugin.', 'cryout' ),
- 'complete' => __( 'All plugins installed and activated successfully. %1$s', 'cryout' ),
- 'dismiss' => __( 'Dismiss this notice', 'cryout' ),
- 'contact_admin' => __( 'Please contact the administrator of this site for help.', 'cryout' ),
- );
-
- do_action( 'tgmpa_register' );
-
- /* After this point, the plugins should be registered and the configuration set. */
-
- // Proceed only if we have plugins to handle.
- if ( empty( $this->plugins ) || ! is_array( $this->plugins ) ) {
- return;
- }
-
- // Set up the menu and notices if we still have outstanding actions.
- if ( true !== $this->is_tgmpa_complete() ) {
- // Sort the plugins.
- array_multisort( $this->sort_order, SORT_ASC, $this->plugins );
-
- add_action( 'admin_menu', array( $this, 'admin_menu' ) );
- add_action( 'admin_head', array( $this, 'dismiss' ) );
-
- // Prevent the normal links from showing underneath a single install/update page.
- add_filter( 'install_plugin_complete_actions', array( $this, 'actions' ) );
- add_filter( 'update_plugin_complete_actions', array( $this, 'actions' ) );
-
- if ( $this->has_notices ) {
- add_action( 'admin_notices', array( $this, 'notices' ) );
- add_action( 'admin_init', array( $this, 'admin_init' ), 1 );
- add_action( 'admin_enqueue_scripts', array( $this, 'thickbox' ) );
- }
-
- add_action( 'load-plugins.php', array( $this, 'add_plugin_action_link_filters' ), 1 );
- }
-
- // Make sure things get reset on switch theme.
- add_action( 'switch_theme', array( $this, 'flush_plugins_cache' ) );
-
- if ( $this->has_notices ) {
- add_action( 'switch_theme', array( $this, 'update_dismiss' ) );
- }
-
- // Setup the force activation hook.
- if ( true === $this->has_forced_activation ) {
- add_action( 'admin_init', array( $this, 'force_activation' ) );
- }
-
- // Setup the force deactivation hook.
- if ( true === $this->has_forced_deactivation ) {
- add_action( 'switch_theme', array( $this, 'force_deactivation' ) );
- }
- }
-
- /**
- * Prevent activation of plugins which don't meet the minimum version requirement from the
- * WP native plugins page.
- *
- * @since 2.5.0
- */
- public function add_plugin_action_link_filters() {
- foreach ( $this->plugins as $slug => $plugin ) {
- if ( false === $this->can_plugin_activate( $slug ) ) {
- add_filter( 'plugin_action_links_' . $plugin['file_path'], array( $this, 'filter_plugin_action_links_activate' ), 20 );
- }
-
- if ( true === $plugin['force_activation'] ) {
- add_filter( 'plugin_action_links_' . $plugin['file_path'], array( $this, 'filter_plugin_action_links_deactivate' ), 20 );
- }
-
- if ( false !== $this->does_plugin_require_update( $slug ) ) {
- add_filter( 'plugin_action_links_' . $plugin['file_path'], array( $this, 'filter_plugin_action_links_update' ), 20 );
- }
- }
- }
-
- /**
- * Remove the 'Activate' link on the WP native plugins page if the plugin does not meet the
- * minimum version requirements.
- *
- * @since 2.5.0
- *
- * @param array $actions Action links.
- * @return array
- */
- public function filter_plugin_action_links_activate( $actions ) {
- unset( $actions['activate'] );
-
- return $actions;
- }
-
- /**
- * Remove the 'Deactivate' link on the WP native plugins page if the plugin has been set to force activate.
- *
- * @since 2.5.0
- *
- * @param array $actions Action links.
- * @return array
- */
- public function filter_plugin_action_links_deactivate( $actions ) {
- unset( $actions['deactivate'] );
-
- return $actions;
- }
-
- /**
- * Add a 'Requires update' link on the WP native plugins page if the plugin does not meet the
- * minimum version requirements.
- *
- * @since 2.5.0
- *
- * @param array $actions Action links.
- * @return array
- */
- public function filter_plugin_action_links_update( $actions ) {
- $actions['update'] = sprintf(
- '<a href="%1$s" title="%2$s" class="edit">%3$s</a>',
- esc_url( $this->get_tgmpa_status_url( 'update' ) ),
- esc_attr__( 'This plugin needs to be updated to be compatible with your theme.', 'cryout' ),
- esc_html__( 'Update Required', 'cryout' )
- );
-
- return $actions;
- }
-
- /**
- * Handles calls to show plugin information via links in the notices.
- *
- * We get the links in the admin notices to point to the TGMPA page, rather
- * than the typical plugin-install.php file, so we can prepare everything
- * beforehand.
- *
- * WP does not make it easy to show the plugin information in the thickbox -
- * here we have to require a file that includes a function that does the
- * main work of displaying it, enqueue some styles, set up some globals and
- * finally call that function before exiting.
- *
- * Down right easy once you know how...
- *
- * Returns early if not the TGMPA page.
- *
- * @since 2.1.0
- *
- * @global string $tab Used as iframe div class names, helps with styling
- * @global string $body_id Used as the iframe body ID, helps with styling
- *
- * @return null Returns early if not the TGMPA page.
- */
- public function admin_init() {
- if ( ! $this->is_tgmpa_page() ) {
- return;
- }
-
- if ( isset( $_REQUEST['tab'] ) && 'plugin-information' === $_REQUEST['tab'] ) {
- // Needed for install_plugin_information().
- require_once ABSPATH . 'wp-admin/includes/plugin-install.php';
-
- wp_enqueue_style( 'plugin-install' );
-
- global $tab, $body_id;
- $body_id = 'plugin-information';
- // @codingStandardsIgnoreStart
- $tab = 'plugin-information';
- // @codingStandardsIgnoreEnd
-
- install_plugin_information();
-
- exit;
- }
- }
-
- /**
- * Enqueue thickbox scripts/styles for plugin info.
- *
- * Thickbox is not automatically included on all admin pages, so we must
- * manually enqueue it for those pages.
- *
- * Thickbox is only loaded if the user has not dismissed the admin
- * notice or if there are any plugins left to install and activate.
- *
- * @since 2.1.0
- */
- public function thickbox() {
- if ( ! get_user_meta( get_current_user_id(), 'tgmpa_dismissed_notice_' . $this->id, true ) ) {
- add_thickbox();
- }
- }
-
- /**
- * Adds submenu page if there are plugin actions to take.
- *
- * This method adds the submenu page letting users know that a required
- * plugin needs to be installed.
- *
- * This page disappears once the plugin has been installed and activated.
- *
- * @since 1.0.0
- *
- * @see TGM_Plugin_Activation::init()
- * @see TGM_Plugin_Activation::install_plugins_page()
- *
- * @return null Return early if user lacks capability to install a plugin.
- */
- public function admin_menu() {
- // Make sure privileges are correct to see the page.
- if ( ! current_user_can( 'install_plugins' ) ) {
- return;
- }
-
- $args = apply_filters(
- 'tgmpa_admin_menu_args',
- array(
- 'parent_slug' => $this->parent_slug, // Parent Menu slug.
- 'page_title' => $this->strings['page_title'], // Page title.
- 'menu_title' => $this->strings['menu_title'], // Menu title.
- 'capability' => $this->capability, // Capability.
- 'menu_slug' => $this->menu, // Menu slug.
- 'function' => array( $this, 'install_plugins_page' ), // Callback.
- )
- );
-
- $this->add_admin_menu( $args );
- }
-
- /**
- * Add the menu item.
- *
- * @since 2.5.0
- *
- * @param array $args Menu item configuration.
- */
- protected function add_admin_menu( array $args ) {
- if ( has_filter( 'tgmpa_admin_menu_use_add_theme_page' ) ) {
- _deprecated_function( 'The "tgmpa_admin_menu_use_add_theme_page" filter', '2.5.0', esc_html__( 'Set the parent_slug config variable instead.', 'cryout' ) );
- }
-
- // modified to pass theme check requirement
- $this->page_hook = call_user_func( 'add_theme_page', $args['page_title'], $args['menu_title'], $args['capability'], $args['menu_slug'], $args['function'] );
- }
-
- /**
- * Echoes plugin installation form.
- *
- * This method is the callback for the admin_menu method function.
- * This displays the admin page and form area where the user can select to install and activate the plugin.
- * Aborts early if we're processing a plugin installation action.
- *
- * @since 1.0.0
- *
- * @return null Aborts early if we're processing a plugin installation action.
- */
- public function install_plugins_page() {
- // Store new instance of plugin table in object.
- $plugin_table = new TGMPA_List_Table;
-
- // Return early if processing a plugin installation action.
- if ( ( ( 'tgmpa-bulk-install' === $plugin_table->current_action() || 'tgmpa-bulk-update' === $plugin_table->current_action() ) && $plugin_table->process_bulk_actions() ) || $this->do_plugin_install() ) {
- return;
- }
-
- // Force refresh of available plugin information so we'll know about manual updates/deletes.
- wp_clean_plugins_cache( false );
-
- ?>
- <div class="tgmpa wrap">
- <h2><?php echo esc_html( get_admin_page_title() ); ?></h2>
- <?php $plugin_table->prepare_items(); ?>
-
- <?php
- if ( ! empty( $this->message ) && is_string( $this->message ) ) {
- echo wp_kses_post( $this->message );
- }
- ?>
- <?php $plugin_table->views(); ?>
-
- <form id="tgmpa-plugins" action="" method="post">
- <input type="hidden" name="tgmpa-page" value="<?php echo esc_attr( $this->menu ); ?>" />
- <input type="hidden" name="plugin_status" value="<?php echo esc_attr( $plugin_table->view_context ); ?>" />
- <?php $plugin_table->display(); ?>
- </form>
- </div>
- <?php
- }
-
- /**
- * Installs, updates or activates a plugin depending on the action link clicked by the user.
- *
- * Checks the $_GET variable to see which actions have been
- * passed and responds with the appropriate method.
- *
- * Uses WP_Filesystem to process and handle the plugin installation
- * method.
- *
- * @since 1.0.0
- *
- * @uses WP_Filesystem
- * @uses WP_Error
- * @uses WP_Upgrader
- * @uses Plugin_Upgrader
- * @uses Plugin_Installer_Skin
- * @uses Plugin_Upgrader_Skin
- *
- * @return boolean True on success, false on failure.
- */
- protected function do_plugin_install() {
- if ( empty( $_GET['plugin'] ) ) {
- return false;
- }
-
- // All plugin information will be stored in an array for processing.
- $slug = $this->sanitize_key( urldecode( $_GET['plugin'] ) );
-
- if ( ! isset( $this->plugins[ $slug ] ) ) {
- return false;
- }
-
- // Was an install or upgrade action link clicked?
- if ( ( isset( $_GET['tgmpa-install'] ) && 'install-plugin' === $_GET['tgmpa-install'] ) || ( isset( $_GET['tgmpa-update'] ) && 'update-plugin' === $_GET['tgmpa-update'] ) ) {
-
- $install_type = 'install';
- if ( isset( $_GET['tgmpa-update'] ) && 'update-plugin' === $_GET['tgmpa-update'] ) {
- $install_type = 'update';
- }
-
- check_admin_referer( 'tgmpa-' . $install_type, 'tgmpa-nonce' );
-
- // Pass necessary information via URL if WP_Filesystem is needed.
- $url = wp_nonce_url(
- add_query_arg(
- array(
- 'plugin' => urlencode( $slug ),
- 'tgmpa-' . $install_type => $install_type . '-plugin',
- ),
- $this->get_tgmpa_url()
- ),
- 'tgmpa-' . $install_type,
- 'tgmpa-nonce'
- );
-
- $method = ''; // Leave blank so WP_Filesystem can populate it as necessary.
-
- if ( false === ( $creds = request_filesystem_credentials( esc_url_raw( $url ), $method, false, false, array() ) ) ) {
- return true;
- }
-
- if ( ! WP_Filesystem( $creds ) ) {
- request_filesystem_credentials( esc_url_raw( $url ), $method, true, false, array() ); // Setup WP_Filesystem.
- return true;
- }
-
- /* If we arrive here, we have the filesystem. */
-
- // Prep variables for Plugin_Installer_Skin class.
- $extra = array();
- $extra['slug'] = $slug; // Needed for potentially renaming of directory name.
- $source = $this->get_download_url( $slug );
- $api = ( 'repo' === $this->plugins[ $slug ]['source_type'] ) ? $this->get_plugins_api( $slug ) : null;
- $api = ( false !== $api ) ? $api : null;
-
- $url = add_query_arg(
- array(
- 'action' => $install_type . '-plugin',
- 'plugin' => urlencode( $slug ),
- ),
- 'update.php'
- );
-
- if ( ! class_exists( 'Plugin_Upgrader', false ) ) {
- require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
- }
-
- $skin_args = array(
- 'type' => ( 'bundled' !== $this->plugins[ $slug ]['source_type'] ) ? 'web' : 'upload',
- 'title' => sprintf( $this->strings['installing'], $this->plugins[ $slug ]['name'] ),
- 'url' => esc_url_raw( $url ),
- 'nonce' => $install_type . '-plugin_' . $slug,
- 'plugin' => '',
- 'api' => $api,
- 'extra' => $extra,
- );
-
- if ( 'update' === $install_type ) {
- $skin_args['plugin'] = $this->plugins[ $slug ]['file_path'];
- $skin = new Plugin_Upgrader_Skin( $skin_args );
- } else {
- $skin = new Plugin_Installer_Skin( $skin_args );
- }
-
- // Create a new instance of Plugin_Upgrader.
- $upgrader = new Plugin_Upgrader( $skin );
-
- // Perform the action and install the plugin from the $source urldecode().
- add_filter( 'upgrader_source_selection', array( $this, 'maybe_adjust_source_dir' ), 1, 3 );
-
- if ( 'update' === $install_type ) {
- // Inject our info into the update transient.
- $to_inject = array( $slug => $this->plugins[ $slug ] );
- $to_inject[ $slug ]['source'] = $source;
- $this->inject_update_info( $to_inject );
-
- $upgrader->upgrade( $this->plugins[ $slug ]['file_path'] );
- } else {
- $upgrader->install( $source );
- }
-
- remove_filter( 'upgrader_source_selection', array( $this, 'maybe_adjust_source_dir' ), 1, 3 );
-
- // Make sure we have the correct file path now the plugin is installed/updated.
- $this->populate_file_path( $slug );
-
- // Only activate plugins if the config option is set to true and the plugin isn't
- // already active (upgrade).
- if ( $this->is_automatic && ! $this->is_plugin_active( $slug ) ) {
- $plugin_activate = $upgrader->plugin_info(); // Grab the plugin info from the Plugin_Upgrader method.
- if ( false === $this->activate_single_plugin( $plugin_activate, $slug, true ) ) {
- return true; // Finish execution of the function early as we encountered an error.
- }
- }
-
- $this->show_tgmpa_version();
-
- // Display message based on if all plugins are now active or not.
- if ( $this->is_tgmpa_complete() ) {
- echo '<p>', sprintf( esc_html( $this->strings['complete'] ), '<a href="' . esc_url( self_admin_url() ) . '">' . esc_html__( 'Return to the Dashboard', 'cryout' ) . '</a>' ), '</p>';
- echo '<style type="text/css">#adminmenu .wp-submenu li.current { display: none !important; }</style>';
- } else {
- echo '<p><a href="', esc_url( $this->get_tgmpa_url() ), '" target="_parent">', esc_html( $this->strings['return'] ), '</a></p>';
- }
-
- return true;
- } elseif ( isset( $this->plugins[ $slug ]['file_path'], $_GET['tgmpa-activate'] ) && 'activate-plugin' === $_GET['tgmpa-activate'] ) {
- // Activate action link was clicked.
- check_admin_referer( 'tgmpa-activate', 'tgmpa-nonce' );
-
- if ( false === $this->activate_single_plugin( $this->plugins[ $slug ]['file_path'], $slug ) ) {
- return true; // Finish execution of the function early as we encountered an error.
- }
- }
-
- return false;
- }
-
- /**
- * Inject information into the 'update_plugins' site transient as WP checks that before running an update.
- *
- * @since 2.5.0
- *
- * @param array $plugins The plugin information for the plugins which are to be updated.
- */
- public function inject_update_info( $plugins ) {
- $repo_updates = get_site_transient( 'update_plugins' );
-
- if ( ! is_object( $repo_updates ) ) {
- $repo_updates = new stdClass;
- }
-
- foreach ( $plugins as $slug => $plugin ) {
- $file_path = $plugin['file_path'];
-
- if ( empty( $repo_updates->response[ $file_path ] ) ) {
- $repo_updates->response[ $file_path ] = new stdClass;
- }
-
- // We only really need to set package, but let's do all we can in case WP changes something.
- $repo_updates->response[ $file_path ]->slug = $slug;
- $repo_updates->response[ $file_path ]->plugin = $file_path;
- $repo_updates->response[ $file_path ]->new_version = $plugin['version'];
- $repo_updates->response[ $file_path ]->package = $plugin['source'];
- if ( empty( $repo_updates->response[ $file_path ]->url ) && ! empty( $plugin['external_url'] ) ) {
- $repo_updates->response[ $file_path ]->url = $plugin['external_url'];
- }
- }
-
- set_site_transient( 'update_plugins', $repo_updates );
- }
-
- /**
- * Adjust the plugin directory name if necessary.
- *
- * The final destination directory of a plugin is based on the subdirectory name found in the
- * (un)zipped source. In some cases - most notably GitHub repository plugin downloads -, this
- * subdirectory name is not the same as the expected slug and the plugin will not be recognized
- * as installed. This is fixed by adjusting the temporary unzipped source subdirectory name to
- * the expected plugin slug.
- *
- * @since 2.5.0
- *
- * @param string $source Path to upgrade/zip-file-name.tmp/subdirectory/.
- * @param string $remote_source Path to upgrade/zip-file-name.tmp.
- * @param \WP_Upgrader $upgrader Instance of the upgrader which installs the plugin.
- * @return string $source
- */
- public function maybe_adjust_source_dir( $source, $remote_source, $upgrader ) {
- if ( ! $this->is_tgmpa_page() || ! is_object( $GLOBALS['wp_filesystem'] ) ) {
- return $source;
- }
-
- // Check for single file plugins.
- $source_files = array_keys( $GLOBALS['wp_filesystem']->dirlist( $remote_source ) );
- if ( 1 === count( $source_files ) && false === $GLOBALS['wp_filesystem']->is_dir( $source ) ) {
- return $source;
- }
-
- // Multi-file plugin, let's see if the directory is correctly named.
- $desired_slug = '';
-
- // Figure out what the slug is supposed to be.
- if ( false === $upgrader->bulk && ! empty( $upgrader->skin->options['extra']['slug'] ) ) {
- $desired_slug = $upgrader->skin->options['extra']['slug'];
- } else {
- // Bulk installer contains less info, so fall back on the info registered here.
- foreach ( $this->plugins as $slug => $plugin ) {
- if ( ! empty( $upgrader->skin->plugin_names[ $upgrader->skin->i ] ) && $plugin['name'] === $upgrader->skin->plugin_names[ $upgrader->skin->i ] ) {
- $desired_slug = $slug;
- break;
- }
- }
- unset( $slug, $plugin );
- }
-
- if ( ! empty( $desired_slug ) ) {
- $subdir_name = untrailingslashit( str_replace( trailingslashit( $remote_source ), '', $source ) );
-
- if ( ! empty( $subdir_name ) && $subdir_name !== $desired_slug ) {
- $from = untrailingslashit( $source );
- $to = trailingslashit( $remote_source ) . $desired_slug;
-
- if ( true === $GLOBALS['wp_filesystem']->move( $from, $to ) ) {
- return trailingslashit( $to );
- } else {
- return new WP_Error( 'rename_failed', esc_html__( 'The remote plugin package does not contain a folder with the desired slug and renaming did not work.', 'cryout' ) . ' ' . esc_html__( 'Please contact the plugin provider and ask them to package their plugin according to the WordPress guidelines.', 'cryout' ), array( 'found' => $subdir_name, 'expected' => $desired_slug ) );
- }
- } elseif ( empty( $subdir_name ) ) {
- return new WP_Error( 'packaged_wrong', esc_html__( 'The remote plugin package consists of more than one file, but the files are not packaged in a folder.', 'cryout' ) . ' ' . esc_html__( 'Please contact the plugin provider and ask them to package their plugin according to the WordPress guidelines.', 'cryout' ), array( 'found' => $subdir_name, 'expected' => $desired_slug ) );
- }
- }
-
- return $source;
- }
-
- /**
- * Activate a single plugin and send feedback about the result to the screen.
- *
- * @since 2.5.0
- *
- * @param string $file_path Path within wp-plugins/ to main plugin file.
- * @param string $slug Plugin slug.
- * @param bool $automatic Whether this is an automatic activation after an install. Defaults to false.
- * This determines the styling of the output messages.
- * @return bool False if an error was encountered, true otherwise.
- */
- protected function activate_single_plugin( $file_path, $slug, $automatic = false ) {
- if ( $this->can_plugin_activate( $slug ) ) {
- $activate = activate_plugin( $file_path );
-
- if ( is_wp_error( $activate ) ) {
- echo '<div id="message" class="error"><p>', wp_kses_post( $activate->get_error_message() ), '</p></div>',
- '<p><a href="', esc_url( $this->get_tgmpa_url() ), '" target="_parent">', esc_html( $this->strings['return'] ), '</a></p>';
-
- return false; // End it here if there is an error with activation.
- } else {
- if ( ! $automatic ) {
- // Make sure message doesn't display again if bulk activation is performed
- // immediately after a single activation.
- if ( ! isset( $_POST['action'] ) ) { // WPCS: CSRF OK.
- echo '<div id="message" class="updated"><p>', esc_html( $this->strings['activated_successfully'] ), ' <strong>', esc_html( $this->plugins[ $slug ]['name'] ), '.</strong></p></div>';
- }
- } else {
- // Simpler message layout for use on the plugin install page.
- echo '<p>', esc_html( $this->strings['plugin_activated'] ), '</p>';
- }
- }
- } elseif ( $this->is_plugin_active( $slug ) ) {
- // No simpler message format provided as this message should never be encountered
- // on the plugin install page.
- echo '<div id="message" class="error"><p>',
- sprintf(
- esc_html( $this->strings['plugin_already_active'] ),
- '<strong>' . esc_html( $this->plugins[ $slug ]['name'] ) . '</strong>'
- ),
- '</p></div>';
- } elseif ( $this->does_plugin_require_update( $slug ) ) {
- if ( ! $automatic ) {
- // Make sure message doesn't display again if bulk activation is performed
- // immediately after a single activation.
- if ( ! isset( $_POST['action'] ) ) { // WPCS: CSRF OK.
- echo '<div id="message" class="error"><p>',
- sprintf(
- esc_html( $this->strings['plugin_needs_higher_version'] ),
- '<strong>' . esc_html( $this->plugins[ $slug ]['name'] ) . '</strong>'
- ),
- '</p></div>';
- }
- } else {
- // Simpler message layout for use on the plugin install page.
- echo '<p>', sprintf( esc_html( $this->strings['plugin_needs_higher_version'] ), esc_html( $this->plugins[ $slug ]['name'] ) ), '</p>';
- }
- }
-
- return true;
- }
-
- /**
- * Echoes required plugin notice.
- *
- * Outputs a message telling users that a specific plugin is required for
- * their theme. If appropriate, it includes a link to the form page where
- * users can install and activate the plugin.
- *
- * Returns early if we're on the Install page.
- *
- * @since 1.0.0
- *
- * @global object $current_screen
- *
- * @return null Returns early if we're on the Install page.
- */
- public function notices() {
- // Remove nag on the install page / Return early if the nag message has been dismissed.
- if ( $this->is_tgmpa_page() || get_user_meta( get_current_user_id(), 'tgmpa_dismissed_notice_' . $this->id, true ) ) {
- return;
- }
-
- // Store for the plugin slugs by message type.
- $message = array();
-
- // Initialize counters used to determine plurality of action link texts.
- $install_link_count = 0;
- $update_link_count = 0;
- $activate_link_count = 0;
-
- foreach ( $this->plugins as $slug => $plugin ) {
- if ( $this->is_plugin_active( $slug ) && false === $this->does_plugin_have_update( $slug ) ) {
- continue;
- }
-
- if ( ! $this->is_plugin_installed( $slug ) ) {
- if ( current_user_can( 'install_plugins' ) ) {
- $install_link_count++;
-
- if ( true === $plugin['required'] ) {
- $message['notice_can_install_required'][] = $slug;
- } else {
- $message['notice_can_install_recommended'][] = $slug;
- }
- } else {
- // Need higher privileges to install the plugin.
- $message['notice_cannot_install'][] = $slug;
- }
- } else {
- if ( ! $this->is_plugin_active( $slug ) && $this->can_plugin_activate( $slug ) ) {
- if ( current_user_can( 'activate_plugins' ) ) {
- $activate_link_count++;
-
- if ( true === $plugin['required'] ) {
- $message['notice_can_activate_required'][] = $slug;
- } else {
- $message['notice_can_activate_recommended'][] = $slug;
- }
- } else {
- // Need higher privileges to activate the plugin.
- $message['notice_cannot_activate'][] = $slug;
- }
- }
-
- if ( $this->does_plugin_require_update( $slug ) || false !== $this->does_plugin_have_update( $slug ) ) {
-
- if ( current_user_can( 'install_plugins' ) ) {
- $update_link_count++;
-
- if ( $this->does_plugin_require_update( $slug ) ) {
- $message['notice_ask_to_update'][] = $slug;
- } elseif ( false !== $this->does_plugin_have_update( $slug ) ) {
- $message['notice_ask_to_update_maybe'][] = $slug;
- }
- } else {
- // Need higher privileges to update the plugin.
- $message['notice_cannot_update'][] = $slug;
- }
- }
- }
- }
- unset( $slug, $plugin );
-
- // If we have notices to display, we move forward.
- if ( ! empty( $message ) ) {
- krsort( $message ); // Sort messages.
- $rendered = '';
-
- // As add_settings_error() wraps the final message in a <p> and as the final message can't be
- // filtered, using <p>'s in our html would render invalid html output.
- $line_template = '<span style="display: block; margin: 0.5em 0.5em 0 0; clear: both;">%s</span>' . "\n";
-
- // If dismissable is false and a message is set, output it now.
- if ( ! $this->dismissable && ! empty( $this->dismiss_msg ) ) {
- $rendered .= sprintf( $line_template, wp_kses_post( $this->dismiss_msg ) );
- }
-
- // Render the individual message lines for the notice.
- foreach ( $message as $type => $plugin_group ) {
- $linked_plugins = array();
-
- // Get the external info link for a plugin if one is available.
- foreach ( $plugin_group as $plugin_slug ) {
- $linked_plugins[] = $this->get_info_link( $plugin_slug );
- }
- unset( $plugin_slug );
-
- $count = count( $plugin_group );
- $linked_plugins = array_map( array( 'TGMPA_Utils', 'wrap_in_em' ), $linked_plugins );
- $last_plugin = array_pop( $linked_plugins ); // Pop off last name to prep for readability.
- $imploded = empty( $linked_plugins ) ? $last_plugin : ( implode( ', ', $linked_plugins ) . ' ' . esc_html_x( 'and', 'plugin A *and* plugin B', 'cryout' ) . ' ' . $last_plugin );
-
- $rendered .= sprintf(
- $line_template,
- sprintf(
- translate_nooped_plural( $this->strings[ $type ], $count, 'cryout' ),
- $imploded,
- $count
- )
- );
-
- if ( 0 === strpos( $type, 'notice_cannot' ) ) {
- $rendered .= $this->strings['contact_admin'];
- }
- }
- unset( $type, $plugin_group, $linked_plugins, $count, $last_plugin, $imploded );
-
- // Setup action links.
- $action_links = array(
- 'install' => '',
- 'update' => '',
- 'activate' => '',
- 'dismiss' => $this->dismissable ? '<a href="' . esc_url( add_query_arg( 'tgmpa-dismiss', 'dismiss_admin_notices' ) ) . '" class="dismiss-notice" target="_parent">' . esc_html( $this->strings['dismiss'] ) . '</a>' : '',
- );
-
- $link_template = '<a href="%2$s">%1$s</a>';
-
- if ( current_user_can( 'install_plugins' ) ) {
- if ( $install_link_count > 0 ) {
- $action_links['install'] = sprintf(
- $link_template,
- translate_nooped_plural( $this->strings['install_link'], $install_link_count, 'cryout' ),
- esc_url( $this->get_tgmpa_status_url( 'install' ) )
- );
- }
- if ( $update_link_count > 0 ) {
- $action_links['update'] = sprintf(
- $link_template,
- translate_nooped_plural( $this->strings['update_link'], $update_link_count, 'cryout' ),
- esc_url( $this->get_tgmpa_status_url( 'update' ) )
- );
- }
- }
-
- if ( current_user_can( 'activate_plugins' ) && $activate_link_count > 0 ) {
- $action_links['activate'] = sprintf(
- $link_template,
- translate_nooped_plural( $this->strings['activate_link'], $activate_link_count, 'cryout' ),
- esc_url( $this->get_tgmpa_status_url( 'activate' ) )
- );
- }
-
- $action_links = apply_filters( 'tgmpa_notice_action_links', $action_links );
-
- $action_links = array_filter( (array) $action_links ); // Remove any empty array items.
-
- if ( ! empty( $action_links ) && is_array( $action_links ) ) {
- $action_links = sprintf( $line_template, implode( ' | ', $action_links ) );
- $rendered .= apply_filters( 'tgmpa_notice_rendered_action_links', $action_links );
- }
-
- // Register the nag messages and prepare them to be processed.
- if ( ! empty( $this->strings['nag_type'] ) ) {
- add_settings_error( 'tgmpa', 'tgmpa', $rendered, sanitize_html_class( strtolower( $this->strings['nag_type'] ) ) );
- } else {
- $nag_class = version_compare( $this->wp_version, '3.8', '<' ) ? 'updated' : 'update-nag';
- add_settings_error( 'tgmpa', 'tgmpa', $rendered, $nag_class );
- }
- }
-
- // Admin options pages already output settings_errors, so this is to avoid duplication.
- if ( 'options-general' !== $GLOBALS['current_screen']->parent_base ) {
- $this->display_settings_errors();
- }
- }
-
- /**
- * Display settings errors and remove those which have been displayed to avoid duplicate messages showing
- *
- * @since 2.5.0
- */
- protected function display_settings_errors() {
- global $wp_settings_errors;
-
- settings_errors( 'tgmpa' );
-
- foreach ( (array) $wp_settings_errors as $key => $details ) {
- if ( 'tgmpa' === $details['setting'] ) {
- unset( $wp_settings_errors[ $key ] );
- break;
- }
- }
- }
-
- /**
- * Add dismissable admin notices.
- *
- * Appends a link to the admin nag messages. If clicked, the admin notice disappears and no longer is visible to users.
- *
- * @since 2.1.0
- */
- public function dismiss() {
- if ( isset( $_GET['tgmpa-dismiss'] ) ) {
- update_user_meta( get_current_user_id(), 'tgmpa_dismissed_notice_' . $this->id, 1 );
- }
- }
-
- /**
- * Add individual plugin to our collection of plugins.
- *
- * If the required keys are not set or the plugin has already
- * been registered, the plugin is not added.
- *
- * @since 2.0.0
- *
- * @param array|null $plugin Array of plugin arguments or null if invalid argument.
- * @return null Return early if incorrect argument.
- */
- public function register( $plugin ) {
- if ( empty( $plugin['slug'] ) || empty( $plugin['name'] ) ) {
- return;
- }
-
- if ( empty( $plugin['slug'] ) || ! is_string( $plugin['slug'] ) || isset( $this->plugins[ $plugin['slug'] ] ) ) {
- return;
- }
-
- $defaults = array(
- 'name' => '', // String
- 'slug' => '', // String
- 'source' => 'repo', // String
- 'required' => false, // Boolean
- 'version' => '', // String
- 'force_activation' => false, // Boolean
- 'force_deactivation' => false, // Boolean
- 'external_url' => '', // String
- 'is_callable' => '', // String|Array.
- );
-
- // Prepare the received data.
- $plugin = wp_parse_args( $plugin, $defaults );
-
- // Standardize the received slug.
- $plugin['slug'] = $this->sanitize_key( $plugin['slug'] );
-
- // Forgive users for using string versions of booleans or floats for version number.
- $plugin['version'] = (string) $plugin['version'];
- $plugin['source'] = empty( $plugin['source'] ) ? 'repo' : $plugin['source'];
- $plugin['required'] = TGMPA_Utils::validate_bool( $plugin['required'] );
- $plugin['force_activation'] = TGMPA_Utils::validate_bool( $plugin['force_activation'] );
- $plugin['force_deactivation'] = TGMPA_Utils::validate_bool( $plugin['force_deactivation'] );
-
- // Enrich the received data.
- $plugin['file_path'] = $this->_get_plugin_basename_from_slug( $plugin['slug'] );
- $plugin['source_type'] = $this->get_plugin_source_type( $plugin['source'] );
-
- // Set the class properties.
- $this->plugins[ $plugin['slug'] ] = $plugin;
- $this->sort_order[ $plugin['slug'] ] = $plugin['name'];
-
- // Should we add the force activation hook ?
- if ( true === $plugin['force_activation'] ) {
- $this->has_forced_activation = true;
- }
-
- // Should we add the force deactivation hook ?
- if ( true === $plugin['force_deactivation'] ) {
- $this->has_forced_deactivation = true;
- }
- }
-
- /**
- * Determine what type of source the plugin comes from.
- *
- * @since 2.5.0
- *
- * @param string $source The source of the plugin as provided, either empty (= WP repo), a file path
- * (= bundled) or an external URL.
- * @return string 'repo', 'external', or 'bundled'
- */
- protected function get_plugin_source_type( $source ) {
- if ( 'repo' === $source || preg_match( self::WP_REPO_REGEX, $source ) ) {
- return 'repo';
- } elseif ( preg_match( self::IS_URL_REGEX, $source ) ) {
- return 'external';
- } else {
- return 'bundled';
- }
- }
-
- /**
- * Sanitizes a string key.
- *
- * Near duplicate of WP Core `sanitize_key()`. The difference is that uppercase characters *are*
- * allowed, so as not to break upgrade paths from non-standard bundled plugins using uppercase
- * characters in the plugin directory path/slug. Silly them.
- *
- * @see https://developer.wordpress.org/reference/hooks/sanitize_key/
- *
- * @since 2.5.0
- *
- * @param string $key String key.
- * @return string Sanitized key
- */
- public function sanitize_key( $key ) {
- $raw_key = $key;
- $key = preg_replace( '`[^A-Za-z0-9_-]`', '', $key );
-
- /**
- * Filter a sanitized key string.
- *
- * @since 3.0.0
- *
- * @param string $key Sanitized key.
- * @param string $raw_key The key prior to sanitization.
- */
- return apply_filters( 'tgmpa_sanitize_key', $key, $raw_key );
- }
-
- /**
- * Amend default configuration settings.
- *
- * @since 2.0.0
- *
- * @param array $config Array of config options to pass as class properties.
- */
- public function config( $config ) {
- $keys = array(
- 'id',
- 'default_path',
- 'has_notices',
- 'dismissable',
- 'dismiss_msg',
- 'menu',
- 'parent_slug',
- 'capability',
- 'is_automatic',
- 'message',
- 'strings',
- );
-
- foreach ( $keys as $key ) {
- if ( isset( $config[ $key ] ) ) {
- if ( is_array( $config[ $key ] ) ) {
- $this->$key = array_merge( $this->$key, $config[ $key ] );
- } else {
- $this->$key = $config[ $key ];
- }
- }
- }
- }
-
- /**
- * Amend action link after plugin installation.
- *
- * @since 2.0.0
- *
- * @param array $install_actions Existing array of actions.
- * @return array Amended array of actions.
- */
- public function actions( $install_actions ) {
- // Remove action links on the TGMPA install page.
- if ( $this->is_tgmpa_page() ) {
- return false;
- }
-
- return $install_actions;
- }
-
- /**
- * Flushes the plugins cache on theme switch to prevent stale entries
- * from remaining in the plugin table.
- *
- * @since 2.4.0
- *
- * @param bool $clear_update_cache Optional. Whether to clear the Plugin updates cache.
- * Parameter added in v2.5.0.
- */
- public function flush_plugins_cache( $clear_update_cache = true ) {
- wp_clean_plugins_cache( $clear_update_cache );
- }
-
- /**
- * Set file_path key for each installed plugin.
- *
- * @since 2.1.0
- *
- * @param string $plugin_slug Optional. If set, only (re-)populates the file path for that specific plugin.
- * Parameter added in v2.5.0.
- */
- public function populate_file_path( $plugin_slug = '' ) {
- if ( ! empty( $plugin_slug ) && is_string( $plugin_slug ) && isset( $this->plugins[ $plugin_slug ] ) ) {
- $this->plugins[ $plugin_slug ]['file_path'] = $this->_get_plugin_basename_from_slug( $plugin_slug );
- } else {
- // Add file_path key for all plugins.
- foreach ( $this->plugins as $slug => $values ) {
- $this->plugins[ $slug ]['file_path'] = $this->_get_plugin_basename_from_slug( $slug );
- }
- }
- }
-
- /**
- * Helper function to extract the file path of the plugin file from the
- * plugin slug, if the plugin is installed.
- *
- * @since 2.0.0
- *
- * @param string $slug Plugin slug (typically folder name) as provided by the developer.
- * @return string Either file path for plugin if installed, or just the plugin slug.
- */
- protected function _get_plugin_basename_from_slug( $slug ) {
- $keys = array_keys( $this->get_plugins() );
-
- foreach ( $keys as $key ) {
- if ( preg_match( '|^' . $slug . '/|', $key ) ) {
- return $key;
- }
- }
-
- return $slug;
- }
-
- /**
- * Retrieve plugin data, given the plugin name.
- *
- * Loops through the registered plugins looking for $name. If it finds it,
- * it returns the $data from that plugin. Otherwise, returns false.
- *
- * @since 2.1.0
- *
- * @param string $name Name of the plugin, as it was registered.
- * @param string $data Optional. Array key of plugin data to return. Default is slug.
- * @return string|boolean Plugin slug if found, false otherwise.
- */
- public function _get_plugin_data_from_name( $name, $data = 'slug' ) {
- foreach ( $this->plugins as $values ) {
- if ( $name === $values['name'] && isset( $values[ $data ] ) ) {
- return $values[ $data ];
- }
- }
-
- return false;
- }
-
- /**
- * Retrieve the download URL for a package.
- *
- * @since 2.5.0
- *
- * @param string $slug Plugin slug.
- * @return string Plugin download URL or path to local file or empty string if undetermined.
- */
- public function get_download_url( $slug ) {
- $dl_source = '';
-
- switch ( $this->plugins[ $slug ]['source_type'] ) {
- case 'repo':
- return $this->get_wp_repo_download_url( $slug );
- case 'external':
- return $this->plugins[ $slug ]['source'];
- case 'bundled':
- return $this->default_path . $this->plugins[ $slug ]['source'];
- }
-
- return $dl_source; // Should never happen.
- }
-
- /**
- * Retrieve the download URL for a WP repo package.
- *
- * @since 2.5.0
- *
- * @param string $slug Plugin slug.
- * @return string Plugin download URL.
- */
- protected function get_wp_repo_download_url( $slug ) {
- $source = '';
- $api = $this->get_plugins_api( $slug );
-
- if ( false !== $api && isset( $api->download_link ) ) {
- $source = $api->download_link;
- }
-
- return $source;
- }
-
- /**
- * Try to grab information from WordPress API.
- *
- * @since 2.5.0
- *
- * @param string $slug Plugin slug.
- * @return object Plugins_api response object on success, WP_Error on failure.
- */
- protected function get_plugins_api( $slug ) {
- static $api = array(); // Cache received responses.
-
- if ( ! isset( $api[ $slug ] ) ) {
- if ( ! function_exists( 'plugins_api' ) ) {
- require_once ABSPATH . 'wp-admin/includes/plugin-install.php';
- }
-
- $response = plugins_api( 'plugin_information', array( 'slug' => $slug, 'fields' => array( 'sections' => false ) ) );
-
- $api[ $slug ] = false;
-
- if ( is_wp_error( $response ) ) {
- wp_die( esc_html( $this->strings['oops'] ) );
- } else {
- $api[ $slug ] = $response;
- }
- }
-
- return $api[ $slug ];
- }
-
- /**
- * Retrieve a link to a plugin information page.
- *
- * @since 2.5.0
- *
- * @param string $slug Plugin slug.
- * @return string Fully formed html link to a plugin information page if available
- * or the plugin name if not.
- */
- public function get_info_link( $slug ) {
- if ( ! empty( $this->plugins[ $slug ]['external_url'] ) && preg_match( self::IS_URL_REGEX, $this->plugins[ $slug ]['external_url'] ) ) {
- $link = sprintf(
- '<a href="%1$s" target="_blank">%2$s</a>',
- esc_url( $this->plugins[ $slug ]['external_url'] ),
- esc_html( $this->plugins[ $slug ]['name'] )
- );
- } elseif ( 'repo' === $this->plugins[ $slug ]['source_type'] ) {
- $url = add_query_arg(
- array(
- 'tab' => 'plugin-information',
- 'plugin' => urlencode( $slug ),
- 'TB_iframe' => 'true',
- 'width' => '640',
- 'height' => '500',
- ),
- self_admin_url( 'plugin-install.php' )
- );
-
- $link = sprintf(
- '<a href="%1$s" class="thickbox">%2$s</a>',
- esc_url( $url ),
- esc_html( $this->plugins[ $slug ]['name'] )
- );
- } else {
- $link = esc_html( $this->plugins[ $slug ]['name'] ); // No hyperlink.
- }
-
- return $link;
- }
-
- /**
- * Determine if we're on the TGMPA Install page.
- *
- * @since 2.1.0
- *
- * @return boolean True when on the TGMPA page, false otherwise.
- */
- protected function is_tgmpa_page() {
- return isset( $_GET['page'] ) && $this->menu === $_GET['page'];
- }
-
- /**
- * Retrieve the URL to the TGMPA Install page.
- *
- * I.e. depending on the config settings passed something along the lines of:
- * http://example.com/wp-admin/themes.php?page=tgmpa-install-plugins
- *
- * @since 2.5.0
- *
- * @return string Properly encoded URL (not escaped).
- */
- public function get_tgmpa_url() {
- static $url;
-
- if ( ! isset( $url ) ) {
- $parent = $this->parent_slug;
- if ( false === strpos( $parent, '.php' ) ) {
- $parent = 'admin.php';
- }
- $url = add_query_arg(
- array(
- 'page' => urlencode( $this->menu ),
- ),
- self_admin_url( $parent )
- );
- }
-
- return $url;
- }
-
- /**
- * Retrieve the URL to the TGMPA Install page for a specific plugin status (view).
- *
- * I.e. depending on the config settings passed something along the lines of:
- * http://example.com/wp-admin/themes.php?page=tgmpa-install-plugins&plugin_status=install
- *
- * @since 2.5.0
- *
- * @param string $status Plugin status - either 'install', 'update' or 'activate'.
- * @return string Properly encoded URL (not escaped).
- */
- public function get_tgmpa_status_url( $status ) {
- return add_query_arg(
- array(
- 'plugin_status' => urlencode( $status ),
- ),
- $this->get_tgmpa_url()
- );
- }
-
- /**
- * Determine whether there are open actions for plugins registered with TGMPA.
- *
- * @since 2.5.0
- *
- * @return bool True if complete, i.e. no outstanding actions. False otherwise.
- */
- public function is_tgmpa_complete() {
- $complete = true;
- foreach ( $this->plugins as $slug => $plugin ) {
- if ( ! $this->is_plugin_active( $slug ) || false !== $this->does_plugin_have_update( $slug ) ) {
- $complete = false;
- break;
- }
- }
-
- return $complete;
- }
-
- /**
- * Check if a plugin is installed. Does not take must-use plugins into account.
- *
- * @since 2.5.0
- *
- * @param string $slug Plugin slug.
- * @return bool True if installed, false otherwise.
- */
- public function is_plugin_installed( $slug ) {
- $installed_plugins = $this->get_plugins(); // Retrieve a list of all installed plugins (WP cached).
-
- return ( ! empty( $installed_plugins[ $this->plugins[ $slug ]['file_path'] ] ) );
- }
-
- /**
- * Check if a plugin is active.
- *
- * @since 2.5.0
- *
- * @param string $slug Plugin slug.
- * @return bool True if active, false otherwise.
- */
- public function is_plugin_active( $slug ) {
- return ( ( ! empty( $this->plugins[ $slug ]['is_callable'] ) && is_callable( $this->plugins[ $slug ]['is_callable'] ) ) || is_plugin_active( $this->plugins[ $slug ]['file_path'] ) );
- }
-
- /**
- * Check if a plugin can be updated, i.e. if we have information on the minimum WP version required
- * available, check whether the current install meets them.
- *
- * @since 2.5.0
- *
- * @param string $slug Plugin slug.
- * @return bool True if OK to update, false otherwise.
- */
- public function can_plugin_update( $slug ) {
- // We currently can't get reliable info on non-WP-repo plugins - issue #380.
- if ( 'repo' !== $this->plugins[ $slug ]['source_type'] ) {
- return true;
- }
-
- $api = $this->get_plugins_api( $slug );
-
- if ( false !== $api && isset( $api->requires ) ) {
- return version_compare( $GLOBALS['wp_version'], $api->requires, '>=' );
- }
-
- // No usable info received from the plugins API, presume we can update.
- return true;
- }
-
- /**
- * Check if a plugin can be activated, i.e. is not currently active and meets the minimum
- * plugin version requirements set in TGMPA (if any).
- *
- * @since 2.5.0
- *
- * @param string $slug Plugin slug.
- * @return bool True if OK to activate, false otherwise.
- */
- public function can_plugin_activate( $slug ) {
- return ( ! $this->is_plugin_active( $slug ) && ! $this->does_plugin_require_update( $slug ) );
- }
-
- /**
- * Retrieve the version number of an installed plugin.
- *
- * @since 2.5.0
- *
- * @param string $slug Plugin slug.
- * @return string Version number as string or an empty string if the plugin is not installed
- * or version unknown (plugins which don't comply with the plugin header standard).
- */
- public function get_installed_version( $slug ) {
- $installed_plugins = $this->get_plugins(); // Retrieve a list of all installed plugins (WP cached).
-
- if ( ! empty( $installed_plugins[ $this->plugins[ $slug ]['file_path'] ]['Version'] ) ) {
- return $installed_plugins[ $this->plugins[ $slug ]['file_path'] ]['Version'];
- }
-
- return '';
- }
-
- /**
- * Check whether a plugin complies with the minimum version requirements.
- *
- * @since 2.5.0
- *
- * @param string $slug Plugin slug.
- * @return bool True when a plugin needs to be updated, otherwise false.
- */
- public function does_plugin_require_update( $slug ) {
- $installed_version = $this->get_installed_version( $slug );
- $minimum_version = $this->plugins[ $slug ]['version'];
-
- return version_compare( $minimum_version, $installed_version, '>' );
- }
-
- /**
- * Check whether there is an update available for a plugin.
- *
- * @since 2.5.0
- *
- * @param string $slug Plugin slug.
- * @return false|string Version number string of the available update or false if no update available.
- */
- public function does_plugin_have_update( $slug ) {
- // Presume bundled and external plugins will point to a package which meets the minimum required version.
- if ( 'repo' !== $this->plugins[ $slug ]['source_type'] ) {
- if ( $this->does_plugin_require_update( $slug ) ) {
- return $this->plugins[ $slug ]['version'];
- }
-
- return false;
- }
-
- $repo_updates = get_site_transient( 'update_plugins' );
-
- if ( isset( $repo_updates->response[ $this->plugins[ $slug ]['file_path'] ]->new_version ) ) {
- return $repo_updates->response[ $this->plugins[ $slug ]['file_path'] ]->new_version;
- }
-
- return false;
- }
-
- /**
- * Retrieve potential upgrade notice for a plugin.
- *
- * @since 2.5.0
- *
- * @param string $slug Plugin slug.
- * @return string The upgrade notice or an empty string if no message was available or provided.
- */
- public function get_upgrade_notice( $slug ) {
- // We currently can't get reliable info on non-WP-repo plugins - issue #380.
- if ( 'repo' !== $this->plugins[ $slug ]['source_type'] ) {
- return '';
- }
-
- $repo_updates = get_site_transient( 'update_plugins' );
-
- if ( ! empty( $repo_updates->response[ $this->plugins[ $slug ]['file_path'] ]->upgrade_notice ) ) {
- return $repo_updates->response[ $this->plugins[ $slug ]['file_path'] ]->upgrade_notice;
- }
-
- return '';
- }
-
- /**
- * Wrapper around the core WP get_plugins function, making sure it's actually available.
- *
- * @since 2.5.0
- *
- * @param string $plugin_folder Optional. Relative path to single plugin folder.
- * @return array Array of installed plugins with plugin information.
- */
- public function get_plugins( $plugin_folder = '' ) {
- if ( ! function_exists( 'get_plugins' ) ) {
- require_once ABSPATH . 'wp-admin/includes/plugin.php';
- }
-
- return get_plugins( $plugin_folder );
- }
-
- /**
- * Delete dismissable nag option when theme is switched.
- *
- * This ensures that the user(s) is/are again reminded via nag of required
- * and/or recommended plugins if they re-activate the theme.
- *
- * @since 2.1.1
- */
- public function update_dismiss() {
- delete_metadata( 'user', null, 'tgmpa_dismissed_notice_' . $this->id, null, true );
- }
-
- /**
- * Forces plugin activation if the parameter 'force_activation' is
- * set to true.
- *
- * This allows theme authors to specify certain plugins that must be
- * active at all times while using the current theme.
- *
- * Please take special care when using this parameter as it has the
- * potential to be harmful if not used correctly. Setting this parameter
- * to true will not allow the specified plugin to be deactivated unless
- * the user switches themes.
- *
- * @since 2.2.0
- */
- public function force_activation() {
- foreach ( $this->plugins as $slug => $plugin ) {
- if ( true === $plugin['force_activation'] ) {
- if ( ! $this->is_plugin_installed( $slug ) ) {
- // Oops, plugin isn't there so iterate to next condition.
- continue;
- } elseif ( $this->can_plugin_activate( $slug ) ) {
- // There we go, activate the plugin.
- activate_plugin( $plugin['file_path'] );
- }
- }
- }
- }
-
- /**
- * Forces plugin deactivation if the parameter 'force_deactivation'
- * is set to true.
- *
- * This allows theme authors to specify certain plugins that must be
- * deactivated upon switching from the current theme to another.
- *
- * Please take special care when using this parameter as it has the
- * potential to be harmful if not used correctly.
- *
- * @since 2.2.0
- */
- public function force_deactivation() {
- foreach ( $this->plugins as $slug => $plugin ) {
- // Only proceed forward if the parameter is set to true and plugin is active.
- if ( true === $plugin['force_deactivation'] && $this->is_plugin_active( $slug ) ) {
- deactivate_plugins( $plugin['file_path'] );
- }
- }
- }
-
- /**
- * Echo the current TGMPA version number to the page.
- */
- public function show_tgmpa_version() {
- echo '<p style="float: right; padding: 0em 1.5em 0.5em 0;"><strong><small>',
- esc_html( sprintf( _x( 'TGMPA v%s', '%s = version number', 'cryout' ), self::TGMPA_VERSION ) ),
- '</small></strong></p>';
- }
-
- /**
- * Returns the singleton instance of the class.
- *
- * @since 2.4.0
- *
- * @return object The TGM_Plugin_Activation object.
- */
- public static function get_instance() {
- if ( ! isset( self::$instance ) && ! ( self::$instance instanceof self ) ) {
- self::$instance = new self();
- }
-
- return self::$instance;
- }
- }
-
- if ( ! function_exists( 'load_tgm_plugin_activation' ) ) {
- /**
- * Ensure only one instance of the class is ever invoked.
- */
- function load_tgm_plugin_activation() {
- $GLOBALS['tgmpa'] = TGM_Plugin_Activation::get_instance();
- }
- }
-
- if ( did_action( 'plugins_loaded' ) ) {
- load_tgm_plugin_activation();
- } else {
- add_action( 'plugins_loaded', 'load_tgm_plugin_activation' );
- }
-}
-
-if ( ! function_exists( 'tgmpa' ) ) {
- /**
- * Helper function to register a collection of required plugins.
- *
- * @since 2.0.0
- * @api
- *
- * @param array $plugins An array of plugin arrays.
- * @param array $config Optional. An array of configuration values.
- */
- function tgmpa( $plugins, $config = array() ) {
- $instance = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) );
-
- foreach ( $plugins as $plugin ) {
- call_user_func( array( $instance, 'register' ), $plugin );
- }
-
- if ( ! empty( $config ) && is_array( $config ) ) {
- // Send out notices for deprecated arguments passed.
- if ( isset( $config['notices'] ) ) {
- _deprecated_argument( __FUNCTION__, '2.2.0', 'The `notices` config parameter was renamed to `has_notices` in TGMPA 2.2.0. Please adjust your configuration.' );
- if ( ! isset( $config['has_notices'] ) ) {
- $config['has_notices'] = $config['notices'];
- }
- }
-
- if ( isset( $config['parent_menu_slug'] ) ) {
- _deprecated_argument( __FUNCTION__, '2.4.0', 'The `parent_menu_slug` config parameter was removed in TGMPA 2.4.0. In TGMPA 2.5.0 an alternative was (re-)introduced. Please adjust your configuration. For more information visit the website: http://tgmpluginactivation.com/configuration/#h-configuration-options.' );
- }
- if ( isset( $config['parent_url_slug'] ) ) {
- _deprecated_argument( __FUNCTION__, '2.4.0', 'The `parent_url_slug` config parameter was removed in TGMPA 2.4.0. In TGMPA 2.5.0 an alternative was (re-)introduced. Please adjust your configuration. For more information visit the website: http://tgmpluginactivation.com/configuration/#h-configuration-options.' );
- }
-
- call_user_func( array( $instance, 'config' ), $config );
- }
- }
-}
-
-/**
- * WP_List_Table isn't always available. If it isn't available,
- * we load it here.
- *
- * @since 2.2.0
- */
-if ( ! class_exists( 'WP_List_Table' ) ) {
- require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
-}
-
-if ( ! class_exists( 'TGMPA_List_Table' ) ) {
-
- /**
- * List table class for handling plugins.
- *
- * Extends the WP_List_Table class to provide a future-compatible
- * way of listing out all required/recommended plugins.
- *
- * Gives users an interface similar to the Plugin Administration
- * area with similar (albeit stripped down) capabilities.
- *
- * This class also allows for the bulk install of plugins.
- *
- * @since 2.2.0
- *
- * @package TGM-Plugin-Activation
- * @author Thomas Griffin
- * @author Gary Jones
- */
- class TGMPA_List_Table extends WP_List_Table {
- /**
- * TGMPA instance.
- *
- * @since 2.5.0
- *
- * @var object
- */
- protected $tgmpa;
-
- /**
- * The currently chosen view.
- *
- * @since 2.5.0
- *
- * @var string One of: 'all', 'install', 'update', 'activate'
- */
- public $view_context = 'all';
-
- /**
- * The plugin counts for the various views.
- *
- * @since 2.5.0
- *
- * @var array
- */
- protected $view_totals = array(
- 'all' => 0,
- 'install' => 0,
- 'update' => 0,
- 'activate' => 0,
- );
-
- /**
- * References parent constructor and sets defaults for class.
- *
- * @since 2.2.0
- */
- public function __construct() {
- $this->tgmpa = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) );
-
- parent::__construct(
- array(
- 'singular' => 'plugin',
- 'plural' => 'plugins',
- 'ajax' => false,
- )
- );
-
- if ( isset( $_REQUEST['plugin_status'] ) && in_array( $_REQUEST['plugin_status'], array( 'install', 'update', 'activate' ), true ) ) {
- $this->view_context = sanitize_key( $_REQUEST['plugin_status'] );
- }
-
- add_filter( 'tgmpa_table_data_items', array( $this, 'sort_table_items' ) );
- }
-
- /**
- * Get a list of CSS classes for the <table> tag.
- *
- * Overruled to prevent the 'plural' argument from being added.
- *
- * @since 2.5.0
- *
- * @return array CSS classnames.
- */
- public function get_table_classes() {
- return array( 'widefat', 'fixed' );
- }
-
- /**
- * Gathers and renames all of our plugin information to be used by WP_List_Table to create our table.
- *
- * @since 2.2.0
- *
- * @return array $table_data Information for use in table.
- */
- protected function _gather_plugin_data() {
- // Load thickbox for plugin links.
- $this->tgmpa->admin_init();
- $this->tgmpa->thickbox();
-
- // Categorize the plugins which have open actions.
- $plugins = $this->categorize_plugins_to_views();
-
- // Set the counts for the view links.
- $this->set_view_totals( $plugins );
-
- // Prep variables for use and grab list of all installed plugins.
- $table_data = array();
- $i = 0;
-
- // Redirect to the 'all' view if no plugins were found for the selected view context.
- if ( empty( $plugins[ $this->view_context ] ) ) {
- $this->view_context = 'all';
- }
-
- foreach ( $plugins[ $this->view_context ] as $slug => $plugin ) {
- $table_data[ $i ]['sanitized_plugin'] = $plugin['name'];
- $table_data[ $i ]['slug'] = $slug;
- $table_data[ $i ]['plugin'] = '<strong>' . $this->tgmpa->get_info_link( $slug ) . '</strong>';
- $table_data[ $i ]['source'] = $this->get_plugin_source_type_text( $plugin['source_type'] );
- $table_data[ $i ]['type'] = $this->get_plugin_advise_type_text( $plugin['required'] );
- $table_data[ $i ]['status'] = $this->get_plugin_status_text( $slug );
- $table_data[ $i ]['installed_version'] = $this->tgmpa->get_installed_version( $slug );
- $table_data[ $i ]['minimum_version'] = $plugin['version'];
- $table_data[ $i ]['available_version'] = $this->tgmpa->does_plugin_have_update( $slug );
-
- // Prep the upgrade notice info.
- $upgrade_notice = $this->tgmpa->get_upgrade_notice( $slug );
- if ( ! empty( $upgrade_notice ) ) {
- $table_data[ $i ]['upgrade_notice'] = $upgrade_notice;
-
- add_action( "tgmpa_after_plugin_row_$slug", array( $this, 'wp_plugin_update_row' ), 10, 2 );
- }
-
- $table_data[ $i ] = apply_filters( 'tgmpa_table_data_item', $table_data[ $i ], $plugin );
-
- $i++;
- }
-
- return $table_data;
- }
-
- /**
- * Categorize the plugins which have open actions into views for the TGMPA page.
- *
- * @since 2.5.0
- */
- protected function categorize_plugins_to_views() {
- $plugins = array(
- 'all' => array(), // Meaning: all plugins which still have open actions.
- 'install' => array(),
- 'update' => array(),
- 'activate' => array(),
- );
-
- foreach ( $this->tgmpa->plugins as $slug => $plugin ) {
- if ( $this->tgmpa->is_plugin_active( $slug ) && false === $this->tgmpa->does_plugin_have_update( $slug ) ) {
- // No need to display plugins if they are installed, up-to-date and active.
- continue;
- } else {
- $plugins['all'][ $slug ] = $plugin;
-
- if ( ! $this->tgmpa->is_plugin_installed( $slug ) ) {
- $plugins['install'][ $slug ] = $plugin;
- } else {
- if ( false !== $this->tgmpa->does_plugin_have_update( $slug ) ) {
- $plugins['update'][ $slug ] = $plugin;
- }
-
- if ( $this->tgmpa->can_plugin_activate( $slug ) ) {
- $plugins['activate'][ $slug ] = $plugin;
- }
- }
- }
- }
-
- return $plugins;
- }
-
- /**
- * Set the counts for the view links.
- *
- * @since 2.5.0
- *
- * @param array $plugins Plugins order by view.
- */
- protected function set_view_totals( $plugins ) {
- foreach ( $plugins as $type => $list ) {
- $this->view_totals[ $type ] = count( $list );
- }
- }
-
- /**
- * Get the plugin required/recommended text string.
- *
- * @since 2.5.0
- *
- * @param string $required Plugin required setting.
- * @return string
- */
- protected function get_plugin_advise_type_text( $required ) {
- if ( true === $required ) {
- return __( 'Required', 'cryout' );
- }
-
- return __( 'Recommended', 'cryout' );
- }
-
- /**
- * Get the plugin source type text string.
- *
- * @since 2.5.0
- *
- * @param string $type Plugin type.
- * @return string
- */
- protected function get_plugin_source_type_text( $type ) {
- $string = '';
-
- switch ( $type ) {
- case 'repo':
- $string = __( 'WordPress Repository', 'cryout' );
- break;
- case 'external':
- $string = __( 'External Source', 'cryout' );
- break;
- case 'bundled':
- $string = __( 'Pre-Packaged', 'cryout' );
- break;
- }
-
- return $string;
- }
-
- /**
- * Determine the plugin status message.
- *
- * @since 2.5.0
- *
- * @param string $slug Plugin slug.
- * @return string
- */
- protected function get_plugin_status_text( $slug ) {
- if ( ! $this->tgmpa->is_plugin_installed( $slug ) ) {
- return __( 'Not Installed', 'cryout' );
- }
-
- if ( ! $this->tgmpa->is_plugin_active( $slug ) ) {
- $install_status = __( 'Installed But Not Activated', 'cryout' );
- } else {
- $install_status = __( 'Active', 'cryout' );
- }
-
- $update_status = '';
-
- if ( $this->tgmpa->does_plugin_require_update( $slug ) && false === $this->tgmpa->does_plugin_have_update( $slug ) ) {
- $update_status = __( 'Required Update not Available', 'cryout' );
-
- } elseif ( $this->tgmpa->does_plugin_require_update( $slug ) ) {
- $update_status = __( 'Requires Update', 'cryout' );
-
- } elseif ( false !== $this->tgmpa->does_plugin_have_update( $slug ) ) {
- $update_status = __( 'Update recommended', 'cryout' );
- }
-
- if ( '' === $update_status ) {
- return $install_status;
- }
-
- return sprintf(
- _x( '%1$s, %2$s', '%1$s = install status, %2$s = update status', 'cryout' ),
- $install_status,
- $update_status
- );
- }
-
- /**
- * Sort plugins by Required/Recommended type and by alphabetical plugin name within each type.
- *
- * @since 2.5.0
- *
- * @param array $items Prepared table items.
- * @return array Sorted table items.
- */
- public function sort_table_items( $items ) {
- $type = array();
- $name = array();
-
- foreach ( $items as $i => $plugin ) {
- $type[ $i ] = $plugin['type']; // Required / recommended.
- $name[ $i ] = $plugin['sanitized_plugin'];
- }
-
- array_multisort( $type, SORT_DESC, $name, SORT_ASC, $items );
-
- return $items;
- }
-
- /**
- * Get an associative array ( id => link ) of the views available on this table.
- *
- * @since 2.5.0
- *
- * @return array
- */
- public function get_views() {
- $status_links = array();
-
- foreach ( $this->view_totals as $type => $count ) {
- if ( $count < 1 ) {
- continue;
- }
-
- switch ( $type ) {
- case 'all':
- $text = _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $count, 'plugins', 'cryout' );
- break;
- case 'install':
- $text = _n( 'To Install <span class="count">(%s)</span>', 'To Install <span class="count">(%s)</span>', $count, 'cryout' );
- break;
- case 'update':
- $text = _n( 'Update Available <span class="count">(%s)</span>', 'Update Available <span class="count">(%s)</span>', $count, 'cryout' );
- break;
- case 'activate':
- $text = _n( 'To Activate <span class="count">(%s)</span>', 'To Activate <span class="count">(%s)</span>', $count, 'cryout' );
- break;
- default:
- $text = '';
- break;
- }
-
- if ( ! empty( $text ) ) {
-
- $status_links[ $type ] = sprintf(
- '<a href="%s"%s>%s</a>',
- esc_url( $this->tgmpa->get_tgmpa_status_url( $type ) ),
- ( $type === $this->view_context ) ? ' class="current"' : '',
- sprintf( $text, number_format_i18n( $count ) )
- );
- }
- }
-
- return $status_links;
- }
-
- /**
- * Create default columns to display important plugin information
- * like type, action and status.
- *
- * @since 2.2.0
- *
- * @param array $item Array of item data.
- * @param string $column_name The name of the column.
- * @return string
- */
- public function column_default( $item, $column_name ) {
- return $item[ $column_name ];
- }
-
- /**
- * Required for bulk installing.
- *
- * Adds a checkbox for each plugin.
- *
- * @since 2.2.0
- *
- * @param array $item Array of item data.
- * @return string The input checkbox with all necessary info.
- */
- public function column_cb( $item ) {
- return sprintf(
- '<input type="checkbox" name="%1$s[]" value="%2$s" id="%3$s" />',
- esc_attr( $this->_args['singular'] ),
- esc_attr( $item['slug'] ),
- esc_attr( $item['sanitized_plugin'] )
- );
- }
-
- /**
- * Create default title column along with the action links.
- *
- * @since 2.2.0
- *
- * @param array $item Array of item data.
- * @return string The plugin name and action links.
- */
- public function column_plugin( $item ) {
- return sprintf(
- '%1$s %2$s',
- $item['plugin'],
- $this->row_actions( $this->get_row_actions( $item ), true )
- );
- }
-
- /**
- * Create version information column.
- *
- * @since 2.5.0
- *
- * @param array $item Array of item data.
- * @return string HTML-formatted version information.
- */
- public function column_version( $item ) {
- $output = array();
-
- if ( $this->tgmpa->is_plugin_installed( $item['slug'] ) ) {
- $installed = ! empty( $item['installed_version'] ) ? $item['installed_version'] : _x( 'unknown', 'as in: "version nr unknown"', 'cryout' );
-
- $color = '';
- if ( ! empty( $item['minimum_version'] ) && $this->tgmpa->does_plugin_require_update( $item['slug'] ) ) {
- $color = ' color: #ff0000; font-weight: bold;';
- }
-
- $output[] = sprintf(
- '<p><span style="min-width: 32px; text-align: right; float: right;%1$s">%2$s</span>' . __( 'Installed version:', 'cryout' ) . '</p>',
- $color,
- $installed
- );
- }
-
- if ( ! empty( $item['minimum_version'] ) ) {
- $output[] = sprintf(
- '<p><span style="min-width: 32px; text-align: right; float: right;">%1$s</span>' . __( 'Minimum required version:', 'cryout' ) . '</p>',
- $item['minimum_version']
- );
- }
-
- if ( ! empty( $item['available_version'] ) ) {
- $color = '';
- if ( ! empty( $item['minimum_version'] ) && version_compare( $item['available_version'], $item['minimum_version'], '>=' ) ) {
- $color = ' color: #71C671; font-weight: bold;';
- }
-
- $output[] = sprintf(
- '<p><span style="min-width: 32px; text-align: right; float: right;%1$s">%2$s</span>' . __( 'Available version:', 'cryout' ) . '</p>',
- $color,
- $item['available_version']
- );
- }
-
- if ( empty( $output ) ) {
- return '&nbsp;'; // Let's not break the table layout.
- } else {
- return implode( "\n", $output );
- }
- }
-
- /**
- * Sets default message within the plugins table if no plugins
- * are left for interaction.
- *
- * Hides the menu item to prevent the user from clicking and
- * getting a permissions error.
- *
- * @since 2.2.0
- */
- public function no_items() {
- printf( wp_kses_post( __( 'No plugins to install, update or activate. <a href="%1$s">Return to the Dashboard</a>', 'cryout' ) ), esc_url( self_admin_url() ) );
- echo '<style type="text/css">#adminmenu .wp-submenu li.current { display: none !important; }</style>';
- }
-
- /**
- * Output all the column information within the table.
- *
- * @since 2.2.0
- *
- * @return array $columns The column names.
- */
- public function get_columns() {
- $columns = array(
- 'cb' => '<input type="checkbox" />',
- 'plugin' => __( 'Plugin', 'cryout' ),
- 'source' => __( 'Source', 'cryout' ),
- 'type' => __( 'Type', 'cryout' ),
- );
-
- if ( 'all' === $this->view_context || 'update' === $this->view_context ) {
- $columns['version'] = __( 'Version', 'cryout' );
- $columns['status'] = __( 'Status', 'cryout' );
- }
-
- return apply_filters( 'tgmpa_table_columns', $columns );
- }
-
- /**
- * Get name of default primary column
- *
- * @since 2.5.0 / WP 4.3+ compatibility
- * @access protected
- *
- * @return string
- */
- protected function get_default_primary_column_name() {
- return 'plugin';
- }
-
- /**
- * Get the name of the primary column.
- *
- * @since 2.5.0 / WP 4.3+ compatibility
- * @access protected
- *
- * @return string The name of the primary column.
- */
- protected function get_primary_column_name() {
- if ( method_exists( 'WP_List_Table', 'get_primary_column_name' ) ) {
- return parent::get_primary_column_name();
- } else {
- return $this->get_default_primary_column_name();
- }
- }
-
- /**
- * Get the actions which are relevant for a specific plugin row.
- *
- * @since 2.5.0
- *
- * @param array $item Array of item data.
- * @return array Array with relevant action links.
- */
- protected function get_row_actions( $item ) {
- $actions = array();
- $action_links = array();
-
- // Display the 'Install' action link if the plugin is not yet available.
- if ( ! $this->tgmpa->is_plugin_installed( $item['slug'] ) ) {
- $actions['install'] = _x( 'Install %2$s', '%2$s = plugin name in screen reader markup', 'cryout' );
- } else {
- // Display the 'Update' action link if an update is available and WP complies with plugin minimum.
- if ( false !== $this->tgmpa->does_plugin_have_update( $item['slug'] ) && $this->tgmpa->can_plugin_update( $item['slug'] ) ) {
- $actions['update'] = _x( 'Update %2$s', '%2$s = plugin name in screen reader markup', 'cryout' );
- }
-
- // Display the 'Activate' action link, but only if the plugin meets the minimum version.
- if ( $this->tgmpa->can_plugin_activate( $item['slug'] ) ) {
- $actions['activate'] = _x( 'Activate %2$s', '%2$s = plugin name in screen reader markup', 'cryout' );
- }
- }
-
- // Create the actual links.
- foreach ( $actions as $action => $text ) {
- $nonce_url = wp_nonce_url(
- add_query_arg(
- array(
- 'plugin' => urlencode( $item['slug'] ),
- 'tgmpa-' . $action => $action . '-plugin',
- ),
- $this->tgmpa->get_tgmpa_url()
- ),
- 'tgmpa-' . $action,
- 'tgmpa-nonce'
- );
-
- $action_links[ $action ] = sprintf(
- '<a href="%1$s">' . esc_html( $text ) . '</a>',
- esc_url( $nonce_url ),
- '<span class="screen-reader-text">' . esc_html( $item['sanitized_plugin'] ) . '</span>'
- );
- }
-
- $prefix = ( defined( 'WP_NETWORK_ADMIN' ) && WP_NETWORK_ADMIN ) ? 'network_admin_' : '';
- return apply_filters( "tgmpa_{$prefix}plugin_action_links", array_filter( $action_links ), $item['slug'], $item, $this->view_context );
- }
-
- /**
- * Generates content for a single row of the table.
- *
- * @since 2.5.0
- *
- * @param object $item The current item.
- */
- public function single_row( $item ) {
- parent::single_row( $item );
-
- /**
- * Fires after each specific row in the TGMPA Plugins list table.
- *
- * The dynamic portion of the hook name, `$item['slug']`, refers to the slug
- * for the plugin.
- *
- * @since 2.5.0
- */
- do_action( "tgmpa_after_plugin_row_{$item['slug']}", $item['slug'], $item, $this->view_context );
- }
-
- /**
- * Show the upgrade notice below a plugin row if there is one.
- *
- * @since 2.5.0
- *
- * @see /wp-admin/includes/update.php
- *
- * @param string $slug Plugin slug.
- * @param array $item The information available in this table row.
- * @return null Return early if upgrade notice is empty.
- */
- public function wp_plugin_update_row( $slug, $item ) {
- if ( empty( $item['upgrade_notice'] ) ) {
- return;
- }
-
- echo '
- <tr class="plugin-update-tr">
- <td colspan="', absint( $this->get_column_count() ), '" class="plugin-update colspanchange">
- <div class="update-message">',
- esc_html__( 'Upgrade message from the plugin author:', 'cryout' ),
- ' <strong>', wp_kses_data( $item['upgrade_notice'] ), '</strong>
- </div>
- </td>
- </tr>';
- }
-
- /**
- * Extra controls to be displayed between bulk actions and pagination.
- *
- * @since 2.5.0
- *
- * @param string $which 'top' or 'bottom' table navigation.
- */
- public function extra_tablenav( $which ) {
- if ( 'bottom' === $which ) {
- $this->tgmpa->show_tgmpa_version();
- }
- }
-
- /**
- * Defines the bulk actions for handling registered plugins.
- *
- * @since 2.2.0
- *
- * @return array $actions The bulk actions for the plugin install table.
- */
- public function get_bulk_actions() {
-
- $actions = array();
-
- if ( 'update' !== $this->view_context && 'activate' !== $this->view_context ) {
- if ( current_user_can( 'install_plugins' ) ) {
- $actions['tgmpa-bulk-install'] = __( 'Install', 'cryout' );
- }
- }
-
- if ( 'install' !== $this->view_context ) {
- if ( current_user_can( 'update_plugins' ) ) {
- $actions['tgmpa-bulk-update'] = __( 'Update', 'cryout' );
- }
- if ( current_user_can( 'activate_plugins' ) ) {
- $actions['tgmpa-bulk-activate'] = __( 'Activate', 'cryout' );
- }
- }
-
- return $actions;
- }
-
- /**
- * Processes bulk installation and activation actions.
- *
- * The bulk installation process looks for the $_POST information and passes that
- * through if a user has to use WP_Filesystem to enter their credentials.
- *
- * @since 2.2.0
- */
- public function process_bulk_actions() {
- // Bulk installation process.
- if ( 'tgmpa-bulk-install' === $this->current_action() || 'tgmpa-bulk-update' === $this->current_action() ) {
-
- check_admin_referer( 'bulk-' . $this->_args['plural'] );
-
- $install_type = 'install';
- if ( 'tgmpa-bulk-update' === $this->current_action() ) {
- $install_type = 'update';
- }
-
- $plugins_to_install = array();
-
- // Did user actually select any plugins to install/update ?
- if ( empty( $_POST['plugin'] ) ) {
- if ( 'install' === $install_type ) {
- $message = __( 'No plugins were selected to be installed. No action taken.', 'cryout' );
- } else {
- $message = __( 'No plugins were selected to be updated. No action taken.', 'cryout' );
- }
-
- echo '<div id="message" class="error"><p>', esc_html( $message ), '</p></div>';
-
- return false;
- }
-
- if ( is_array( $_POST['plugin'] ) ) {
- $plugins_to_install = (array) $_POST['plugin'];
- } elseif ( is_string( $_POST['plugin'] ) ) {
- // Received via Filesystem page - un-flatten array (WP bug #19643).
- $plugins_to_install = explode( ',', $_POST['plugin'] );
- }
-
- // Sanitize the received input.
- $plugins_to_install = array_map( 'urldecode', $plugins_to_install );
- $plugins_to_install = array_map( array( $this->tgmpa, 'sanitize_key' ), $plugins_to_install );
-
- // Validate the received input.
- foreach ( $plugins_to_install as $key => $slug ) {
- // Check if the plugin was registered with TGMPA and remove if not.
- if ( ! isset( $this->tgmpa->plugins[ $slug ] ) ) {
- unset( $plugins_to_install[ $key ] );
- continue;
- }
-
- // For updates: make sure this is a plugin we *can* update (update available and WP version ok).
- if ( 'update' === $install_type && ( $this->tgmpa->is_plugin_installed( $slug ) && ( false === $this->tgmpa->does_plugin_have_update( $slug ) || ! $this->tgmpa->can_plugin_update( $slug ) ) ) ) {
- unset( $plugins_to_install[ $key ] );
- }
- }
-
- // No need to proceed further if we have no plugins to handle.
- if ( empty( $plugins_to_install ) ) {
- if ( 'install' === $install_type ) {
- $message = __( 'No plugins are available to be installed at this time.', 'cryout' );
- } else {
- $message = __( 'No plugins are available to be updated at this time.', 'cryout' );
- }
-
- echo '<div id="message" class="error"><p>', esc_html( $message ), '</p></div>';
-
- return false;
- }
-
- // Pass all necessary information if WP_Filesystem is needed.
- $url = wp_nonce_url(
- $this->tgmpa->get_tgmpa_url(),
- 'bulk-' . $this->_args['plural']
- );
-
- // Give validated data back to $_POST which is the only place the filesystem looks for extra fields.
- $_POST['plugin'] = implode( ',', $plugins_to_install ); // Work around for WP bug #19643.
-
- $method = ''; // Leave blank so WP_Filesystem can populate it as necessary.
- $fields = array_keys( $_POST ); // Extra fields to pass to WP_Filesystem.
-
- if ( false === ( $creds = request_filesystem_credentials( esc_url_raw( $url ), $method, false, false, $fields ) ) ) {
- return true; // Stop the normal page form from displaying, credential request form will be shown.
- }
-
- // Now we have some credentials, setup WP_Filesystem.
- if ( ! WP_Filesystem( $creds ) ) {
- // Our credentials were no good, ask the user for them again.
- request_filesystem_credentials( esc_url_raw( $url ), $method, true, false, $fields );
-
- return true;
- }
-
- /* If we arrive here, we have the filesystem */
-
- // Store all information in arrays since we are processing a bulk installation.
- $names = array();
- $sources = array(); // Needed for installs.
- $file_paths = array(); // Needed for upgrades.
- $to_inject = array(); // Information to inject into the update_plugins transient.
-
- // Prepare the data for validated plugins for the install/upgrade.
- foreach ( $plugins_to_install as $slug ) {
- $name = $this->tgmpa->plugins[ $slug ]['name'];
- $source = $this->tgmpa->get_download_url( $slug );
-
- if ( ! empty( $name ) && ! empty( $source ) ) {
- $names[] = $name;
-
- switch ( $install_type ) {
-
- case 'install':
- $sources[] = $source;
- break;
-
- case 'update':
- $file_paths[] = $this->tgmpa->plugins[ $slug ]['file_path'];
- $to_inject[ $slug ] = $this->tgmpa->plugins[ $slug ];
- $to_inject[ $slug ]['source'] = $source;
- break;
- }
- }
- }
- unset( $slug, $name, $source );
-
- // Create a new instance of TGMPA_Bulk_Installer.
- $installer = new TGMPA_Bulk_Installer(
- new TGMPA_Bulk_Installer_Skin(
- array(
- 'url' => esc_url_raw( $this->tgmpa->get_tgmpa_url() ),
- 'nonce' => 'bulk-' . $this->_args['plural'],
- 'names' => $names,
- 'install_type' => $install_type,
- )
- )
- );
-
- // Wrap the install process with the appropriate HTML.
- echo '<div class="tgmpa wrap">',
- '<h2>', esc_html( get_admin_page_title() ), '</h2>';
-
- // Process the bulk installation submissions.
- add_filter( 'upgrader_source_selection', array( $this->tgmpa, 'maybe_adjust_source_dir' ), 1, 3 );
-
- if ( 'tgmpa-bulk-update' === $this->current_action() ) {
- // Inject our info into the update transient.
- $this->tgmpa->inject_update_info( $to_inject );
-
- $installer->bulk_upgrade( $file_paths );
- } else {
- $installer->bulk_install( $sources );
- }
-
- remove_filter( 'upgrader_source_selection', array( $this->tgmpa, 'maybe_adjust_source_dir' ), 1, 3 );
-
- echo '</div>';
-
- return true;
- }
-
- // Bulk activation process.
- if ( 'tgmpa-bulk-activate' === $this->current_action() ) {
- check_admin_referer( 'bulk-' . $this->_args['plural'] );
-
- // Did user actually select any plugins to activate ?
- if ( empty( $_POST['plugin'] ) ) {
- echo '<div id="message" class="error"><p>', esc_html__( 'No plugins were selected to be activated. No action taken.', 'cryout' ), '</p></div>';
-
- return false;
- }
-
- // Grab plugin data from $_POST.
- $plugins = array();
- if ( isset( $_POST['plugin'] ) ) {
- $plugins = array_map( 'urldecode', (array) $_POST['plugin'] );
- $plugins = array_map( array( $this->tgmpa, 'sanitize_key' ), $plugins );
- }
-
- $plugins_to_activate = array();
- $plugin_names = array();
-
- // Grab the file paths for the selected & inactive plugins from the registration array.
- foreach ( $plugins as $slug ) {
- if ( $this->tgmpa->can_plugin_activate( $slug ) ) {
- $plugins_to_activate[] = $this->tgmpa->plugins[ $slug ]['file_path'];
- $plugin_names[] = $this->tgmpa->plugins[ $slug ]['name'];
- }
- }
- unset( $slug );
-
- // Return early if there are no plugins to activate.
- if ( empty( $plugins_to_activate ) ) {
- echo '<div id="message" class="error"><p>', esc_html__( 'No plugins are available to be activated at this time.', 'cryout' ), '</p></div>';
-
- return false;
- }
-
- // Now we are good to go - let's start activating plugins.
- $activate = activate_plugins( $plugins_to_activate );
-
- if ( is_wp_error( $activate ) ) {
- echo '<div id="message" class="error"><p>', wp_kses_post( $activate->get_error_message() ), '</p></div>';
- } else {
- $count = count( $plugin_names ); // Count so we can use _n function.
- $plugin_names = array_map( array( 'TGMPA_Utils', 'wrap_in_strong' ), $plugin_names );
- $last_plugin = array_pop( $plugin_names ); // Pop off last name to prep for readability.
- $imploded = empty( $plugin_names ) ? $last_plugin : ( implode( ', ', $plugin_names ) . ' ' . esc_html_x( 'and', 'plugin A *and* plugin B', 'cryout' ) . ' ' . $last_plugin );
-
- printf( // WPCS: xss ok.
- '<div id="message" class="updated"><p>%1$s %2$s.</p></div>',
- esc_html( _n( 'The following plugin was activated successfully:', 'The following plugins were activated successfully:', $count, 'cryout' ) ),
- $imploded
- );
-
- // Update recently activated plugins option.
- $recent = (array) get_option( 'recently_activated' );
- foreach ( $plugins_to_activate as $plugin => $time ) {
- if ( isset( $recent[ $plugin ] ) ) {
- unset( $recent[ $plugin ] );
- }
- }
- update_option( 'recently_activated', $recent );
- }
-
- unset( $_POST ); // Reset the $_POST variable in case user wants to perform one action after another.
-
- return true;
- }
-
- return false;
- }
-
- /**
- * Prepares all of our information to be outputted into a usable table.
- *
- * @since 2.2.0
- */
- public function prepare_items() {
- $columns = $this->get_columns(); // Get all necessary column information.
- $hidden = array(); // No columns to hide, but we must set as an array.
- $sortable = array(); // No reason to make sortable columns.
- $primary = $this->get_primary_column_name(); // Column which has the row actions.
- $this->_column_headers = array( $columns, $hidden, $sortable, $primary ); // Get all necessary column headers.
-
- // Process our bulk activations here.
- if ( 'tgmpa-bulk-activate' === $this->current_action() ) {
- $this->process_bulk_actions();
- }
-
- // Store all of our plugin data into $items array so WP_List_Table can use it.
- $this->items = apply_filters( 'tgmpa_table_data_items', $this->_gather_plugin_data() );
- }
-
- /* *********** DEPRECATED METHODS *********** */
-
- /**
- * Retrieve plugin data, given the plugin name.
- *
- * @since 2.2.0
- * @deprecated 2.5.0 use {@see TGM_Plugin_Activation::_get_plugin_data_from_name()} instead.
- * @see TGM_Plugin_Activation::_get_plugin_data_from_name()
- *
- * @param string $name Name of the plugin, as it was registered.
- * @param string $data Optional. Array key of plugin data to return. Default is slug.
- * @return string|boolean Plugin slug if found, false otherwise.
- */
- protected function _get_plugin_data_from_name( $name, $data = 'slug' ) {
- _deprecated_function( __FUNCTION__, 'TGMPA 2.5.0', 'TGM_Plugin_Activation::_get_plugin_data_from_name()' );
-
- return $this->tgmpa->_get_plugin_data_from_name( $name, $data );
- }
- }
-}
-
-
-if ( ! class_exists( 'TGM_Bulk_Installer' ) ) {
-
- /**
- * Hack: Prevent TGMPA v2.4.1- bulk installer class from being loaded if 2.4.1- is loaded after 2.5+.
- */
- class TGM_Bulk_Installer {
- }
-}
-if ( ! class_exists( 'TGM_Bulk_Installer_Skin' ) ) {
-
- /**
- * Hack: Prevent TGMPA v2.4.1- bulk installer skin class from being loaded if 2.4.1- is loaded after 2.5+.
- */
- class TGM_Bulk_Installer_Skin {
- }
-}
-
-/**
- * The WP_Upgrader file isn't always available. If it isn't available,
- * we load it here.
- *
- * We check to make sure no action or activation keys are set so that WordPress
- * does not try to re-include the class when processing upgrades or installs outside
- * of the class.
- *
- * @since 2.2.0
- */
-add_action( 'admin_init', 'tgmpa_load_bulk_installer' );
-if ( ! function_exists( 'tgmpa_load_bulk_installer' ) ) {
- /**
- * Load bulk installer
- */
- function tgmpa_load_bulk_installer() {
- // Silently fail if 2.5+ is loaded *after* an older version.
- if ( ! isset( $GLOBALS['tgmpa'] ) ) {
- return;
- }
-
- // Get TGMPA class instance.
- $tgmpa_instance = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) );
-
- if ( isset( $_GET['page'] ) && $tgmpa_instance->menu === $_GET['page'] ) {
- if ( ! class_exists( 'Plugin_Upgrader', false ) ) {
- require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
- }
-
- if ( ! class_exists( 'TGMPA_Bulk_Installer' ) ) {
-
- /**
- * Installer class to handle bulk plugin installations.
- *
- * Extends WP_Upgrader and customizes to suit the installation of multiple
- * plugins.
- *
- * @since 2.2.0
- *
- * @internal Since 2.5.0 the class is an extension of Plugin_Upgrader rather than WP_Upgrader
- * @internal Since 2.5.2 the class has been renamed from TGM_Bulk_Installer to TGMPA_Bulk_Installer.
- * This was done to prevent backward compatibility issues with v2.3.6.
- *
- * @package TGM-Plugin-Activation
- * @author Thomas Griffin
- * @author Gary Jones
- */
- class TGMPA_Bulk_Installer extends Plugin_Upgrader {
- /**
- * Holds result of bulk plugin installation.
- *
- * @since 2.2.0
- *
- * @var string
- */
- public $result;
-
- /**
- * Flag to check if bulk installation is occurring or not.
- *
- * @since 2.2.0
- *
- * @var boolean
- */
- public $bulk = false;
-
- /**
- * TGMPA instance
- *
- * @since 2.5.0
- *
- * @var object
- */
- protected $tgmpa;
-
- /**
- * Whether or not the destination directory needs to be cleared ( = on update).
- *
- * @since 2.5.0
- *
- * @var bool
- */
- protected $clear_destination = false;
-
- /**
- * References parent constructor and sets defaults for class.
- *
- * @since 2.2.0
- *
- * @param \Bulk_Upgrader_Skin|null $skin Installer skin.
- */
- public function __construct( $skin = null ) {
- // Get TGMPA class instance.
- $this->tgmpa = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) );
-
- parent::__construct( $skin );
-
- if ( isset( $this->skin->options['install_type'] ) && 'update' === $this->skin->options['install_type'] ) {
- $this->clear_destination = true;
- }
-
- if ( $this->tgmpa->is_automatic ) {
- $this->activate_strings();
- }
-
- add_action( 'upgrader_process_complete', array( $this->tgmpa, 'populate_file_path' ) );
- }
-
- /**
- * Sets the correct activation strings for the installer skin to use.
- *
- * @since 2.2.0
- */
- public function activate_strings() {
- $this->strings['activation_failed'] = __( 'Plugin activation failed.', 'cryout' );
- $this->strings['activation_success'] = __( 'Plugin activated successfully.', 'cryout' );
- }
-
- /**
- * Performs the actual installation of each plugin.
- *
- * @since 2.2.0
- *
- * @see WP_Upgrader::run()
- *
- * @param array $options The installation config options.
- * @return null|array Return early if error, array of installation data on success.
- */
- public function run( $options ) {
- $result = parent::run( $options );
-
- // Reset the strings in case we changed one during automatic activation.
- if ( $this->tgmpa->is_automatic ) {
- if ( 'update' === $this->skin->options['install_type'] ) {
- $this->upgrade_strings();
- } else {
- $this->install_strings();
- }
- }
-
- return $result;
- }
-
- /**
- * Processes the bulk installation of plugins.
- *
- * @since 2.2.0
- *
- * @internal This is basically a near identical copy of the WP Core Plugin_Upgrader::bulk_upgrade()
- * method, with minor adjustments to deal with new installs instead of upgrades.
- * For ease of future synchronizations, the adjustments are clearly commented, but no other
- * comments are added. Code style has been made to comply.
- *
- * @see Plugin_Upgrader::bulk_upgrade()
- * @see https://core.trac.wordpress.org/browser/tags/4.2.1/src/wp-admin/includes/class-wp-upgrader.php#L838
- *
- * @param array $plugins The plugin sources needed for installation.
- * @param array $args Arbitrary passed extra arguments.
- * @return string|bool Install confirmation messages on success, false on failure.
- */
- public function bulk_install( $plugins, $args = array() ) {
- // [TGMPA + ] Hook auto-activation in.
- add_filter( 'upgrader_post_install', array( $this, 'auto_activate' ), 10 );
-
- $defaults = array(
- 'clear_update_cache' => true,
- );
- $parsed_args = wp_parse_args( $args, $defaults );
-
- $this->init();
- $this->bulk = true;
-
- $this->install_strings(); // [TGMPA + ] adjusted.
-
- /* [TGMPA - ] $current = get_site_transient( 'update_plugins' ); */
-
- /* [TGMPA - ] add_filter('upgrader_clear_destination', array($this, 'delete_old_plugin'), 10, 4); */
-
- $this->skin->header();
-
- // Connect to the Filesystem first.
- $res = $this->fs_connect( array( WP_CONTENT_DIR, WP_PLUGIN_DIR ) );
- if ( ! $res ) {
- $this->skin->footer();
-
- return false;
- }
-
- $this->skin->bulk_header();
-
- // Only start maintenance mode if:
- // - running Multisite and there are one or more plugins specified, OR
- // - a plugin with an update available is currently active.
- // @TODO: For multisite, maintenance mode should only kick in for individual sites if at all possible.
- $maintenance = ( is_multisite() && ! empty( $plugins ) );
-
- /*
- [TGMPA - ]
- foreach ( $plugins as $plugin )
- $maintenance = $maintenance || ( is_plugin_active( $plugin ) && isset( $current->response[ $plugin] ) );
- */
- if ( $maintenance ) {
- $this->maintenance_mode( true );
- }
-
- $results = array();
-
- $this->update_count = count( $plugins );
- $this->update_current = 0;
- foreach ( $plugins as $plugin ) {
- $this->update_current++;
-
- /*
- [TGMPA - ]
- $this->skin->plugin_info = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin, false, true);
-
- if ( !isset( $current->response[ $plugin ] ) ) {
- $this->skin->set_result('up_to_date');
- $this->skin->before();
- $this->skin->feedback('up_to_date');
- $this->skin->after();
- $results[$plugin] = true;
- continue;
- }
-
- // Get the URL to the zip file
- $r = $current->response[ $plugin ];
-
- $this->skin->plugin_active = is_plugin_active($plugin);
- */
-
- $result = $this->run( array(
- 'package' => $plugin, // [TGMPA + ] adjusted.
- 'destination' => WP_PLUGIN_DIR,
- 'clear_destination' => false, // [TGMPA + ] adjusted.
- 'clear_working' => true,
- 'is_multi' => true,
- 'hook_extra' => array(
- 'plugin' => $plugin,
- ),
- ) );
-
- $results[ $plugin ] = $this->result;
-
- // Prevent credentials auth screen from displaying multiple times.
- if ( false === $result ) {
- break;
- }
- } //end foreach $plugins
-
- $this->maintenance_mode( false );
-
- /**
- * Fires when the bulk upgrader process is complete.
- *
- * @since WP 3.6.0 / TGMPA 2.5.0
- *
- * @param Plugin_Upgrader $this Plugin_Upgrader instance. In other contexts, $this, might
- * be a Theme_Upgrader or Core_Upgrade instance.
- * @param array $data {
- * Array of bulk item update data.
- *
- * @type string $action Type of action. Default 'update'.
- * @type string $type Type of update process. Accepts 'plugin', 'theme', or 'core'.
- * @type bool $bulk Whether the update process is a bulk update. Default true.
- * @type array $packages Array of plugin, theme, or core packages to update.
- * }
- */
- do_action( 'upgrader_process_complete', $this, array(
- 'action' => 'install', // [TGMPA + ] adjusted.
- 'type' => 'plugin',
- 'bulk' => true,
- 'plugins' => $plugins,
- ) );
-
- $this->skin->bulk_footer();
-
- $this->skin->footer();
-
- // Cleanup our hooks, in case something else does a upgrade on this connection.
- /* [TGMPA - ] remove_filter('upgrader_clear_destination', array($this, 'delete_old_plugin')); */
-
- // [TGMPA + ] Remove our auto-activation hook.
- remove_filter( 'upgrader_post_install', array( $this, 'auto_activate' ), 10 );
-
- // Force refresh of plugin update information.
- wp_clean_plugins_cache( $parsed_args['clear_update_cache'] );
-
- return $results;
- }
-
- /**
- * Handle a bulk upgrade request.
- *
- * @since 2.5.0
- *
- * @see Plugin_Upgrader::bulk_upgrade()
- *
- * @param array $plugins The local WP file_path's of the plugins which should be upgraded.
- * @param array $args Arbitrary passed extra arguments.
- * @return string|bool Install confirmation messages on success, false on failure.
- */
- public function bulk_upgrade( $plugins, $args = array() ) {
-
- add_filter( 'upgrader_post_install', array( $this, 'auto_activate' ), 10 );
-
- $result = parent::bulk_upgrade( $plugins, $args );
-
- remove_filter( 'upgrader_post_install', array( $this, 'auto_activate' ), 10 );
-
- return $result;
- }
-
- /**
- * Abuse a filter to auto-activate plugins after installation.
- *
- * Hooked into the 'upgrader_post_install' filter hook.
- *
- * @since 2.5.0
- *
- * @param bool $bool The value we need to give back (true).
- * @return bool
- */
- public function auto_activate( $bool ) {
- // Only process the activation of installed plugins if the automatic flag is set to true.
- if ( $this->tgmpa->is_automatic ) {
- // Flush plugins cache so the headers of the newly installed plugins will be read correctly.
- wp_clean_plugins_cache();
-
- // Get the installed plugin file.
- $plugin_info = $this->plugin_info();
-
- // Don't try to activate on upgrade of active plugin as WP will do this already.
- if ( ! is_plugin_active( $plugin_info ) ) {
- $activate = activate_plugin( $plugin_info );
-
- // Adjust the success string based on the activation result.
- $this->strings['process_success'] = $this->strings['process_success'] . "<br />\n";
-
- if ( is_wp_error( $activate ) ) {
- $this->skin->error( $activate );
- $this->strings['process_success'] .= $this->strings['activation_failed'];
- } else {
- $this->strings['process_success'] .= $this->strings['activation_success'];
- }
- }
- }
-
- return $bool;
- }
- }
- }
-
- if ( ! class_exists( 'TGMPA_Bulk_Installer_Skin' ) ) {
-
- /**
- * Installer skin to set strings for the bulk plugin installations..
- *
- * Extends Bulk_Upgrader_Skin and customizes to suit the installation of multiple
- * plugins.
- *
- * @since 2.2.0
- *
- * @internal Since 2.5.2 the class has been renamed from TGM_Bulk_Installer_Skin to
- * TGMPA_Bulk_Installer_Skin.
- * This was done to prevent backward compatibility issues with v2.3.6.
- *
- * @see https://core.trac.wordpress.org/browser/trunk/src/wp-admin/includes/class-wp-upgrader-skins.php
- *
- * @package TGM-Plugin-Activation
- * @author Thomas Griffin
- * @author Gary Jones
- */
- class TGMPA_Bulk_Installer_Skin extends Bulk_Upgrader_Skin {
- /**
- * Holds plugin info for each individual plugin installation.
- *
- * @since 2.2.0
- *
- * @var array
- */
- public $plugin_info = array();
-
- /**
- * Holds names of plugins that are undergoing bulk installations.
- *
- * @since 2.2.0
- *
- * @var array
- */
- public $plugin_names = array();
-
- /**
- * Integer to use for iteration through each plugin installation.
- *
- * @since 2.2.0
- *
- * @var integer
- */
- public $i = 0;
-
- /**
- * TGMPA instance
- *
- * @since 2.5.0
- *
- * @var object
- */
- protected $tgmpa;
-
- /**
- * Constructor. Parses default args with new ones and extracts them for use.
- *
- * @since 2.2.0
- *
- * @param array $args Arguments to pass for use within the class.
- */
- public function __construct( $args = array() ) {
- // Get TGMPA class instance.
- $this->tgmpa = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) );
-
- // Parse default and new args.
- $defaults = array(
- 'url' => '',
- 'nonce' => '',
- 'names' => array(),
- 'install_type' => 'install',
- );
- $args = wp_parse_args( $args, $defaults );
-
- // Set plugin names to $this->plugin_names property.
- $this->plugin_names = $args['names'];
-
- // Extract the new args.
- parent::__construct( $args );
- }
-
- /**
- * Sets install skin strings for each individual plugin.
- *
- * Checks to see if the automatic activation flag is set and uses the
- * the proper strings accordingly.
- *
- * @since 2.2.0
- */
- public function add_strings() {
- if ( 'update' === $this->options['install_type'] ) {
- parent::add_strings();
- $this->upgrader->strings['skin_before_update_header'] = __( 'Updating Plugin %1$s (%2$d/%3$d)', 'cryout' );
- } else {
- $this->upgrader->strings['skin_update_failed_error'] = __( 'An error occurred while installing %1$s: <strong>%2$s</strong>.', 'cryout' );
- $this->upgrader->strings['skin_update_failed'] = __( 'The installation of %1$s failed.', 'cryout' );
-
- if ( $this->tgmpa->is_automatic ) {
- // Automatic activation strings.
- $this->upgrader->strings['skin_upgrade_start'] = __( 'The installation and activation process is starting. This process may take a while on some hosts, so please be patient.', 'cryout' );
- $this->upgrader->strings['skin_update_successful'] = __( '%1$s installed and activated successfully.', 'cryout' ) . ' <a href="#" class="hide-if-no-js" onclick="%2$s"><span>' . esc_html__( 'Show Details', 'cryout' ) . '</span><span class="hidden">' . esc_html__( 'Hide Details', 'cryout' ) . '</span>.</a>';
- $this->upgrader->strings['skin_upgrade_end'] = __( 'All installations and activations have been completed.', 'cryout' );
- $this->upgrader->strings['skin_before_update_header'] = __( 'Installing and Activating Plugin %1$s (%2$d/%3$d)', 'cryout' );
- } else {
- // Default installation strings.
- $this->upgrader->strings['skin_upgrade_start'] = __( 'The installation process is starting. This process may take a while on some hosts, so please be patient.', 'cryout' );
- $this->upgrader->strings['skin_update_successful'] = esc_html__( '%1$s installed successfully.', 'cryout' ) . ' <a href="#" class="hide-if-no-js" onclick="%2$s"><span>' . esc_html__( 'Show Details', 'cryout' ) . '</span><span class="hidden">' . esc_html__( 'Hide Details', 'cryout' ) . '</span>.</a>';
- $this->upgrader->strings['skin_upgrade_end'] = __( 'All installations have been completed.', 'cryout' );
- $this->upgrader->strings['skin_before_update_header'] = __( 'Installing Plugin %1$s (%2$d/%3$d)', 'cryout' );
- }
- }
- }
-
- /**
- * Outputs the header strings and necessary JS before each plugin installation.
- *
- * @since 2.2.0
- *
- * @param string $title Unused in this implementation.
- */
- public function before( $title = '' ) {
- if ( empty( $title ) ) {
- $title = esc_html( $this->plugin_names[ $this->i ] );
- }
- parent::before( $title );
- }
-
- /**
- * Outputs the footer strings and necessary JS after each plugin installation.
- *
- * Checks for any errors and outputs them if they exist, else output
- * success strings.
- *
- * @since 2.2.0
- *
- * @param string $title Unused in this implementation.
- */
- public function after( $title = '' ) {
- if ( empty( $title ) ) {
- $title = esc_html( $this->plugin_names[ $this->i ] );
- }
- parent::after( $title );
-
- $this->i++;
- }
-
- /**
- * Outputs links after bulk plugin installation is complete.
- *
- * @since 2.2.0
- */
- public function bulk_footer() {
- // Serve up the string to say installations (and possibly activations) are complete.
- parent::bulk_footer();
-
- // Flush plugins cache so we can make sure that the installed plugins list is always up to date.
- wp_clean_plugins_cache();
-
- $this->tgmpa->show_tgmpa_version();
-
- // Display message based on if all plugins are now active or not.
- $update_actions = array();
-
- if ( $this->tgmpa->is_tgmpa_complete() ) {
- // All plugins are active, so we display the complete string and hide the menu to protect users.
- echo '<style type="text/css">#adminmenu .wp-submenu li.current { display: none !important; }</style>';
- $update_actions['dashboard'] = sprintf(
- esc_html( $this->tgmpa->strings['complete'] ),
- '<a href="' . esc_url( self_admin_url() ) . '">' . esc_html__( 'Return to the Dashboard', 'cryout' ) . '</a>'
- );
- } else {
- $update_actions['tgmpa_page'] = '<a href="' . esc_url( $this->tgmpa->get_tgmpa_url() ) . '" target="_parent">' . esc_html( $this->tgmpa->strings['return'] ) . '</a>';
- }
-
- /**
- * Filter the list of action links available following bulk plugin installs/updates.
- *
- * @since 2.5.0
- *
- * @param array $update_actions Array of plugin action links.
- * @param array $plugin_info Array of information for the last-handled plugin.
- */
- $update_actions = apply_filters( 'tgmpa_update_bulk_plugins_complete_actions', $update_actions, $this->plugin_info );
-
- if ( ! empty( $update_actions ) ) {
- $this->feedback( implode( ' | ', (array) $update_actions ) );
- }
- }
-
- /* *********** DEPRECATED METHODS *********** */
-
- /**
- * Flush header output buffer.
- *
- * @since 2.2.0
- * @deprecated 2.5.0 use {@see Bulk_Upgrader_Skin::flush_output()} instead
- * @see Bulk_Upgrader_Skin::flush_output()
- */
- public function before_flush_output() {
- _deprecated_function( __FUNCTION__, 'TGMPA 2.5.0', 'Bulk_Upgrader_Skin::flush_output()' );
- $this->flush_output();
- }
-
- /**
- * Flush footer output buffer and iterate $this->i to make sure the
- * installation strings reference the correct plugin.
- *
- * @since 2.2.0
- * @deprecated 2.5.0 use {@see Bulk_Upgrader_Skin::flush_output()} instead
- * @see Bulk_Upgrader_Skin::flush_output()
- */
- public function after_flush_output() {
- _deprecated_function( __FUNCTION__, 'TGMPA 2.5.0', 'Bulk_Upgrader_Skin::flush_output()' );
- $this->flush_output();
- $this->i++;
- }
- }
- }
- }
- }
-}
-
-if ( ! class_exists( 'TGMPA_Utils' ) ) {
-
- /**
- * Generic utilities for TGMPA.
- *
- * All methods are static, poor-dev name-spacing class wrapper.
- *
- * Class was called TGM_Utils in 2.5.0 but renamed TGMPA_Utils in 2.5.1 as this was conflicting with Soliloquy.
- *
- * @since 2.5.0
- *
- * @package TGM-Plugin-Activation
- * @author Juliette Reinders Folmer
- */
- class TGMPA_Utils {
- /**
- * Whether the PHP filter extension is enabled.
- *
- * @see http://php.net/book.filter
- *
- * @since 2.5.0
- *
- * @static
- *
- * @var bool $has_filters True is the extension is enabled.
- */
- public static $has_filters;
-
- /**
- * Wrap an arbitrary string in <em> tags. Meant to be used in combination with array_map().
- *
- * @since 2.5.0
- *
- * @static
- *
- * @param string $string Text to be wrapped.
- * @return string
- */
- public static function wrap_in_em( $string ) {
- return '<em>' . wp_kses_post( $string ) . '</em>';
- }
-
- /**
- * Wrap an arbitrary string in <strong> tags. Meant to be used in combination with array_map().
- *
- * @since 2.5.0
- *
- * @static
- *
- * @param string $string Text to be wrapped.
- * @return string
- */
- public static function wrap_in_strong( $string ) {
- return '<strong>' . wp_kses_post( $string ) . '</strong>';
- }
-
- /**
- * Helper function: Validate a value as boolean
- *
- * @since 2.5.0
- *
- * @static
- *
- * @param mixed $value Arbitrary value.
- * @return bool
- */
- public static function validate_bool( $value ) {
- if ( ! isset( self::$has_filters ) ) {
- self::$has_filters = extension_loaded( 'filter' );
- }
-
- if ( self::$has_filters ) {
- return filter_var( $value, FILTER_VALIDATE_BOOLEAN );
- } else {
- return self::emulate_filter_bool( $value );
- }
- }
-
- /**
- * Helper function: Cast a value to bool
- *
- * @since 2.5.0
- *
- * @static
- *
- * @param mixed $value Value to cast.
- * @return bool
- */
- protected static function emulate_filter_bool( $value ) {
- // @codingStandardsIgnoreStart
- static $true = array(
- '1',
- 'true', 'True', 'TRUE',
- 'y', 'Y',
- 'yes', 'Yes', 'YES',
- 'on', 'On', 'ON',
- );
- static $false = array(
- '0',
- 'false', 'False', 'FALSE',
- 'n', 'N',
- 'no', 'No', 'NO',
- 'off', 'Off', 'OFF',
- );
- // @codingStandardsIgnoreEnd
-
- if ( is_bool( $value ) ) {
- return $value;
- } else if ( is_int( $value ) && ( 0 === $value || 1 === $value ) ) {
- return (bool) $value;
- } else if ( ( is_float( $value ) && ! is_nan( $value ) ) && ( (float) 0 === $value || (float) 1 === $value ) ) {
- return (bool) $value;
- } else if ( is_string( $value ) ) {
- $value = trim( $value );
- if ( in_array( $value, $true, true ) ) {
- return true;
- } else if ( in_array( $value, $false, true ) ) {
- return false;
- } else {
- return false;
- }
- }
-
- return false;
- }
- } // End of class TGMPA_Utils
-} // End of class_exists wrapper
-
+<?php
+
+add_action( 'tgmpa_register', 'cryout_settings_plugin' );
+
+function cryout_settings_plugin() {
+
+ $plugins = array(
+
+ array(
+ 'name' => 'Cryout Serious Theme Settings',
+ 'slug' => 'cryout-theme-settings',
+ 'required' => false,
+ 'version' => '0.5.6',
+ //'force_activation' => true,
+ //'force_deactivation' => true,
+ ),
+
+ );
+
+ $config = array(
+ 'default_path' => '', // Default absolute path to pre-packaged plugins.
+ 'menu' => 'mantra-extra-plugins', // Menu slug.
+ 'has_notices' => true, // Show admin notices or not.
+ 'dismissable' => true, // If false, a user cannot dismiss the nag message.
+ 'dismiss_msg' => '', // If 'dismissable' is false, this message will be output at top of nag.
+ 'is_automatic' => true, // Automatically activate plugins after installation or not.
+ 'message' => '', // Message to output right before the plugins table.
+ 'strings' => array(
+ 'page_title' => __( 'Recommended Plugins', 'cryout' ),
+ 'menu_title' => ucwords(_CRYOUT_THEME_NAME) . __( ' Plugins', 'cryout' ),
+ 'installing' => __( 'Installing Plugin: %s', 'cryout' ), // %s = plugin name.
+ 'oops' => __( 'Something went wrong with the plugin API.', 'cryout' ),
+ 'notice_can_install_required' => _n_noop( ucwords(_CRYOUT_THEME_NAME) . ' requires the following plugin: %1$s.', ucwords(_CRYOUT_THEME_NAME) . ' requires the following plugins: %1$s.', 'cryout' ), // %1$s = plugin name(s).
+ 'notice_can_install_recommended' => _n_noop( ucwords(_CRYOUT_THEME_NAME) . ' recommends the following plugin: %1$s.', ucwords(_CRYOUT_THEME_NAME) . ' recommends the following plugins: %1$s.', 'cryout' ), // %1$s = plugin name(s).
+ 'notice_cannot_install' => _n_noop( 'Sorry, but you do not have the correct permissions to install the %s plugin. Contact the administrator of this site for help on getting the plugin installed.', 'Sorry, but you do not have the correct permissions to install the %s plugins. Contact the administrator of this site for help on getting the plugins installed.', 'cryout' ), // %1$s = plugin name(s).
+ 'notice_can_activate_required' => _n_noop( 'The following required plugin is currently inactive: %1$s.', 'The following required plugins are currently inactive: %1$s.', 'cryout' ), // %1$s = plugin name(s).
+ 'notice_can_activate_recommended' => _n_noop( 'The following recommended plugin is currently inactive: %1$s.', 'The following recommended plugins are currently inactive: %1$s.', 'cryout' ), // %1$s = plugin name(s).
+ 'notice_cannot_activate' => _n_noop( 'Sorry, but you do not have the correct permissions to activate the %s plugin. Contact the administrator of this site for help on getting the plugin activated.', 'Sorry, but you do not have the correct permissions to activate the %s plugins. Contact the administrator of this site for help on getting the plugins activated.', 'cryout' ), // %1$s = plugin name(s).
+ 'notice_ask_to_update' => _n_noop( 'The following plugin needs to be updated to its latest version to ensure maximum compatibility with this theme: %1$s.', 'The following plugins need to be updated to their latest version to ensure maximum compatibility with this theme: %1$s.', 'cryout' ), // %1$s = plugin name(s).
+ 'notice_cannot_update' => _n_noop( 'Sorry, but you do not have the correct permissions to update the %s plugin. Contact the administrator of this site for help on getting the plugin updated.', 'Sorry, but you do not have the correct permissions to update the %s plugins. Contact the administrator of this site for help on getting the plugins updated.', 'cryout' ), // %1$s = plugin name(s).
+ 'install_link' => _n_noop( 'Begin installing plugin', 'Begin installing plugins', 'cryout' ),
+ 'activate_link' => _n_noop( 'Begin activating plugin', 'Begin activating plugins', 'cryout' ),
+ 'return' => __( 'Return to Required Plugins Installer', 'cryout' ),
+ 'plugin_activated' => __( 'Plugin activated successfully.', 'cryout' ),
+ 'complete' => __( 'All plugins installed and activated successfully. %s', 'cryout' ), // %s = dashboard link.
+ 'nag_type' => 'updated' // Determines admin notice type - can only be 'updated', 'update-nag' or 'error'.
+ )
+ );
+
+ tgmpa( $plugins, $config );
+
+}
+
+
+/***************** TGM class below *******************/
+
+/**
+ * Plugin installation and activation for WordPress themes.
+ *
+ * Please note that this is a drop-in library for a theme or plugin.
+ * The authors of this library (Thomas, Gary and Juliette) are NOT responsible
+ * for the support of your plugin or theme. Please contact the plugin
+ * or theme author for support.
+ *
+ * @package TGM-Plugin-Activation
+ * @version 2.5.2
+ * @link http://tgmpluginactivation.com/
+ * @author Thomas Griffin, Gary Jones, Juliette Reinders Folmer
+ * @copyright Copyright (c) 2011, Thomas Griffin
+ * @license GPL-2.0+
+ *
+ * @wordpress-plugin
+ * Plugin Name: TGM Plugin Activation
+ * Plugin URI:
+ * Description: Plugin installation and activation for WordPress themes.
+ * Version: 2.5.2
+ * Author: Thomas Griffin, Gary Jones, Juliette Reinders Folmer
+ * Author URI: http://tgmpluginactivation.com/
+ * Text Domain: tgmpa
+ * Domain Path: /languages/
+ * Copyright: 2011, Thomas Griffin
+ */
+
+/*
+ Copyright 2011 Thomas Griffin (thomasgriffinmedia.com)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License, version 2, as
+ published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+if ( ! class_exists( 'TGM_Plugin_Activation' ) ) {
+
+ /**
+ * Automatic plugin installation and activation library.
+ *
+ * Creates a way to automatically install and activate plugins from within themes.
+ * The plugins can be either bundled, downloaded from the WordPress
+ * Plugin Repository or downloaded from another external source.
+ *
+ * @since 1.0.0
+ *
+ * @package TGM-Plugin-Activation
+ * @author Thomas Griffin
+ * @author Gary Jones
+ */
+ class TGM_Plugin_Activation {
+ /**
+ * TGMPA version number.
+ *
+ * @since 2.5.0
+ *
+ * @const string Version number.
+ */
+ const TGMPA_VERSION = '2.5.2';
+
+ /**
+ * Regular expression to test if a URL is a WP plugin repo URL.
+ *
+ * @const string Regex.
+ *
+ * @since 2.5.0
+ */
+ const WP_REPO_REGEX = '|^http[s]?://wordpress\.org/(?:extend/)?plugins/|';
+
+ /**
+ * Arbitrary regular expression to test if a string starts with a URL.
+ *
+ * @const string Regex.
+ *
+ * @since 2.5.0
+ */
+ const IS_URL_REGEX = '|^http[s]?://|';
+
+ /**
+ * Holds a copy of itself, so it can be referenced by the class name.
+ *
+ * @since 1.0.0
+ *
+ * @var TGM_Plugin_Activation
+ */
+ public static $instance;
+
+ /**
+ * Holds arrays of plugin details.
+ *
+ * @since 1.0.0
+ *
+ * @since 2.5.0 the array has the plugin slug as an associative key.
+ *
+ * @var array
+ */
+ public $plugins = array();
+
+ /**
+ * Holds arrays of plugin names to use to sort the plugins array.
+ *
+ * @since 2.5.0
+ *
+ * @var array
+ */
+ protected $sort_order = array();
+
+ /**
+ * Whether any plugins have the 'force_activation' setting set to true.
+ *
+ * @since 2.5.0
+ *
+ * @var bool
+ */
+ protected $has_forced_activation = false;
+
+ /**
+ * Whether any plugins have the 'force_deactivation' setting set to true.
+ *
+ * @since 2.5.0
+ *
+ * @var bool
+ */
+ protected $has_forced_deactivation = false;
+
+ /**
+ * Name of the unique ID to hash notices.
+ *
+ * @since 2.4.0
+ *
+ * @var string
+ */
+ public $id = 'tgmpa';
+
+ /**
+ * Name of the query-string argument for the admin page.
+ *
+ * @since 1.0.0
+ *
+ * @var string
+ */
+ protected $menu = 'tgmpa-install-plugins';
+
+ /**
+ * Parent menu file slug.
+ *
+ * @since 2.5.0
+ *
+ * @var string
+ */
+ public $parent_slug = 'themes.php';
+
+ /**
+ * Capability needed to view the plugin installation menu item.
+ *
+ * @since 2.5.0
+ *
+ * @var string
+ */
+ public $capability = 'edit_theme_options';
+
+ /**
+ * Default absolute path to folder containing bundled plugin zip files.
+ *
+ * @since 2.0.0
+ *
+ * @var string Absolute path prefix to zip file location for bundled plugins. Default is empty string.
+ */
+ public $default_path = '';
+
+ /**
+ * Flag to show admin notices or not.
+ *
+ * @since 2.1.0
+ *
+ * @var boolean
+ */
+ public $has_notices = true;
+
+ /**
+ * Flag to determine if the user can dismiss the notice nag.
+ *
+ * @since 2.4.0
+ *
+ * @var boolean
+ */
+ public $dismissable = true;
+
+ /**
+ * Message to be output above nag notice if dismissable is false.
+ *
+ * @since 2.4.0
+ *
+ * @var string
+ */
+ public $dismiss_msg = '';
+
+ /**
+ * Flag to set automatic activation of plugins. Off by default.
+ *
+ * @since 2.2.0
+ *
+ * @var boolean
+ */
+ public $is_automatic = false;
+
+ /**
+ * Optional message to display before the plugins table.
+ *
+ * @since 2.2.0
+ *
+ * @var string Message filtered by wp_kses_post(). Default is empty string.
+ */
+ public $message = '';
+
+ /**
+ * Holds configurable array of strings.
+ *
+ * Default values are added in the constructor.
+ *
+ * @since 2.0.0
+ *
+ * @var array
+ */
+ public $strings = array();
+
+ /**
+ * Holds the version of WordPress.
+ *
+ * @since 2.4.0
+ *
+ * @var int
+ */
+ public $wp_version;
+
+ /**
+ * Holds the hook name for the admin page.
+ *
+ * @since 2.5.0
+ *
+ * @var string
+ */
+ public $page_hook;
+
+ /**
+ * Adds a reference of this object to $instance, populates default strings,
+ * does the tgmpa_init action hook, and hooks in the interactions to init.
+ *
+ * @internal This method should be `protected`, but as too many TGMPA implementations
+ * haven't upgraded beyond v2.3.6 yet, this gives backward compatibility issues.
+ * Reverted back to public for the time being.
+ *
+ * @since 1.0.0
+ *
+ * @see TGM_Plugin_Activation::init()
+ */
+ public function __construct() {
+ // Set the current WordPress version.
+ $this->wp_version = $GLOBALS['wp_version'];
+
+ // Announce that the class is ready, and pass the object (for advanced use).
+ do_action_ref_array( 'tgmpa_init', array( $this ) );
+
+ // When the rest of WP has loaded, kick-start the rest of the class.
+ add_action( 'init', array( $this, 'init' ) );
+ }
+
+ /**
+ * Magic method to (not) set protected properties from outside of this class.
+ *
+ * @internal hackedihack... There is a serious bug in v2.3.2 - 2.3.6 where the `menu` property
+ * is being assigned rather than tested in a conditional, effectively rendering it useless.
+ * This 'hack' prevents this from happening.
+ *
+ * @see https://github.com/TGMPA/TGM-Plugin-Activation/blob/2.3.6/tgm-plugin-activation/class-tgm-plugin-activation.php#L1593
+ *
+ * @param string $name Name of an inaccessible property.
+ * @param mixed $value Value to assign to the property.
+ * @return void Silently fail to set the property when this is tried from outside of this class context.
+ * (Inside this class context, the __set() method if not used as there is direct access.)
+ */
+ public function __set( $name, $value ) {
+ return;
+ }
+
+ /**
+ * Magic method to get the value of a protected property outside of this class context.
+ *
+ * @param string $name Name of an inaccessible property.
+ * @return mixed The property value.
+ */
+ public function __get( $name ) {
+ return $this->{$name};
+ }
+
+ /**
+ * Initialise the interactions between this class and WordPress.
+ *
+ * Hooks in three new methods for the class: admin_menu, notices and styles.
+ *
+ * @since 2.0.0
+ *
+ * @see TGM_Plugin_Activation::admin_menu()
+ * @see TGM_Plugin_Activation::notices()
+ * @see TGM_Plugin_Activation::styles()
+ */
+ public function init() {
+ /**
+ * By default TGMPA only loads on the WP back-end and not in an Ajax call. Using this filter
+ * you can overrule that behaviour.
+ *
+ * @since 2.5.0
+ *
+ * @param bool $load Whether or not TGMPA should load.
+ * Defaults to the return of `is_admin() && ! defined( 'DOING_AJAX' )`.
+ */
+ if ( true !== apply_filters( 'tgmpa_load', ( is_admin() && ! defined( 'DOING_AJAX' ) ) ) ) {
+ return;
+ }
+
+ // Load class strings.
+ $this->strings = array(
+ 'page_title' => __( 'Install Required Plugins', 'cryout' ),
+ 'menu_title' => __( 'Install Plugins', 'cryout' ),
+ 'installing' => __( 'Installing Plugin: %s', 'cryout' ),
+ 'oops' => __( 'Something went wrong with the plugin API.', 'cryout' ),
+ 'notice_can_install_required' => _n_noop(
+ 'This theme requires the following plugin: %1$s.',
+ 'This theme requires the following plugins: %1$s.',
+ 'cryout'
+ ),
+ 'notice_can_install_recommended' => _n_noop(
+ 'This theme recommends the following plugin: %1$s.',
+ 'This theme recommends the following plugins: %1$s.',
+ 'cryout'
+ ),
+ 'notice_cannot_install' => _n_noop(
+ 'Sorry, but you do not have the correct permissions to install the %1$s plugin.',
+ 'Sorry, but you do not have the correct permissions to install the %1$s plugins.',
+ 'cryout'
+ ),
+ 'notice_ask_to_update' => _n_noop(
+ 'The following plugin needs to be updated to its latest version to ensure maximum compatibility with this theme: %1$s.',
+ 'The following plugins need to be updated to their latest version to ensure maximum compatibility with this theme: %1$s.',
+ 'cryout'
+ ),
+ 'notice_ask_to_update_maybe' => _n_noop(
+ 'There is an update available for: %1$s.',
+ 'There are updates available for the following plugins: %1$s.',
+ 'cryout'
+ ),
+ 'notice_cannot_update' => _n_noop(
+ 'Sorry, but you do not have the correct permissions to update the %1$s plugin.',
+ 'Sorry, but you do not have the correct permissions to update the %1$s plugins.',
+ 'cryout'
+ ),
+ 'notice_can_activate_required' => _n_noop(
+ 'The following required plugin is currently inactive: %1$s.',
+ 'The following required plugins are currently inactive: %1$s.',
+ 'cryout'
+ ),
+ 'notice_can_activate_recommended' => _n_noop(
+ 'The following recommended plugin is currently inactive: %1$s.',
+ 'The following recommended plugins are currently inactive: %1$s.',
+ 'cryout'
+ ),
+ 'notice_cannot_activate' => _n_noop(
+ 'Sorry, but you do not have the correct permissions to activate the %1$s plugin.',
+ 'Sorry, but you do not have the correct permissions to activate the %1$s plugins.',
+ 'cryout'
+ ),
+ 'install_link' => _n_noop(
+ 'Begin installing plugin',
+ 'Begin installing plugins',
+ 'cryout'
+ ),
+ 'update_link' => _n_noop(
+ 'Begin updating plugin',
+ 'Begin updating plugins',
+ 'cryout'
+ ),
+ 'activate_link' => _n_noop(
+ 'Begin activating plugin',
+ 'Begin activating plugins',
+ 'cryout'
+ ),
+ 'return' => __( 'Return to Required Plugins Installer', 'cryout' ),
+ 'dashboard' => __( 'Return to the dashboard', 'cryout' ),
+ 'plugin_activated' => __( 'Plugin activated successfully.', 'cryout' ),
+ 'activated_successfully' => __( 'The following plugin was activated successfully:', 'cryout' ),
+ 'plugin_already_active' => __( 'No action taken. Plugin %1$s was already active.', 'cryout' ),
+ 'plugin_needs_higher_version' => __( 'Plugin not activated. A higher version of %s is needed for this theme. Please update the plugin.', 'cryout' ),
+ 'complete' => __( 'All plugins installed and activated successfully. %1$s', 'cryout' ),
+ 'dismiss' => __( 'Dismiss this notice', 'cryout' ),
+ 'contact_admin' => __( 'Please contact the administrator of this site for help.', 'cryout' ),
+ );
+
+ do_action( 'tgmpa_register' );
+
+ /* After this point, the plugins should be registered and the configuration set. */
+
+ // Proceed only if we have plugins to handle.
+ if ( empty( $this->plugins ) || ! is_array( $this->plugins ) ) {
+ return;
+ }
+
+ // Set up the menu and notices if we still have outstanding actions.
+ if ( true !== $this->is_tgmpa_complete() ) {
+ // Sort the plugins.
+ array_multisort( $this->sort_order, SORT_ASC, $this->plugins );
+
+ add_action( 'admin_menu', array( $this, 'admin_menu' ) );
+ add_action( 'admin_head', array( $this, 'dismiss' ) );
+
+ // Prevent the normal links from showing underneath a single install/update page.
+ add_filter( 'install_plugin_complete_actions', array( $this, 'actions' ) );
+ add_filter( 'update_plugin_complete_actions', array( $this, 'actions' ) );
+
+ if ( $this->has_notices ) {
+ add_action( 'admin_notices', array( $this, 'notices' ) );
+ add_action( 'admin_init', array( $this, 'admin_init' ), 1 );
+ add_action( 'admin_enqueue_scripts', array( $this, 'thickbox' ) );
+ }
+
+ add_action( 'load-plugins.php', array( $this, 'add_plugin_action_link_filters' ), 1 );
+ }
+
+ // Make sure things get reset on switch theme.
+ add_action( 'switch_theme', array( $this, 'flush_plugins_cache' ) );
+
+ if ( $this->has_notices ) {
+ add_action( 'switch_theme', array( $this, 'update_dismiss' ) );
+ }
+
+ // Setup the force activation hook.
+ if ( true === $this->has_forced_activation ) {
+ add_action( 'admin_init', array( $this, 'force_activation' ) );
+ }
+
+ // Setup the force deactivation hook.
+ if ( true === $this->has_forced_deactivation ) {
+ add_action( 'switch_theme', array( $this, 'force_deactivation' ) );
+ }
+ }
+
+ /**
+ * Prevent activation of plugins which don't meet the minimum version requirement from the
+ * WP native plugins page.
+ *
+ * @since 2.5.0
+ */
+ public function add_plugin_action_link_filters() {
+ foreach ( $this->plugins as $slug => $plugin ) {
+ if ( false === $this->can_plugin_activate( $slug ) ) {
+ add_filter( 'plugin_action_links_' . $plugin['file_path'], array( $this, 'filter_plugin_action_links_activate' ), 20 );
+ }
+
+ if ( true === $plugin['force_activation'] ) {
+ add_filter( 'plugin_action_links_' . $plugin['file_path'], array( $this, 'filter_plugin_action_links_deactivate' ), 20 );
+ }
+
+ if ( false !== $this->does_plugin_require_update( $slug ) ) {
+ add_filter( 'plugin_action_links_' . $plugin['file_path'], array( $this, 'filter_plugin_action_links_update' ), 20 );
+ }
+ }
+ }
+
+ /**
+ * Remove the 'Activate' link on the WP native plugins page if the plugin does not meet the
+ * minimum version requirements.
+ *
+ * @since 2.5.0
+ *
+ * @param array $actions Action links.
+ * @return array
+ */
+ public function filter_plugin_action_links_activate( $actions ) {
+ unset( $actions['activate'] );
+
+ return $actions;
+ }
+
+ /**
+ * Remove the 'Deactivate' link on the WP native plugins page if the plugin has been set to force activate.
+ *
+ * @since 2.5.0
+ *
+ * @param array $actions Action links.
+ * @return array
+ */
+ public function filter_plugin_action_links_deactivate( $actions ) {
+ unset( $actions['deactivate'] );
+
+ return $actions;
+ }
+
+ /**
+ * Add a 'Requires update' link on the WP native plugins page if the plugin does not meet the
+ * minimum version requirements.
+ *
+ * @since 2.5.0
+ *
+ * @param array $actions Action links.
+ * @return array
+ */
+ public function filter_plugin_action_links_update( $actions ) {
+ $actions['update'] = sprintf(
+ '<a href="%1$s" title="%2$s" class="edit">%3$s</a>',
+ esc_url( $this->get_tgmpa_status_url( 'update' ) ),
+ esc_attr__( 'This plugin needs to be updated to be compatible with your theme.', 'cryout' ),
+ esc_html__( 'Update Required', 'cryout' )
+ );
+
+ return $actions;
+ }
+
+ /**
+ * Handles calls to show plugin information via links in the notices.
+ *
+ * We get the links in the admin notices to point to the TGMPA page, rather
+ * than the typical plugin-install.php file, so we can prepare everything
+ * beforehand.
+ *
+ * WP does not make it easy to show the plugin information in the thickbox -
+ * here we have to require a file that includes a function that does the
+ * main work of displaying it, enqueue some styles, set up some globals and
+ * finally call that function before exiting.
+ *
+ * Down right easy once you know how...
+ *
+ * Returns early if not the TGMPA page.
+ *
+ * @since 2.1.0
+ *
+ * @global string $tab Used as iframe div class names, helps with styling
+ * @global string $body_id Used as the iframe body ID, helps with styling
+ *
+ * @return null Returns early if not the TGMPA page.
+ */
+ public function admin_init() {
+ if ( ! $this->is_tgmpa_page() ) {
+ return;
+ }
+
+ if ( isset( $_REQUEST['tab'] ) && 'plugin-information' === $_REQUEST['tab'] ) {
+ // Needed for install_plugin_information().
+ require_once ABSPATH . 'wp-admin/includes/plugin-install.php';
+
+ wp_enqueue_style( 'plugin-install' );
+
+ global $tab, $body_id;
+ $body_id = 'plugin-information';
+ // @codingStandardsIgnoreStart
+ $tab = 'plugin-information';
+ // @codingStandardsIgnoreEnd
+
+ install_plugin_information();
+
+ exit;
+ }
+ }
+
+ /**
+ * Enqueue thickbox scripts/styles for plugin info.
+ *
+ * Thickbox is not automatically included on all admin pages, so we must
+ * manually enqueue it for those pages.
+ *
+ * Thickbox is only loaded if the user has not dismissed the admin
+ * notice or if there are any plugins left to install and activate.
+ *
+ * @since 2.1.0
+ */
+ public function thickbox() {
+ if ( ! get_user_meta( get_current_user_id(), 'tgmpa_dismissed_notice_' . $this->id, true ) ) {
+ add_thickbox();
+ }
+ }
+
+ /**
+ * Adds submenu page if there are plugin actions to take.
+ *
+ * This method adds the submenu page letting users know that a required
+ * plugin needs to be installed.
+ *
+ * This page disappears once the plugin has been installed and activated.
+ *
+ * @since 1.0.0
+ *
+ * @see TGM_Plugin_Activation::init()
+ * @see TGM_Plugin_Activation::install_plugins_page()
+ *
+ * @return null Return early if user lacks capability to install a plugin.
+ */
+ public function admin_menu() {
+ // Make sure privileges are correct to see the page.
+ if ( ! current_user_can( 'install_plugins' ) ) {
+ return;
+ }
+
+ $args = apply_filters(
+ 'tgmpa_admin_menu_args',
+ array(
+ 'parent_slug' => $this->parent_slug, // Parent Menu slug.
+ 'page_title' => $this->strings['page_title'], // Page title.
+ 'menu_title' => $this->strings['menu_title'], // Menu title.
+ 'capability' => $this->capability, // Capability.
+ 'menu_slug' => $this->menu, // Menu slug.
+ 'function' => array( $this, 'install_plugins_page' ), // Callback.
+ )
+ );
+
+ $this->add_admin_menu( $args );
+ }
+
+ /**
+ * Add the menu item.
+ *
+ * @since 2.5.0
+ *
+ * @param array $args Menu item configuration.
+ */
+ protected function add_admin_menu( array $args ) {
+ if ( has_filter( 'tgmpa_admin_menu_use_add_theme_page' ) ) {
+ _deprecated_function( 'The "tgmpa_admin_menu_use_add_theme_page" filter', '2.5.0', esc_html__( 'Set the parent_slug config variable instead.', 'cryout' ) );
+ }
+
+ // modified to pass theme check requirement
+ $this->page_hook = call_user_func( 'add_theme_page', $args['page_title'], $args['menu_title'], $args['capability'], $args['menu_slug'], $args['function'] );
+ }
+
+ /**
+ * Echoes plugin installation form.
+ *
+ * This method is the callback for the admin_menu method function.
+ * This displays the admin page and form area where the user can select to install and activate the plugin.
+ * Aborts early if we're processing a plugin installation action.
+ *
+ * @since 1.0.0
+ *
+ * @return null Aborts early if we're processing a plugin installation action.
+ */
+ public function install_plugins_page() {
+ // Store new instance of plugin table in object.
+ $plugin_table = new TGMPA_List_Table;
+
+ // Return early if processing a plugin installation action.
+ if ( ( ( 'tgmpa-bulk-install' === $plugin_table->current_action() || 'tgmpa-bulk-update' === $plugin_table->current_action() ) && $plugin_table->process_bulk_actions() ) || $this->do_plugin_install() ) {
+ return;
+ }
+
+ // Force refresh of available plugin information so we'll know about manual updates/deletes.
+ wp_clean_plugins_cache( false );
+
+ ?>
+ <div class="tgmpa wrap">
+ <h2><?php echo esc_html( get_admin_page_title() ); ?></h2>
+ <?php $plugin_table->prepare_items(); ?>
+
+ <?php
+ if ( ! empty( $this->message ) && is_string( $this->message ) ) {
+ echo wp_kses_post( $this->message );
+ }
+ ?>
+ <?php $plugin_table->views(); ?>
+
+ <form id="tgmpa-plugins" action="" method="post">
+ <input type="hidden" name="tgmpa-page" value="<?php echo esc_attr( $this->menu ); ?>" />
+ <input type="hidden" name="plugin_status" value="<?php echo esc_attr( $plugin_table->view_context ); ?>" />
+ <?php $plugin_table->display(); ?>
+ </form>
+ </div>
+ <?php
+ }
+
+ /**
+ * Installs, updates or activates a plugin depending on the action link clicked by the user.
+ *
+ * Checks the $_GET variable to see which actions have been
+ * passed and responds with the appropriate method.
+ *
+ * Uses WP_Filesystem to process and handle the plugin installation
+ * method.
+ *
+ * @since 1.0.0
+ *
+ * @uses WP_Filesystem
+ * @uses WP_Error
+ * @uses WP_Upgrader
+ * @uses Plugin_Upgrader
+ * @uses Plugin_Installer_Skin
+ * @uses Plugin_Upgrader_Skin
+ *
+ * @return boolean True on success, false on failure.
+ */
+ protected function do_plugin_install() {
+ if ( empty( $_GET['plugin'] ) ) {
+ return false;
+ }
+
+ // All plugin information will be stored in an array for processing.
+ $slug = $this->sanitize_key( urldecode( $_GET['plugin'] ) );
+
+ if ( ! isset( $this->plugins[ $slug ] ) ) {
+ return false;
+ }
+
+ // Was an install or upgrade action link clicked?
+ if ( ( isset( $_GET['tgmpa-install'] ) && 'install-plugin' === $_GET['tgmpa-install'] ) || ( isset( $_GET['tgmpa-update'] ) && 'update-plugin' === $_GET['tgmpa-update'] ) ) {
+
+ $install_type = 'install';
+ if ( isset( $_GET['tgmpa-update'] ) && 'update-plugin' === $_GET['tgmpa-update'] ) {
+ $install_type = 'update';
+ }
+
+ check_admin_referer( 'tgmpa-' . $install_type, 'tgmpa-nonce' );
+
+ // Pass necessary information via URL if WP_Filesystem is needed.
+ $url = wp_nonce_url(
+ add_query_arg(
+ array(
+ 'plugin' => urlencode( $slug ),
+ 'tgmpa-' . $install_type => $install_type . '-plugin',
+ ),
+ $this->get_tgmpa_url()
+ ),
+ 'tgmpa-' . $install_type,
+ 'tgmpa-nonce'
+ );
+
+ $method = ''; // Leave blank so WP_Filesystem can populate it as necessary.
+
+ if ( false === ( $creds = request_filesystem_credentials( esc_url_raw( $url ), $method, false, false, array() ) ) ) {
+ return true;
+ }
+
+ if ( ! WP_Filesystem( $creds ) ) {
+ request_filesystem_credentials( esc_url_raw( $url ), $method, true, false, array() ); // Setup WP_Filesystem.
+ return true;
+ }
+
+ /* If we arrive here, we have the filesystem. */
+
+ // Prep variables for Plugin_Installer_Skin class.
+ $extra = array();
+ $extra['slug'] = $slug; // Needed for potentially renaming of directory name.
+ $source = $this->get_download_url( $slug );
+ $api = ( 'repo' === $this->plugins[ $slug ]['source_type'] ) ? $this->get_plugins_api( $slug ) : null;
+ $api = ( false !== $api ) ? $api : null;
+
+ $url = add_query_arg(
+ array(
+ 'action' => $install_type . '-plugin',
+ 'plugin' => urlencode( $slug ),
+ ),
+ 'update.php'
+ );
+
+ if ( ! class_exists( 'Plugin_Upgrader', false ) ) {
+ require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
+ }
+
+ $skin_args = array(
+ 'type' => ( 'bundled' !== $this->plugins[ $slug ]['source_type'] ) ? 'web' : 'upload',
+ 'title' => sprintf( $this->strings['installing'], $this->plugins[ $slug ]['name'] ),
+ 'url' => esc_url_raw( $url ),
+ 'nonce' => $install_type . '-plugin_' . $slug,
+ 'plugin' => '',
+ 'api' => $api,
+ 'extra' => $extra,
+ );
+
+ if ( 'update' === $install_type ) {
+ $skin_args['plugin'] = $this->plugins[ $slug ]['file_path'];
+ $skin = new Plugin_Upgrader_Skin( $skin_args );
+ } else {
+ $skin = new Plugin_Installer_Skin( $skin_args );
+ }
+
+ // Create a new instance of Plugin_Upgrader.
+ $upgrader = new Plugin_Upgrader( $skin );
+
+ // Perform the action and install the plugin from the $source urldecode().
+ add_filter( 'upgrader_source_selection', array( $this, 'maybe_adjust_source_dir' ), 1, 3 );
+
+ if ( 'update' === $install_type ) {
+ // Inject our info into the update transient.
+ $to_inject = array( $slug => $this->plugins[ $slug ] );
+ $to_inject[ $slug ]['source'] = $source;
+ $this->inject_update_info( $to_inject );
+
+ $upgrader->upgrade( $this->plugins[ $slug ]['file_path'] );
+ } else {
+ $upgrader->install( $source );
+ }
+
+ remove_filter( 'upgrader_source_selection', array( $this, 'maybe_adjust_source_dir' ), 1, 3 );
+
+ // Make sure we have the correct file path now the plugin is installed/updated.
+ $this->populate_file_path( $slug );
+
+ // Only activate plugins if the config option is set to true and the plugin isn't
+ // already active (upgrade).
+ if ( $this->is_automatic && ! $this->is_plugin_active( $slug ) ) {
+ $plugin_activate = $upgrader->plugin_info(); // Grab the plugin info from the Plugin_Upgrader method.
+ if ( false === $this->activate_single_plugin( $plugin_activate, $slug, true ) ) {
+ return true; // Finish execution of the function early as we encountered an error.
+ }
+ }
+
+ $this->show_tgmpa_version();
+
+ // Display message based on if all plugins are now active or not.
+ if ( $this->is_tgmpa_complete() ) {
+ echo '<p>', sprintf( esc_html( $this->strings['complete'] ), '<a href="' . esc_url( self_admin_url() ) . '">' . esc_html__( 'Return to the Dashboard', 'cryout' ) . '</a>' ), '</p>';
+ echo '<style type="text/css">#adminmenu .wp-submenu li.current { display: none !important; }</style>';
+ } else {
+ echo '<p><a href="', esc_url( $this->get_tgmpa_url() ), '" target="_parent">', esc_html( $this->strings['return'] ), '</a></p>';
+ }
+
+ return true;
+ } elseif ( isset( $this->plugins[ $slug ]['file_path'], $_GET['tgmpa-activate'] ) && 'activate-plugin' === $_GET['tgmpa-activate'] ) {
+ // Activate action link was clicked.
+ check_admin_referer( 'tgmpa-activate', 'tgmpa-nonce' );
+
+ if ( false === $this->activate_single_plugin( $this->plugins[ $slug ]['file_path'], $slug ) ) {
+ return true; // Finish execution of the function early as we encountered an error.
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Inject information into the 'update_plugins' site transient as WP checks that before running an update.
+ *
+ * @since 2.5.0
+ *
+ * @param array $plugins The plugin information for the plugins which are to be updated.
+ */
+ public function inject_update_info( $plugins ) {
+ $repo_updates = get_site_transient( 'update_plugins' );
+
+ if ( ! is_object( $repo_updates ) ) {
+ $repo_updates = new stdClass;
+ }
+
+ foreach ( $plugins as $slug => $plugin ) {
+ $file_path = $plugin['file_path'];
+
+ if ( empty( $repo_updates->response[ $file_path ] ) ) {
+ $repo_updates->response[ $file_path ] = new stdClass;
+ }
+
+ // We only really need to set package, but let's do all we can in case WP changes something.
+ $repo_updates->response[ $file_path ]->slug = $slug;
+ $repo_updates->response[ $file_path ]->plugin = $file_path;
+ $repo_updates->response[ $file_path ]->new_version = $plugin['version'];
+ $repo_updates->response[ $file_path ]->package = $plugin['source'];
+ if ( empty( $repo_updates->response[ $file_path ]->url ) && ! empty( $plugin['external_url'] ) ) {
+ $repo_updates->response[ $file_path ]->url = $plugin['external_url'];
+ }
+ }
+
+ set_site_transient( 'update_plugins', $repo_updates );
+ }
+
+ /**
+ * Adjust the plugin directory name if necessary.
+ *
+ * The final destination directory of a plugin is based on the subdirectory name found in the
+ * (un)zipped source. In some cases - most notably GitHub repository plugin downloads -, this
+ * subdirectory name is not the same as the expected slug and the plugin will not be recognized
+ * as installed. This is fixed by adjusting the temporary unzipped source subdirectory name to
+ * the expected plugin slug.
+ *
+ * @since 2.5.0
+ *
+ * @param string $source Path to upgrade/zip-file-name.tmp/subdirectory/.
+ * @param string $remote_source Path to upgrade/zip-file-name.tmp.
+ * @param \WP_Upgrader $upgrader Instance of the upgrader which installs the plugin.
+ * @return string $source
+ */
+ public function maybe_adjust_source_dir( $source, $remote_source, $upgrader ) {
+ if ( ! $this->is_tgmpa_page() || ! is_object( $GLOBALS['wp_filesystem'] ) ) {
+ return $source;
+ }
+
+ // Check for single file plugins.
+ $source_files = array_keys( $GLOBALS['wp_filesystem']->dirlist( $remote_source ) );
+ if ( 1 === count( $source_files ) && false === $GLOBALS['wp_filesystem']->is_dir( $source ) ) {
+ return $source;
+ }
+
+ // Multi-file plugin, let's see if the directory is correctly named.
+ $desired_slug = '';
+
+ // Figure out what the slug is supposed to be.
+ if ( false === $upgrader->bulk && ! empty( $upgrader->skin->options['extra']['slug'] ) ) {
+ $desired_slug = $upgrader->skin->options['extra']['slug'];
+ } else {
+ // Bulk installer contains less info, so fall back on the info registered here.
+ foreach ( $this->plugins as $slug => $plugin ) {
+ if ( ! empty( $upgrader->skin->plugin_names[ $upgrader->skin->i ] ) && $plugin['name'] === $upgrader->skin->plugin_names[ $upgrader->skin->i ] ) {
+ $desired_slug = $slug;
+ break;
+ }
+ }
+ unset( $slug, $plugin );
+ }
+
+ if ( ! empty( $desired_slug ) ) {
+ $subdir_name = untrailingslashit( str_replace( trailingslashit( $remote_source ), '', $source ) );
+
+ if ( ! empty( $subdir_name ) && $subdir_name !== $desired_slug ) {
+ $from = untrailingslashit( $source );
+ $to = trailingslashit( $remote_source ) . $desired_slug;
+
+ if ( true === $GLOBALS['wp_filesystem']->move( $from, $to ) ) {
+ return trailingslashit( $to );
+ } else {
+ return new WP_Error( 'rename_failed', esc_html__( 'The remote plugin package does not contain a folder with the desired slug and renaming did not work.', 'cryout' ) . ' ' . esc_html__( 'Please contact the plugin provider and ask them to package their plugin according to the WordPress guidelines.', 'cryout' ), array( 'found' => $subdir_name, 'expected' => $desired_slug ) );
+ }
+ } elseif ( empty( $subdir_name ) ) {
+ return new WP_Error( 'packaged_wrong', esc_html__( 'The remote plugin package consists of more than one file, but the files are not packaged in a folder.', 'cryout' ) . ' ' . esc_html__( 'Please contact the plugin provider and ask them to package their plugin according to the WordPress guidelines.', 'cryout' ), array( 'found' => $subdir_name, 'expected' => $desired_slug ) );
+ }
+ }
+
+ return $source;
+ }
+
+ /**
+ * Activate a single plugin and send feedback about the result to the screen.
+ *
+ * @since 2.5.0
+ *
+ * @param string $file_path Path within wp-plugins/ to main plugin file.
+ * @param string $slug Plugin slug.
+ * @param bool $automatic Whether this is an automatic activation after an install. Defaults to false.
+ * This determines the styling of the output messages.
+ * @return bool False if an error was encountered, true otherwise.
+ */
+ protected function activate_single_plugin( $file_path, $slug, $automatic = false ) {
+ if ( $this->can_plugin_activate( $slug ) ) {
+ $activate = activate_plugin( $file_path );
+
+ if ( is_wp_error( $activate ) ) {
+ echo '<div id="message" class="error"><p>', wp_kses_post( $activate->get_error_message() ), '</p></div>',
+ '<p><a href="', esc_url( $this->get_tgmpa_url() ), '" target="_parent">', esc_html( $this->strings['return'] ), '</a></p>';
+
+ return false; // End it here if there is an error with activation.
+ } else {
+ if ( ! $automatic ) {
+ // Make sure message doesn't display again if bulk activation is performed
+ // immediately after a single activation.
+ if ( ! isset( $_POST['action'] ) ) { // WPCS: CSRF OK.
+ echo '<div id="message" class="updated"><p>', esc_html( $this->strings['activated_successfully'] ), ' <strong>', esc_html( $this->plugins[ $slug ]['name'] ), '.</strong></p></div>';
+ }
+ } else {
+ // Simpler message layout for use on the plugin install page.
+ echo '<p>', esc_html( $this->strings['plugin_activated'] ), '</p>';
+ }
+ }
+ } elseif ( $this->is_plugin_active( $slug ) ) {
+ // No simpler message format provided as this message should never be encountered
+ // on the plugin install page.
+ echo '<div id="message" class="error"><p>',
+ sprintf(
+ esc_html( $this->strings['plugin_already_active'] ),
+ '<strong>' . esc_html( $this->plugins[ $slug ]['name'] ) . '</strong>'
+ ),
+ '</p></div>';
+ } elseif ( $this->does_plugin_require_update( $slug ) ) {
+ if ( ! $automatic ) {
+ // Make sure message doesn't display again if bulk activation is performed
+ // immediately after a single activation.
+ if ( ! isset( $_POST['action'] ) ) { // WPCS: CSRF OK.
+ echo '<div id="message" class="error"><p>',
+ sprintf(
+ esc_html( $this->strings['plugin_needs_higher_version'] ),
+ '<strong>' . esc_html( $this->plugins[ $slug ]['name'] ) . '</strong>'
+ ),
+ '</p></div>';
+ }
+ } else {
+ // Simpler message layout for use on the plugin install page.
+ echo '<p>', sprintf( esc_html( $this->strings['plugin_needs_higher_version'] ), esc_html( $this->plugins[ $slug ]['name'] ) ), '</p>';
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * Echoes required plugin notice.
+ *
+ * Outputs a message telling users that a specific plugin is required for
+ * their theme. If appropriate, it includes a link to the form page where
+ * users can install and activate the plugin.
+ *
+ * Returns early if we're on the Install page.
+ *
+ * @since 1.0.0
+ *
+ * @global object $current_screen
+ *
+ * @return null Returns early if we're on the Install page.
+ */
+ public function notices() {
+ // Remove nag on the install page / Return early if the nag message has been dismissed.
+ if ( $this->is_tgmpa_page() || get_user_meta( get_current_user_id(), 'tgmpa_dismissed_notice_' . $this->id, true ) ) {
+ return;
+ }
+
+ // Store for the plugin slugs by message type.
+ $message = array();
+
+ // Initialize counters used to determine plurality of action link texts.
+ $install_link_count = 0;
+ $update_link_count = 0;
+ $activate_link_count = 0;
+
+ foreach ( $this->plugins as $slug => $plugin ) {
+ if ( $this->is_plugin_active( $slug ) && false === $this->does_plugin_have_update( $slug ) ) {
+ continue;
+ }
+
+ if ( ! $this->is_plugin_installed( $slug ) ) {
+ if ( current_user_can( 'install_plugins' ) ) {
+ $install_link_count++;
+
+ if ( true === $plugin['required'] ) {
+ $message['notice_can_install_required'][] = $slug;
+ } else {
+ $message['notice_can_install_recommended'][] = $slug;
+ }
+ } else {
+ // Need higher privileges to install the plugin.
+ $message['notice_cannot_install'][] = $slug;
+ }
+ } else {
+ if ( ! $this->is_plugin_active( $slug ) && $this->can_plugin_activate( $slug ) ) {
+ if ( current_user_can( 'activate_plugins' ) ) {
+ $activate_link_count++;
+
+ if ( true === $plugin['required'] ) {
+ $message['notice_can_activate_required'][] = $slug;
+ } else {
+ $message['notice_can_activate_recommended'][] = $slug;
+ }
+ } else {
+ // Need higher privileges to activate the plugin.
+ $message['notice_cannot_activate'][] = $slug;
+ }
+ }
+
+ if ( $this->does_plugin_require_update( $slug ) || false !== $this->does_plugin_have_update( $slug ) ) {
+
+ if ( current_user_can( 'install_plugins' ) ) {
+ $update_link_count++;
+
+ if ( $this->does_plugin_require_update( $slug ) ) {
+ $message['notice_ask_to_update'][] = $slug;
+ } elseif ( false !== $this->does_plugin_have_update( $slug ) ) {
+ $message['notice_ask_to_update_maybe'][] = $slug;
+ }
+ } else {
+ // Need higher privileges to update the plugin.
+ $message['notice_cannot_update'][] = $slug;
+ }
+ }
+ }
+ }
+ unset( $slug, $plugin );
+
+ // If we have notices to display, we move forward.
+ if ( ! empty( $message ) ) {
+ krsort( $message ); // Sort messages.
+ $rendered = '';
+
+ // As add_settings_error() wraps the final message in a <p> and as the final message can't be
+ // filtered, using <p>'s in our html would render invalid html output.
+ $line_template = '<span style="display: block; margin: 0.5em 0.5em 0 0; clear: both;">%s</span>' . "\n";
+
+ // If dismissable is false and a message is set, output it now.
+ if ( ! $this->dismissable && ! empty( $this->dismiss_msg ) ) {
+ $rendered .= sprintf( $line_template, wp_kses_post( $this->dismiss_msg ) );
+ }
+
+ // Render the individual message lines for the notice.
+ foreach ( $message as $type => $plugin_group ) {
+ $linked_plugins = array();
+
+ // Get the external info link for a plugin if one is available.
+ foreach ( $plugin_group as $plugin_slug ) {
+ $linked_plugins[] = $this->get_info_link( $plugin_slug );
+ }
+ unset( $plugin_slug );
+
+ $count = count( $plugin_group );
+ $linked_plugins = array_map( array( 'TGMPA_Utils', 'wrap_in_em' ), $linked_plugins );
+ $last_plugin = array_pop( $linked_plugins ); // Pop off last name to prep for readability.
+ $imploded = empty( $linked_plugins ) ? $last_plugin : ( implode( ', ', $linked_plugins ) . ' ' . esc_html_x( 'and', 'plugin A *and* plugin B', 'cryout' ) . ' ' . $last_plugin );
+
+ $rendered .= sprintf(
+ $line_template,
+ sprintf(
+ translate_nooped_plural( $this->strings[ $type ], $count, 'cryout' ),
+ $imploded,
+ $count
+ )
+ );
+
+ if ( 0 === strpos( $type, 'notice_cannot' ) ) {
+ $rendered .= $this->strings['contact_admin'];
+ }
+ }
+ unset( $type, $plugin_group, $linked_plugins, $count, $last_plugin, $imploded );
+
+ // Setup action links.
+ $action_links = array(
+ 'install' => '',
+ 'update' => '',
+ 'activate' => '',
+ 'dismiss' => $this->dismissable ? '<a href="' . esc_url( add_query_arg( 'tgmpa-dismiss', 'dismiss_admin_notices' ) ) . '" class="dismiss-notice" target="_parent">' . esc_html( $this->strings['dismiss'] ) . '</a>' : '',
+ );
+
+ $link_template = '<a href="%2$s">%1$s</a>';
+
+ if ( current_user_can( 'install_plugins' ) ) {
+ if ( $install_link_count > 0 ) {
+ $action_links['install'] = sprintf(
+ $link_template,
+ translate_nooped_plural( $this->strings['install_link'], $install_link_count, 'cryout' ),
+ esc_url( $this->get_tgmpa_status_url( 'install' ) )
+ );
+ }
+ if ( $update_link_count > 0 ) {
+ $action_links['update'] = sprintf(
+ $link_template,
+ translate_nooped_plural( $this->strings['update_link'], $update_link_count, 'cryout' ),
+ esc_url( $this->get_tgmpa_status_url( 'update' ) )
+ );
+ }
+ }
+
+ if ( current_user_can( 'activate_plugins' ) && $activate_link_count > 0 ) {
+ $action_links['activate'] = sprintf(
+ $link_template,
+ translate_nooped_plural( $this->strings['activate_link'], $activate_link_count, 'cryout' ),
+ esc_url( $this->get_tgmpa_status_url( 'activate' ) )
+ );
+ }
+
+ $action_links = apply_filters( 'tgmpa_notice_action_links', $action_links );
+
+ $action_links = array_filter( (array) $action_links ); // Remove any empty array items.
+
+ if ( ! empty( $action_links ) && is_array( $action_links ) ) {
+ $action_links = sprintf( $line_template, implode( ' | ', $action_links ) );
+ $rendered .= apply_filters( 'tgmpa_notice_rendered_action_links', $action_links );
+ }
+
+ // Register the nag messages and prepare them to be processed.
+ if ( ! empty( $this->strings['nag_type'] ) ) {
+ add_settings_error( 'tgmpa', 'tgmpa', $rendered, sanitize_html_class( strtolower( $this->strings['nag_type'] ) ) );
+ } else {
+ $nag_class = version_compare( $this->wp_version, '3.8', '<' ) ? 'updated' : 'update-nag';
+ add_settings_error( 'tgmpa', 'tgmpa', $rendered, $nag_class );
+ }
+ }
+
+ // Admin options pages already output settings_errors, so this is to avoid duplication.
+ if ( 'options-general' !== $GLOBALS['current_screen']->parent_base ) {
+ $this->display_settings_errors();
+ }
+ }
+
+ /**
+ * Display settings errors and remove those which have been displayed to avoid duplicate messages showing
+ *
+ * @since 2.5.0
+ */
+ protected function display_settings_errors() {
+ global $wp_settings_errors;
+
+ settings_errors( 'tgmpa' );
+
+ foreach ( (array) $wp_settings_errors as $key => $details ) {
+ if ( 'tgmpa' === $details['setting'] ) {
+ unset( $wp_settings_errors[ $key ] );
+ break;
+ }
+ }
+ }
+
+ /**
+ * Add dismissable admin notices.
+ *
+ * Appends a link to the admin nag messages. If clicked, the admin notice disappears and no longer is visible to users.
+ *
+ * @since 2.1.0
+ */
+ public function dismiss() {
+ if ( isset( $_GET['tgmpa-dismiss'] ) ) {
+ update_user_meta( get_current_user_id(), 'tgmpa_dismissed_notice_' . $this->id, 1 );
+ }
+ }
+
+ /**
+ * Add individual plugin to our collection of plugins.
+ *
+ * If the required keys are not set or the plugin has already
+ * been registered, the plugin is not added.
+ *
+ * @since 2.0.0
+ *
+ * @param array|null $plugin Array of plugin arguments or null if invalid argument.
+ * @return null Return early if incorrect argument.
+ */
+ public function register( $plugin ) {
+ if ( empty( $plugin['slug'] ) || empty( $plugin['name'] ) ) {
+ return;
+ }
+
+ if ( empty( $plugin['slug'] ) || ! is_string( $plugin['slug'] ) || isset( $this->plugins[ $plugin['slug'] ] ) ) {
+ return;
+ }
+
+ $defaults = array(
+ 'name' => '', // String
+ 'slug' => '', // String
+ 'source' => 'repo', // String
+ 'required' => false, // Boolean
+ 'version' => '', // String
+ 'force_activation' => false, // Boolean
+ 'force_deactivation' => false, // Boolean
+ 'external_url' => '', // String
+ 'is_callable' => '', // String|Array.
+ );
+
+ // Prepare the received data.
+ $plugin = wp_parse_args( $plugin, $defaults );
+
+ // Standardize the received slug.
+ $plugin['slug'] = $this->sanitize_key( $plugin['slug'] );
+
+ // Forgive users for using string versions of booleans or floats for version number.
+ $plugin['version'] = (string) $plugin['version'];
+ $plugin['source'] = empty( $plugin['source'] ) ? 'repo' : $plugin['source'];
+ $plugin['required'] = TGMPA_Utils::validate_bool( $plugin['required'] );
+ $plugin['force_activation'] = TGMPA_Utils::validate_bool( $plugin['force_activation'] );
+ $plugin['force_deactivation'] = TGMPA_Utils::validate_bool( $plugin['force_deactivation'] );
+
+ // Enrich the received data.
+ $plugin['file_path'] = $this->_get_plugin_basename_from_slug( $plugin['slug'] );
+ $plugin['source_type'] = $this->get_plugin_source_type( $plugin['source'] );
+
+ // Set the class properties.
+ $this->plugins[ $plugin['slug'] ] = $plugin;
+ $this->sort_order[ $plugin['slug'] ] = $plugin['name'];
+
+ // Should we add the force activation hook ?
+ if ( true === $plugin['force_activation'] ) {
+ $this->has_forced_activation = true;
+ }
+
+ // Should we add the force deactivation hook ?
+ if ( true === $plugin['force_deactivation'] ) {
+ $this->has_forced_deactivation = true;
+ }
+ }
+
+ /**
+ * Determine what type of source the plugin comes from.
+ *
+ * @since 2.5.0
+ *
+ * @param string $source The source of the plugin as provided, either empty (= WP repo), a file path
+ * (= bundled) or an external URL.
+ * @return string 'repo', 'external', or 'bundled'
+ */
+ protected function get_plugin_source_type( $source ) {
+ if ( 'repo' === $source || preg_match( self::WP_REPO_REGEX, $source ) ) {
+ return 'repo';
+ } elseif ( preg_match( self::IS_URL_REGEX, $source ) ) {
+ return 'external';
+ } else {
+ return 'bundled';
+ }
+ }
+
+ /**
+ * Sanitizes a string key.
+ *
+ * Near duplicate of WP Core `sanitize_key()`. The difference is that uppercase characters *are*
+ * allowed, so as not to break upgrade paths from non-standard bundled plugins using uppercase
+ * characters in the plugin directory path/slug. Silly them.
+ *
+ * @see https://developer.wordpress.org/reference/hooks/sanitize_key/
+ *
+ * @since 2.5.0
+ *
+ * @param string $key String key.
+ * @return string Sanitized key
+ */
+ public function sanitize_key( $key ) {
+ $raw_key = $key;
+ $key = preg_replace( '`[^A-Za-z0-9_-]`', '', $key );
+
+ /**
+ * Filter a sanitized key string.
+ *
+ * @since 3.0.0
+ *
+ * @param string $key Sanitized key.
+ * @param string $raw_key The key prior to sanitization.
+ */
+ return apply_filters( 'tgmpa_sanitize_key', $key, $raw_key );
+ }
+
+ /**
+ * Amend default configuration settings.
+ *
+ * @since 2.0.0
+ *
+ * @param array $config Array of config options to pass as class properties.
+ */
+ public function config( $config ) {
+ $keys = array(
+ 'id',
+ 'default_path',
+ 'has_notices',
+ 'dismissable',
+ 'dismiss_msg',
+ 'menu',
+ 'parent_slug',
+ 'capability',
+ 'is_automatic',
+ 'message',
+ 'strings',
+ );
+
+ foreach ( $keys as $key ) {
+ if ( isset( $config[ $key ] ) ) {
+ if ( is_array( $config[ $key ] ) ) {
+ $this->$key = array_merge( $this->$key, $config[ $key ] );
+ } else {
+ $this->$key = $config[ $key ];
+ }
+ }
+ }
+ }
+
+ /**
+ * Amend action link after plugin installation.
+ *
+ * @since 2.0.0
+ *
+ * @param array $install_actions Existing array of actions.
+ * @return array Amended array of actions.
+ */
+ public function actions( $install_actions ) {
+ // Remove action links on the TGMPA install page.
+ if ( $this->is_tgmpa_page() ) {
+ return false;
+ }
+
+ return $install_actions;
+ }
+
+ /**
+ * Flushes the plugins cache on theme switch to prevent stale entries
+ * from remaining in the plugin table.
+ *
+ * @since 2.4.0
+ *
+ * @param bool $clear_update_cache Optional. Whether to clear the Plugin updates cache.
+ * Parameter added in v2.5.0.
+ */
+ public function flush_plugins_cache( $clear_update_cache = true ) {
+ wp_clean_plugins_cache( $clear_update_cache );
+ }
+
+ /**
+ * Set file_path key for each installed plugin.
+ *
+ * @since 2.1.0
+ *
+ * @param string $plugin_slug Optional. If set, only (re-)populates the file path for that specific plugin.
+ * Parameter added in v2.5.0.
+ */
+ public function populate_file_path( $plugin_slug = '' ) {
+ if ( ! empty( $plugin_slug ) && is_string( $plugin_slug ) && isset( $this->plugins[ $plugin_slug ] ) ) {
+ $this->plugins[ $plugin_slug ]['file_path'] = $this->_get_plugin_basename_from_slug( $plugin_slug );
+ } else {
+ // Add file_path key for all plugins.
+ foreach ( $this->plugins as $slug => $values ) {
+ $this->plugins[ $slug ]['file_path'] = $this->_get_plugin_basename_from_slug( $slug );
+ }
+ }
+ }
+
+ /**
+ * Helper function to extract the file path of the plugin file from the
+ * plugin slug, if the plugin is installed.
+ *
+ * @since 2.0.0
+ *
+ * @param string $slug Plugin slug (typically folder name) as provided by the developer.
+ * @return string Either file path for plugin if installed, or just the plugin slug.
+ */
+ protected function _get_plugin_basename_from_slug( $slug ) {
+ $keys = array_keys( $this->get_plugins() );
+
+ foreach ( $keys as $key ) {
+ if ( preg_match( '|^' . $slug . '/|', $key ) ) {
+ return $key;
+ }
+ }
+
+ return $slug;
+ }
+
+ /**
+ * Retrieve plugin data, given the plugin name.
+ *
+ * Loops through the registered plugins looking for $name. If it finds it,
+ * it returns the $data from that plugin. Otherwise, returns false.
+ *
+ * @since 2.1.0
+ *
+ * @param string $name Name of the plugin, as it was registered.
+ * @param string $data Optional. Array key of plugin data to return. Default is slug.
+ * @return string|boolean Plugin slug if found, false otherwise.
+ */
+ public function _get_plugin_data_from_name( $name, $data = 'slug' ) {
+ foreach ( $this->plugins as $values ) {
+ if ( $name === $values['name'] && isset( $values[ $data ] ) ) {
+ return $values[ $data ];
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Retrieve the download URL for a package.
+ *
+ * @since 2.5.0
+ *
+ * @param string $slug Plugin slug.
+ * @return string Plugin download URL or path to local file or empty string if undetermined.
+ */
+ public function get_download_url( $slug ) {
+ $dl_source = '';
+
+ switch ( $this->plugins[ $slug ]['source_type'] ) {
+ case 'repo':
+ return $this->get_wp_repo_download_url( $slug );
+ case 'external':
+ return $this->plugins[ $slug ]['source'];
+ case 'bundled':
+ return $this->default_path . $this->plugins[ $slug ]['source'];
+ }
+
+ return $dl_source; // Should never happen.
+ }
+
+ /**
+ * Retrieve the download URL for a WP repo package.
+ *
+ * @since 2.5.0
+ *
+ * @param string $slug Plugin slug.
+ * @return string Plugin download URL.
+ */
+ protected function get_wp_repo_download_url( $slug ) {
+ $source = '';
+ $api = $this->get_plugins_api( $slug );
+
+ if ( false !== $api && isset( $api->download_link ) ) {
+ $source = $api->download_link;
+ }
+
+ return $source;
+ }
+
+ /**
+ * Try to grab information from WordPress API.
+ *
+ * @since 2.5.0
+ *
+ * @param string $slug Plugin slug.
+ * @return object Plugins_api response object on success, WP_Error on failure.
+ */
+ protected function get_plugins_api( $slug ) {
+ static $api = array(); // Cache received responses.
+
+ if ( ! isset( $api[ $slug ] ) ) {
+ if ( ! function_exists( 'plugins_api' ) ) {
+ require_once ABSPATH . 'wp-admin/includes/plugin-install.php';
+ }
+
+ $response = plugins_api( 'plugin_information', array( 'slug' => $slug, 'fields' => array( 'sections' => false ) ) );
+
+ $api[ $slug ] = false;
+
+ if ( is_wp_error( $response ) ) {
+ wp_die( esc_html( $this->strings['oops'] ) );
+ } else {
+ $api[ $slug ] = $response;
+ }
+ }
+
+ return $api[ $slug ];
+ }
+
+ /**
+ * Retrieve a link to a plugin information page.
+ *
+ * @since 2.5.0
+ *
+ * @param string $slug Plugin slug.
+ * @return string Fully formed html link to a plugin information page if available
+ * or the plugin name if not.
+ */
+ public function get_info_link( $slug ) {
+ if ( ! empty( $this->plugins[ $slug ]['external_url'] ) && preg_match( self::IS_URL_REGEX, $this->plugins[ $slug ]['external_url'] ) ) {
+ $link = sprintf(
+ '<a href="%1$s" target="_blank">%2$s</a>',
+ esc_url( $this->plugins[ $slug ]['external_url'] ),
+ esc_html( $this->plugins[ $slug ]['name'] )
+ );
+ } elseif ( 'repo' === $this->plugins[ $slug ]['source_type'] ) {
+ $url = add_query_arg(
+ array(
+ 'tab' => 'plugin-information',
+ 'plugin' => urlencode( $slug ),
+ 'TB_iframe' => 'true',
+ 'width' => '640',
+ 'height' => '500',
+ ),
+ self_admin_url( 'plugin-install.php' )
+ );
+
+ $link = sprintf(
+ '<a href="%1$s" class="thickbox">%2$s</a>',
+ esc_url( $url ),
+ esc_html( $this->plugins[ $slug ]['name'] )
+ );
+ } else {
+ $link = esc_html( $this->plugins[ $slug ]['name'] ); // No hyperlink.
+ }
+
+ return $link;
+ }
+
+ /**
+ * Determine if we're on the TGMPA Install page.
+ *
+ * @since 2.1.0
+ *
+ * @return boolean True when on the TGMPA page, false otherwise.
+ */
+ protected function is_tgmpa_page() {
+ return isset( $_GET['page'] ) && $this->menu === $_GET['page'];
+ }
+
+ /**
+ * Retrieve the URL to the TGMPA Install page.
+ *
+ * I.e. depending on the config settings passed something along the lines of:
+ * http://example.com/wp-admin/themes.php?page=tgmpa-install-plugins
+ *
+ * @since 2.5.0
+ *
+ * @return string Properly encoded URL (not escaped).
+ */
+ public function get_tgmpa_url() {
+ static $url;
+
+ if ( ! isset( $url ) ) {
+ $parent = $this->parent_slug;
+ if ( false === strpos( $parent, '.php' ) ) {
+ $parent = 'admin.php';
+ }
+ $url = add_query_arg(
+ array(
+ 'page' => urlencode( $this->menu ),
+ ),
+ self_admin_url( $parent )
+ );
+ }
+
+ return $url;
+ }
+
+ /**
+ * Retrieve the URL to the TGMPA Install page for a specific plugin status (view).
+ *
+ * I.e. depending on the config settings passed something along the lines of:
+ * http://example.com/wp-admin/themes.php?page=tgmpa-install-plugins&plugin_status=install
+ *
+ * @since 2.5.0
+ *
+ * @param string $status Plugin status - either 'install', 'update' or 'activate'.
+ * @return string Properly encoded URL (not escaped).
+ */
+ public function get_tgmpa_status_url( $status ) {
+ return add_query_arg(
+ array(
+ 'plugin_status' => urlencode( $status ),
+ ),
+ $this->get_tgmpa_url()
+ );
+ }
+
+ /**
+ * Determine whether there are open actions for plugins registered with TGMPA.
+ *
+ * @since 2.5.0
+ *
+ * @return bool True if complete, i.e. no outstanding actions. False otherwise.
+ */
+ public function is_tgmpa_complete() {
+ $complete = true;
+ foreach ( $this->plugins as $slug => $plugin ) {
+ if ( ! $this->is_plugin_active( $slug ) || false !== $this->does_plugin_have_update( $slug ) ) {
+ $complete = false;
+ break;
+ }
+ }
+
+ return $complete;
+ }
+
+ /**
+ * Check if a plugin is installed. Does not take must-use plugins into account.
+ *
+ * @since 2.5.0
+ *
+ * @param string $slug Plugin slug.
+ * @return bool True if installed, false otherwise.
+ */
+ public function is_plugin_installed( $slug ) {
+ $installed_plugins = $this->get_plugins(); // Retrieve a list of all installed plugins (WP cached).
+
+ return ( ! empty( $installed_plugins[ $this->plugins[ $slug ]['file_path'] ] ) );
+ }
+
+ /**
+ * Check if a plugin is active.
+ *
+ * @since 2.5.0
+ *
+ * @param string $slug Plugin slug.
+ * @return bool True if active, false otherwise.
+ */
+ public function is_plugin_active( $slug ) {
+ return ( ( ! empty( $this->plugins[ $slug ]['is_callable'] ) && is_callable( $this->plugins[ $slug ]['is_callable'] ) ) || is_plugin_active( $this->plugins[ $slug ]['file_path'] ) );
+ }
+
+ /**
+ * Check if a plugin can be updated, i.e. if we have information on the minimum WP version required
+ * available, check whether the current install meets them.
+ *
+ * @since 2.5.0
+ *
+ * @param string $slug Plugin slug.
+ * @return bool True if OK to update, false otherwise.
+ */
+ public function can_plugin_update( $slug ) {
+ // We currently can't get reliable info on non-WP-repo plugins - issue #380.
+ if ( 'repo' !== $this->plugins[ $slug ]['source_type'] ) {
+ return true;
+ }
+
+ $api = $this->get_plugins_api( $slug );
+
+ if ( false !== $api && isset( $api->requires ) ) {
+ return version_compare( $GLOBALS['wp_version'], $api->requires, '>=' );
+ }
+
+ // No usable info received from the plugins API, presume we can update.
+ return true;
+ }
+
+ /**
+ * Check if a plugin can be activated, i.e. is not currently active and meets the minimum
+ * plugin version requirements set in TGMPA (if any).
+ *
+ * @since 2.5.0
+ *
+ * @param string $slug Plugin slug.
+ * @return bool True if OK to activate, false otherwise.
+ */
+ public function can_plugin_activate( $slug ) {
+ return ( ! $this->is_plugin_active( $slug ) && ! $this->does_plugin_require_update( $slug ) );
+ }
+
+ /**
+ * Retrieve the version number of an installed plugin.
+ *
+ * @since 2.5.0
+ *
+ * @param string $slug Plugin slug.
+ * @return string Version number as string or an empty string if the plugin is not installed
+ * or version unknown (plugins which don't comply with the plugin header standard).
+ */
+ public function get_installed_version( $slug ) {
+ $installed_plugins = $this->get_plugins(); // Retrieve a list of all installed plugins (WP cached).
+
+ if ( ! empty( $installed_plugins[ $this->plugins[ $slug ]['file_path'] ]['Version'] ) ) {
+ return $installed_plugins[ $this->plugins[ $slug ]['file_path'] ]['Version'];
+ }
+
+ return '';
+ }
+
+ /**
+ * Check whether a plugin complies with the minimum version requirements.
+ *
+ * @since 2.5.0
+ *
+ * @param string $slug Plugin slug.
+ * @return bool True when a plugin needs to be updated, otherwise false.
+ */
+ public function does_plugin_require_update( $slug ) {
+ $installed_version = $this->get_installed_version( $slug );
+ $minimum_version = $this->plugins[ $slug ]['version'];
+
+ return version_compare( $minimum_version, $installed_version, '>' );
+ }
+
+ /**
+ * Check whether there is an update available for a plugin.
+ *
+ * @since 2.5.0
+ *
+ * @param string $slug Plugin slug.
+ * @return false|string Version number string of the available update or false if no update available.
+ */
+ public function does_plugin_have_update( $slug ) {
+ // Presume bundled and external plugins will point to a package which meets the minimum required version.
+ if ( 'repo' !== $this->plugins[ $slug ]['source_type'] ) {
+ if ( $this->does_plugin_require_update( $slug ) ) {
+ return $this->plugins[ $slug ]['version'];
+ }
+
+ return false;
+ }
+
+ $repo_updates = get_site_transient( 'update_plugins' );
+
+ if ( isset( $repo_updates->response[ $this->plugins[ $slug ]['file_path'] ]->new_version ) ) {
+ return $repo_updates->response[ $this->plugins[ $slug ]['file_path'] ]->new_version;
+ }
+
+ return false;
+ }
+
+ /**
+ * Retrieve potential upgrade notice for a plugin.
+ *
+ * @since 2.5.0
+ *
+ * @param string $slug Plugin slug.
+ * @return string The upgrade notice or an empty string if no message was available or provided.
+ */
+ public function get_upgrade_notice( $slug ) {
+ // We currently can't get reliable info on non-WP-repo plugins - issue #380.
+ if ( 'repo' !== $this->plugins[ $slug ]['source_type'] ) {
+ return '';
+ }
+
+ $repo_updates = get_site_transient( 'update_plugins' );
+
+ if ( ! empty( $repo_updates->response[ $this->plugins[ $slug ]['file_path'] ]->upgrade_notice ) ) {
+ return $repo_updates->response[ $this->plugins[ $slug ]['file_path'] ]->upgrade_notice;
+ }
+
+ return '';
+ }
+
+ /**
+ * Wrapper around the core WP get_plugins function, making sure it's actually available.
+ *
+ * @since 2.5.0
+ *
+ * @param string $plugin_folder Optional. Relative path to single plugin folder.
+ * @return array Array of installed plugins with plugin information.
+ */
+ public function get_plugins( $plugin_folder = '' ) {
+ if ( ! function_exists( 'get_plugins' ) ) {
+ require_once ABSPATH . 'wp-admin/includes/plugin.php';
+ }
+
+ return get_plugins( $plugin_folder );
+ }
+
+ /**
+ * Delete dismissable nag option when theme is switched.
+ *
+ * This ensures that the user(s) is/are again reminded via nag of required
+ * and/or recommended plugins if they re-activate the theme.
+ *
+ * @since 2.1.1
+ */
+ public function update_dismiss() {
+ delete_metadata( 'user', null, 'tgmpa_dismissed_notice_' . $this->id, null, true );
+ }
+
+ /**
+ * Forces plugin activation if the parameter 'force_activation' is
+ * set to true.
+ *
+ * This allows theme authors to specify certain plugins that must be
+ * active at all times while using the current theme.
+ *
+ * Please take special care when using this parameter as it has the
+ * potential to be harmful if not used correctly. Setting this parameter
+ * to true will not allow the specified plugin to be deactivated unless
+ * the user switches themes.
+ *
+ * @since 2.2.0
+ */
+ public function force_activation() {
+ foreach ( $this->plugins as $slug => $plugin ) {
+ if ( true === $plugin['force_activation'] ) {
+ if ( ! $this->is_plugin_installed( $slug ) ) {
+ // Oops, plugin isn't there so iterate to next condition.
+ continue;
+ } elseif ( $this->can_plugin_activate( $slug ) ) {
+ // There we go, activate the plugin.
+ activate_plugin( $plugin['file_path'] );
+ }
+ }
+ }
+ }
+
+ /**
+ * Forces plugin deactivation if the parameter 'force_deactivation'
+ * is set to true.
+ *
+ * This allows theme authors to specify certain plugins that must be
+ * deactivated upon switching from the current theme to another.
+ *
+ * Please take special care when using this parameter as it has the
+ * potential to be harmful if not used correctly.
+ *
+ * @since 2.2.0
+ */
+ public function force_deactivation() {
+ foreach ( $this->plugins as $slug => $plugin ) {
+ // Only proceed forward if the parameter is set to true and plugin is active.
+ if ( true === $plugin['force_deactivation'] && $this->is_plugin_active( $slug ) ) {
+ deactivate_plugins( $plugin['file_path'] );
+ }
+ }
+ }
+
+ /**
+ * Echo the current TGMPA version number to the page.
+ */
+ public function show_tgmpa_version() {
+ echo '<p style="float: right; padding: 0em 1.5em 0.5em 0;"><strong><small>',
+ esc_html( sprintf( _x( 'TGMPA v%s', '%s = version number', 'cryout' ), self::TGMPA_VERSION ) ),
+ '</small></strong></p>';
+ }
+
+ /**
+ * Returns the singleton instance of the class.
+ *
+ * @since 2.4.0
+ *
+ * @return object The TGM_Plugin_Activation object.
+ */
+ public static function get_instance() {
+ if ( ! isset( self::$instance ) && ! ( self::$instance instanceof self ) ) {
+ self::$instance = new self();
+ }
+
+ return self::$instance;
+ }
+ }
+
+ if ( ! function_exists( 'load_tgm_plugin_activation' ) ) {
+ /**
+ * Ensure only one instance of the class is ever invoked.
+ */
+ function load_tgm_plugin_activation() {
+ $GLOBALS['tgmpa'] = TGM_Plugin_Activation::get_instance();
+ }
+ }
+
+ if ( did_action( 'plugins_loaded' ) ) {
+ load_tgm_plugin_activation();
+ } else {
+ add_action( 'plugins_loaded', 'load_tgm_plugin_activation' );
+ }
+}
+
+if ( ! function_exists( 'tgmpa' ) ) {
+ /**
+ * Helper function to register a collection of required plugins.
+ *
+ * @since 2.0.0
+ * @api
+ *
+ * @param array $plugins An array of plugin arrays.
+ * @param array $config Optional. An array of configuration values.
+ */
+ function tgmpa( $plugins, $config = array() ) {
+ $instance = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) );
+
+ foreach ( $plugins as $plugin ) {
+ call_user_func( array( $instance, 'register' ), $plugin );
+ }
+
+ if ( ! empty( $config ) && is_array( $config ) ) {
+ // Send out notices for deprecated arguments passed.
+ if ( isset( $config['notices'] ) ) {
+ _deprecated_argument( __FUNCTION__, '2.2.0', 'The `notices` config parameter was renamed to `has_notices` in TGMPA 2.2.0. Please adjust your configuration.' );
+ if ( ! isset( $config['has_notices'] ) ) {
+ $config['has_notices'] = $config['notices'];
+ }
+ }
+
+ if ( isset( $config['parent_menu_slug'] ) ) {
+ _deprecated_argument( __FUNCTION__, '2.4.0', 'The `parent_menu_slug` config parameter was removed in TGMPA 2.4.0. In TGMPA 2.5.0 an alternative was (re-)introduced. Please adjust your configuration. For more information visit the website: http://tgmpluginactivation.com/configuration/#h-configuration-options.' );
+ }
+ if ( isset( $config['parent_url_slug'] ) ) {
+ _deprecated_argument( __FUNCTION__, '2.4.0', 'The `parent_url_slug` config parameter was removed in TGMPA 2.4.0. In TGMPA 2.5.0 an alternative was (re-)introduced. Please adjust your configuration. For more information visit the website: http://tgmpluginactivation.com/configuration/#h-configuration-options.' );
+ }
+
+ call_user_func( array( $instance, 'config' ), $config );
+ }
+ }
+}
+
+/**
+ * WP_List_Table isn't always available. If it isn't available,
+ * we load it here.
+ *
+ * @since 2.2.0
+ */
+if ( ! class_exists( 'WP_List_Table' ) ) {
+ require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
+}
+
+if ( ! class_exists( 'TGMPA_List_Table' ) ) {
+
+ /**
+ * List table class for handling plugins.
+ *
+ * Extends the WP_List_Table class to provide a future-compatible
+ * way of listing out all required/recommended plugins.
+ *
+ * Gives users an interface similar to the Plugin Administration
+ * area with similar (albeit stripped down) capabilities.
+ *
+ * This class also allows for the bulk install of plugins.
+ *
+ * @since 2.2.0
+ *
+ * @package TGM-Plugin-Activation
+ * @author Thomas Griffin
+ * @author Gary Jones
+ */
+ class TGMPA_List_Table extends WP_List_Table {
+ /**
+ * TGMPA instance.
+ *
+ * @since 2.5.0
+ *
+ * @var object
+ */
+ protected $tgmpa;
+
+ /**
+ * The currently chosen view.
+ *
+ * @since 2.5.0
+ *
+ * @var string One of: 'all', 'install', 'update', 'activate'
+ */
+ public $view_context = 'all';
+
+ /**
+ * The plugin counts for the various views.
+ *
+ * @since 2.5.0
+ *
+ * @var array
+ */
+ protected $view_totals = array(
+ 'all' => 0,
+ 'install' => 0,
+ 'update' => 0,
+ 'activate' => 0,
+ );
+
+ /**
+ * References parent constructor and sets defaults for class.
+ *
+ * @since 2.2.0
+ */
+ public function __construct() {
+ $this->tgmpa = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) );
+
+ parent::__construct(
+ array(
+ 'singular' => 'plugin',
+ 'plural' => 'plugins',
+ 'ajax' => false,
+ )
+ );
+
+ if ( isset( $_REQUEST['plugin_status'] ) && in_array( $_REQUEST['plugin_status'], array( 'install', 'update', 'activate' ), true ) ) {
+ $this->view_context = sanitize_key( $_REQUEST['plugin_status'] );
+ }
+
+ add_filter( 'tgmpa_table_data_items', array( $this, 'sort_table_items' ) );
+ }
+
+ /**
+ * Get a list of CSS classes for the <table> tag.
+ *
+ * Overruled to prevent the 'plural' argument from being added.
+ *
+ * @since 2.5.0
+ *
+ * @return array CSS classnames.
+ */
+ public function get_table_classes() {
+ return array( 'widefat', 'fixed' );
+ }
+
+ /**
+ * Gathers and renames all of our plugin information to be used by WP_List_Table to create our table.
+ *
+ * @since 2.2.0
+ *
+ * @return array $table_data Information for use in table.
+ */
+ protected function _gather_plugin_data() {
+ // Load thickbox for plugin links.
+ $this->tgmpa->admin_init();
+ $this->tgmpa->thickbox();
+
+ // Categorize the plugins which have open actions.
+ $plugins = $this->categorize_plugins_to_views();
+
+ // Set the counts for the view links.
+ $this->set_view_totals( $plugins );
+
+ // Prep variables for use and grab list of all installed plugins.
+ $table_data = array();
+ $i = 0;
+
+ // Redirect to the 'all' view if no plugins were found for the selected view context.
+ if ( empty( $plugins[ $this->view_context ] ) ) {
+ $this->view_context = 'all';
+ }
+
+ foreach ( $plugins[ $this->view_context ] as $slug => $plugin ) {
+ $table_data[ $i ]['sanitized_plugin'] = $plugin['name'];
+ $table_data[ $i ]['slug'] = $slug;
+ $table_data[ $i ]['plugin'] = '<strong>' . $this->tgmpa->get_info_link( $slug ) . '</strong>';
+ $table_data[ $i ]['source'] = $this->get_plugin_source_type_text( $plugin['source_type'] );
+ $table_data[ $i ]['type'] = $this->get_plugin_advise_type_text( $plugin['required'] );
+ $table_data[ $i ]['status'] = $this->get_plugin_status_text( $slug );
+ $table_data[ $i ]['installed_version'] = $this->tgmpa->get_installed_version( $slug );
+ $table_data[ $i ]['minimum_version'] = $plugin['version'];
+ $table_data[ $i ]['available_version'] = $this->tgmpa->does_plugin_have_update( $slug );
+
+ // Prep the upgrade notice info.
+ $upgrade_notice = $this->tgmpa->get_upgrade_notice( $slug );
+ if ( ! empty( $upgrade_notice ) ) {
+ $table_data[ $i ]['upgrade_notice'] = $upgrade_notice;
+
+ add_action( "tgmpa_after_plugin_row_$slug", array( $this, 'wp_plugin_update_row' ), 10, 2 );
+ }
+
+ $table_data[ $i ] = apply_filters( 'tgmpa_table_data_item', $table_data[ $i ], $plugin );
+
+ $i++;
+ }
+
+ return $table_data;
+ }
+
+ /**
+ * Categorize the plugins which have open actions into views for the TGMPA page.
+ *
+ * @since 2.5.0
+ */
+ protected function categorize_plugins_to_views() {
+ $plugins = array(
+ 'all' => array(), // Meaning: all plugins which still have open actions.
+ 'install' => array(),
+ 'update' => array(),
+ 'activate' => array(),
+ );
+
+ foreach ( $this->tgmpa->plugins as $slug => $plugin ) {
+ if ( $this->tgmpa->is_plugin_active( $slug ) && false === $this->tgmpa->does_plugin_have_update( $slug ) ) {
+ // No need to display plugins if they are installed, up-to-date and active.
+ continue;
+ } else {
+ $plugins['all'][ $slug ] = $plugin;
+
+ if ( ! $this->tgmpa->is_plugin_installed( $slug ) ) {
+ $plugins['install'][ $slug ] = $plugin;
+ } else {
+ if ( false !== $this->tgmpa->does_plugin_have_update( $slug ) ) {
+ $plugins['update'][ $slug ] = $plugin;
+ }
+
+ if ( $this->tgmpa->can_plugin_activate( $slug ) ) {
+ $plugins['activate'][ $slug ] = $plugin;
+ }
+ }
+ }
+ }
+
+ return $plugins;
+ }
+
+ /**
+ * Set the counts for the view links.
+ *
+ * @since 2.5.0
+ *
+ * @param array $plugins Plugins order by view.
+ */
+ protected function set_view_totals( $plugins ) {
+ foreach ( $plugins as $type => $list ) {
+ $this->view_totals[ $type ] = count( $list );
+ }
+ }
+
+ /**
+ * Get the plugin required/recommended text string.
+ *
+ * @since 2.5.0
+ *
+ * @param string $required Plugin required setting.
+ * @return string
+ */
+ protected function get_plugin_advise_type_text( $required ) {
+ if ( true === $required ) {
+ return __( 'Required', 'cryout' );
+ }
+
+ return __( 'Recommended', 'cryout' );
+ }
+
+ /**
+ * Get the plugin source type text string.
+ *
+ * @since 2.5.0
+ *
+ * @param string $type Plugin type.
+ * @return string
+ */
+ protected function get_plugin_source_type_text( $type ) {
+ $string = '';
+
+ switch ( $type ) {
+ case 'repo':
+ $string = __( 'WordPress Repository', 'cryout' );
+ break;
+ case 'external':
+ $string = __( 'External Source', 'cryout' );
+ break;
+ case 'bundled':
+ $string = __( 'Pre-Packaged', 'cryout' );
+ break;
+ }
+
+ return $string;
+ }
+
+ /**
+ * Determine the plugin status message.
+ *
+ * @since 2.5.0
+ *
+ * @param string $slug Plugin slug.
+ * @return string
+ */
+ protected function get_plugin_status_text( $slug ) {
+ if ( ! $this->tgmpa->is_plugin_installed( $slug ) ) {
+ return __( 'Not Installed', 'cryout' );
+ }
+
+ if ( ! $this->tgmpa->is_plugin_active( $slug ) ) {
+ $install_status = __( 'Installed But Not Activated', 'cryout' );
+ } else {
+ $install_status = __( 'Active', 'cryout' );
+ }
+
+ $update_status = '';
+
+ if ( $this->tgmpa->does_plugin_require_update( $slug ) && false === $this->tgmpa->does_plugin_have_update( $slug ) ) {
+ $update_status = __( 'Required Update not Available', 'cryout' );
+
+ } elseif ( $this->tgmpa->does_plugin_require_update( $slug ) ) {
+ $update_status = __( 'Requires Update', 'cryout' );
+
+ } elseif ( false !== $this->tgmpa->does_plugin_have_update( $slug ) ) {
+ $update_status = __( 'Update recommended', 'cryout' );
+ }
+
+ if ( '' === $update_status ) {
+ return $install_status;
+ }
+
+ return sprintf(
+ _x( '%1$s, %2$s', '%1$s = install status, %2$s = update status', 'cryout' ),
+ $install_status,
+ $update_status
+ );
+ }
+
+ /**
+ * Sort plugins by Required/Recommended type and by alphabetical plugin name within each type.
+ *
+ * @since 2.5.0
+ *
+ * @param array $items Prepared table items.
+ * @return array Sorted table items.
+ */
+ public function sort_table_items( $items ) {
+ $type = array();
+ $name = array();
+
+ foreach ( $items as $i => $plugin ) {
+ $type[ $i ] = $plugin['type']; // Required / recommended.
+ $name[ $i ] = $plugin['sanitized_plugin'];
+ }
+
+ array_multisort( $type, SORT_DESC, $name, SORT_ASC, $items );
+
+ return $items;
+ }
+
+ /**
+ * Get an associative array ( id => link ) of the views available on this table.
+ *
+ * @since 2.5.0
+ *
+ * @return array
+ */
+ public function get_views() {
+ $status_links = array();
+
+ foreach ( $this->view_totals as $type => $count ) {
+ if ( $count < 1 ) {
+ continue;
+ }
+
+ switch ( $type ) {
+ case 'all':
+ $text = _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $count, 'plugins', 'cryout' );
+ break;
+ case 'install':
+ $text = _n( 'To Install <span class="count">(%s)</span>', 'To Install <span class="count">(%s)</span>', $count, 'cryout' );
+ break;
+ case 'update':
+ $text = _n( 'Update Available <span class="count">(%s)</span>', 'Update Available <span class="count">(%s)</span>', $count, 'cryout' );
+ break;
+ case 'activate':
+ $text = _n( 'To Activate <span class="count">(%s)</span>', 'To Activate <span class="count">(%s)</span>', $count, 'cryout' );
+ break;
+ default:
+ $text = '';
+ break;
+ }
+
+ if ( ! empty( $text ) ) {
+
+ $status_links[ $type ] = sprintf(
+ '<a href="%s"%s>%s</a>',
+ esc_url( $this->tgmpa->get_tgmpa_status_url( $type ) ),
+ ( $type === $this->view_context ) ? ' class="current"' : '',
+ sprintf( $text, number_format_i18n( $count ) )
+ );
+ }
+ }
+
+ return $status_links;
+ }
+
+ /**
+ * Create default columns to display important plugin information
+ * like type, action and status.
+ *
+ * @since 2.2.0
+ *
+ * @param array $item Array of item data.
+ * @param string $column_name The name of the column.
+ * @return string
+ */
+ public function column_default( $item, $column_name ) {
+ return $item[ $column_name ];
+ }
+
+ /**
+ * Required for bulk installing.
+ *
+ * Adds a checkbox for each plugin.
+ *
+ * @since 2.2.0
+ *
+ * @param array $item Array of item data.
+ * @return string The input checkbox with all necessary info.
+ */
+ public function column_cb( $item ) {
+ return sprintf(
+ '<input type="checkbox" name="%1$s[]" value="%2$s" id="%3$s" />',
+ esc_attr( $this->_args['singular'] ),
+ esc_attr( $item['slug'] ),
+ esc_attr( $item['sanitized_plugin'] )
+ );
+ }
+
+ /**
+ * Create default title column along with the action links.
+ *
+ * @since 2.2.0
+ *
+ * @param array $item Array of item data.
+ * @return string The plugin name and action links.
+ */
+ public function column_plugin( $item ) {
+ return sprintf(
+ '%1$s %2$s',
+ $item['plugin'],
+ $this->row_actions( $this->get_row_actions( $item ), true )
+ );
+ }
+
+ /**
+ * Create version information column.
+ *
+ * @since 2.5.0
+ *
+ * @param array $item Array of item data.
+ * @return string HTML-formatted version information.
+ */
+ public function column_version( $item ) {
+ $output = array();
+
+ if ( $this->tgmpa->is_plugin_installed( $item['slug'] ) ) {
+ $installed = ! empty( $item['installed_version'] ) ? $item['installed_version'] : _x( 'unknown', 'as in: "version nr unknown"', 'cryout' );
+
+ $color = '';
+ if ( ! empty( $item['minimum_version'] ) && $this->tgmpa->does_plugin_require_update( $item['slug'] ) ) {
+ $color = ' color: #ff0000; font-weight: bold;';
+ }
+
+ $output[] = sprintf(
+ '<p><span style="min-width: 32px; text-align: right; float: right;%1$s">%2$s</span>' . __( 'Installed version:', 'cryout' ) . '</p>',
+ $color,
+ $installed
+ );
+ }
+
+ if ( ! empty( $item['minimum_version'] ) ) {
+ $output[] = sprintf(
+ '<p><span style="min-width: 32px; text-align: right; float: right;">%1$s</span>' . __( 'Minimum required version:', 'cryout' ) . '</p>',
+ $item['minimum_version']
+ );
+ }
+
+ if ( ! empty( $item['available_version'] ) ) {
+ $color = '';
+ if ( ! empty( $item['minimum_version'] ) && version_compare( $item['available_version'], $item['minimum_version'], '>=' ) ) {
+ $color = ' color: #71C671; font-weight: bold;';
+ }
+
+ $output[] = sprintf(
+ '<p><span style="min-width: 32px; text-align: right; float: right;%1$s">%2$s</span>' . __( 'Available version:', 'cryout' ) . '</p>',
+ $color,
+ $item['available_version']
+ );
+ }
+
+ if ( empty( $output ) ) {
+ return '&nbsp;'; // Let's not break the table layout.
+ } else {
+ return implode( "\n", $output );
+ }
+ }
+
+ /**
+ * Sets default message within the plugins table if no plugins
+ * are left for interaction.
+ *
+ * Hides the menu item to prevent the user from clicking and
+ * getting a permissions error.
+ *
+ * @since 2.2.0
+ */
+ public function no_items() {
+ printf( wp_kses_post( __( 'No plugins to install, update or activate. <a href="%1$s">Return to the Dashboard</a>', 'cryout' ) ), esc_url( self_admin_url() ) );
+ echo '<style type="text/css">#adminmenu .wp-submenu li.current { display: none !important; }</style>';
+ }
+
+ /**
+ * Output all the column information within the table.
+ *
+ * @since 2.2.0
+ *
+ * @return array $columns The column names.
+ */
+ public function get_columns() {
+ $columns = array(
+ 'cb' => '<input type="checkbox" />',
+ 'plugin' => __( 'Plugin', 'cryout' ),
+ 'source' => __( 'Source', 'cryout' ),
+ 'type' => __( 'Type', 'cryout' ),
+ );
+
+ if ( 'all' === $this->view_context || 'update' === $this->view_context ) {
+ $columns['version'] = __( 'Version', 'cryout' );
+ $columns['status'] = __( 'Status', 'cryout' );
+ }
+
+ return apply_filters( 'tgmpa_table_columns', $columns );
+ }
+
+ /**
+ * Get name of default primary column
+ *
+ * @since 2.5.0 / WP 4.3+ compatibility
+ * @access protected
+ *
+ * @return string
+ */
+ protected function get_default_primary_column_name() {
+ return 'plugin';
+ }
+
+ /**
+ * Get the name of the primary column.
+ *
+ * @since 2.5.0 / WP 4.3+ compatibility
+ * @access protected
+ *
+ * @return string The name of the primary column.
+ */
+ protected function get_primary_column_name() {
+ if ( method_exists( 'WP_List_Table', 'get_primary_column_name' ) ) {
+ return parent::get_primary_column_name();
+ } else {
+ return $this->get_default_primary_column_name();
+ }
+ }
+
+ /**
+ * Get the actions which are relevant for a specific plugin row.
+ *
+ * @since 2.5.0
+ *
+ * @param array $item Array of item data.
+ * @return array Array with relevant action links.
+ */
+ protected function get_row_actions( $item ) {
+ $actions = array();
+ $action_links = array();
+
+ // Display the 'Install' action link if the plugin is not yet available.
+ if ( ! $this->tgmpa->is_plugin_installed( $item['slug'] ) ) {
+ $actions['install'] = _x( 'Install %2$s', '%2$s = plugin name in screen reader markup', 'cryout' );
+ } else {
+ // Display the 'Update' action link if an update is available and WP complies with plugin minimum.
+ if ( false !== $this->tgmpa->does_plugin_have_update( $item['slug'] ) && $this->tgmpa->can_plugin_update( $item['slug'] ) ) {
+ $actions['update'] = _x( 'Update %2$s', '%2$s = plugin name in screen reader markup', 'cryout' );
+ }
+
+ // Display the 'Activate' action link, but only if the plugin meets the minimum version.
+ if ( $this->tgmpa->can_plugin_activate( $item['slug'] ) ) {
+ $actions['activate'] = _x( 'Activate %2$s', '%2$s = plugin name in screen reader markup', 'cryout' );
+ }
+ }
+
+ // Create the actual links.
+ foreach ( $actions as $action => $text ) {
+ $nonce_url = wp_nonce_url(
+ add_query_arg(
+ array(
+ 'plugin' => urlencode( $item['slug'] ),
+ 'tgmpa-' . $action => $action . '-plugin',
+ ),
+ $this->tgmpa->get_tgmpa_url()
+ ),
+ 'tgmpa-' . $action,
+ 'tgmpa-nonce'
+ );
+
+ $action_links[ $action ] = sprintf(
+ '<a href="%1$s">' . esc_html( $text ) . '</a>',
+ esc_url( $nonce_url ),
+ '<span class="screen-reader-text">' . esc_html( $item['sanitized_plugin'] ) . '</span>'
+ );
+ }
+
+ $prefix = ( defined( 'WP_NETWORK_ADMIN' ) && WP_NETWORK_ADMIN ) ? 'network_admin_' : '';
+ return apply_filters( "tgmpa_{$prefix}plugin_action_links", array_filter( $action_links ), $item['slug'], $item, $this->view_context );
+ }
+
+ /**
+ * Generates content for a single row of the table.
+ *
+ * @since 2.5.0
+ *
+ * @param object $item The current item.
+ */
+ public function single_row( $item ) {
+ parent::single_row( $item );
+
+ /**
+ * Fires after each specific row in the TGMPA Plugins list table.
+ *
+ * The dynamic portion of the hook name, `$item['slug']`, refers to the slug
+ * for the plugin.
+ *
+ * @since 2.5.0
+ */
+ do_action( "tgmpa_after_plugin_row_{$item['slug']}", $item['slug'], $item, $this->view_context );
+ }
+
+ /**
+ * Show the upgrade notice below a plugin row if there is one.
+ *
+ * @since 2.5.0
+ *
+ * @see /wp-admin/includes/update.php
+ *
+ * @param string $slug Plugin slug.
+ * @param array $item The information available in this table row.
+ * @return null Return early if upgrade notice is empty.
+ */
+ public function wp_plugin_update_row( $slug, $item ) {
+ if ( empty( $item['upgrade_notice'] ) ) {
+ return;
+ }
+
+ echo '
+ <tr class="plugin-update-tr">
+ <td colspan="', absint( $this->get_column_count() ), '" class="plugin-update colspanchange">
+ <div class="update-message">',
+ esc_html__( 'Upgrade message from the plugin author:', 'cryout' ),
+ ' <strong>', wp_kses_data( $item['upgrade_notice'] ), '</strong>
+ </div>
+ </td>
+ </tr>';
+ }
+
+ /**
+ * Extra controls to be displayed between bulk actions and pagination.
+ *
+ * @since 2.5.0
+ *
+ * @param string $which 'top' or 'bottom' table navigation.
+ */
+ public function extra_tablenav( $which ) {
+ if ( 'bottom' === $which ) {
+ $this->tgmpa->show_tgmpa_version();
+ }
+ }
+
+ /**
+ * Defines the bulk actions for handling registered plugins.
+ *
+ * @since 2.2.0
+ *
+ * @return array $actions The bulk actions for the plugin install table.
+ */
+ public function get_bulk_actions() {
+
+ $actions = array();
+
+ if ( 'update' !== $this->view_context && 'activate' !== $this->view_context ) {
+ if ( current_user_can( 'install_plugins' ) ) {
+ $actions['tgmpa-bulk-install'] = __( 'Install', 'cryout' );
+ }
+ }
+
+ if ( 'install' !== $this->view_context ) {
+ if ( current_user_can( 'update_plugins' ) ) {
+ $actions['tgmpa-bulk-update'] = __( 'Update', 'cryout' );
+ }
+ if ( current_user_can( 'activate_plugins' ) ) {
+ $actions['tgmpa-bulk-activate'] = __( 'Activate', 'cryout' );
+ }
+ }
+
+ return $actions;
+ }
+
+ /**
+ * Processes bulk installation and activation actions.
+ *
+ * The bulk installation process looks for the $_POST information and passes that
+ * through if a user has to use WP_Filesystem to enter their credentials.
+ *
+ * @since 2.2.0
+ */
+ public function process_bulk_actions() {
+ // Bulk installation process.
+ if ( 'tgmpa-bulk-install' === $this->current_action() || 'tgmpa-bulk-update' === $this->current_action() ) {
+
+ check_admin_referer( 'bulk-' . $this->_args['plural'] );
+
+ $install_type = 'install';
+ if ( 'tgmpa-bulk-update' === $this->current_action() ) {
+ $install_type = 'update';
+ }
+
+ $plugins_to_install = array();
+
+ // Did user actually select any plugins to install/update ?
+ if ( empty( $_POST['plugin'] ) ) {
+ if ( 'install' === $install_type ) {
+ $message = __( 'No plugins were selected to be installed. No action taken.', 'cryout' );
+ } else {
+ $message = __( 'No plugins were selected to be updated. No action taken.', 'cryout' );
+ }
+
+ echo '<div id="message" class="error"><p>', esc_html( $message ), '</p></div>';
+
+ return false;
+ }
+
+ if ( is_array( $_POST['plugin'] ) ) {
+ $plugins_to_install = (array) $_POST['plugin'];
+ } elseif ( is_string( $_POST['plugin'] ) ) {
+ // Received via Filesystem page - un-flatten array (WP bug #19643).
+ $plugins_to_install = explode( ',', $_POST['plugin'] );
+ }
+
+ // Sanitize the received input.
+ $plugins_to_install = array_map( 'urldecode', $plugins_to_install );
+ $plugins_to_install = array_map( array( $this->tgmpa, 'sanitize_key' ), $plugins_to_install );
+
+ // Validate the received input.
+ foreach ( $plugins_to_install as $key => $slug ) {
+ // Check if the plugin was registered with TGMPA and remove if not.
+ if ( ! isset( $this->tgmpa->plugins[ $slug ] ) ) {
+ unset( $plugins_to_install[ $key ] );
+ continue;
+ }
+
+ // For updates: make sure this is a plugin we *can* update (update available and WP version ok).
+ if ( 'update' === $install_type && ( $this->tgmpa->is_plugin_installed( $slug ) && ( false === $this->tgmpa->does_plugin_have_update( $slug ) || ! $this->tgmpa->can_plugin_update( $slug ) ) ) ) {
+ unset( $plugins_to_install[ $key ] );
+ }
+ }
+
+ // No need to proceed further if we have no plugins to handle.
+ if ( empty( $plugins_to_install ) ) {
+ if ( 'install' === $install_type ) {
+ $message = __( 'No plugins are available to be installed at this time.', 'cryout' );
+ } else {
+ $message = __( 'No plugins are available to be updated at this time.', 'cryout' );
+ }
+
+ echo '<div id="message" class="error"><p>', esc_html( $message ), '</p></div>';
+
+ return false;
+ }
+
+ // Pass all necessary information if WP_Filesystem is needed.
+ $url = wp_nonce_url(
+ $this->tgmpa->get_tgmpa_url(),
+ 'bulk-' . $this->_args['plural']
+ );
+
+ // Give validated data back to $_POST which is the only place the filesystem looks for extra fields.
+ $_POST['plugin'] = implode( ',', $plugins_to_install ); // Work around for WP bug #19643.
+
+ $method = ''; // Leave blank so WP_Filesystem can populate it as necessary.
+ $fields = array_keys( $_POST ); // Extra fields to pass to WP_Filesystem.
+
+ if ( false === ( $creds = request_filesystem_credentials( esc_url_raw( $url ), $method, false, false, $fields ) ) ) {
+ return true; // Stop the normal page form from displaying, credential request form will be shown.
+ }
+
+ // Now we have some credentials, setup WP_Filesystem.
+ if ( ! WP_Filesystem( $creds ) ) {
+ // Our credentials were no good, ask the user for them again.
+ request_filesystem_credentials( esc_url_raw( $url ), $method, true, false, $fields );
+
+ return true;
+ }
+
+ /* If we arrive here, we have the filesystem */
+
+ // Store all information in arrays since we are processing a bulk installation.
+ $names = array();
+ $sources = array(); // Needed for installs.
+ $file_paths = array(); // Needed for upgrades.
+ $to_inject = array(); // Information to inject into the update_plugins transient.
+
+ // Prepare the data for validated plugins for the install/upgrade.
+ foreach ( $plugins_to_install as $slug ) {
+ $name = $this->tgmpa->plugins[ $slug ]['name'];
+ $source = $this->tgmpa->get_download_url( $slug );
+
+ if ( ! empty( $name ) && ! empty( $source ) ) {
+ $names[] = $name;
+
+ switch ( $install_type ) {
+
+ case 'install':
+ $sources[] = $source;
+ break;
+
+ case 'update':
+ $file_paths[] = $this->tgmpa->plugins[ $slug ]['file_path'];
+ $to_inject[ $slug ] = $this->tgmpa->plugins[ $slug ];
+ $to_inject[ $slug ]['source'] = $source;
+ break;
+ }
+ }
+ }
+ unset( $slug, $name, $source );
+
+ // Create a new instance of TGMPA_Bulk_Installer.
+ $installer = new TGMPA_Bulk_Installer(
+ new TGMPA_Bulk_Installer_Skin(
+ array(
+ 'url' => esc_url_raw( $this->tgmpa->get_tgmpa_url() ),
+ 'nonce' => 'bulk-' . $this->_args['plural'],
+ 'names' => $names,
+ 'install_type' => $install_type,
+ )
+ )
+ );
+
+ // Wrap the install process with the appropriate HTML.
+ echo '<div class="tgmpa wrap">',
+ '<h2>', esc_html( get_admin_page_title() ), '</h2>';
+
+ // Process the bulk installation submissions.
+ add_filter( 'upgrader_source_selection', array( $this->tgmpa, 'maybe_adjust_source_dir' ), 1, 3 );
+
+ if ( 'tgmpa-bulk-update' === $this->current_action() ) {
+ // Inject our info into the update transient.
+ $this->tgmpa->inject_update_info( $to_inject );
+
+ $installer->bulk_upgrade( $file_paths );
+ } else {
+ $installer->bulk_install( $sources );
+ }
+
+ remove_filter( 'upgrader_source_selection', array( $this->tgmpa, 'maybe_adjust_source_dir' ), 1, 3 );
+
+ echo '</div>';
+
+ return true;
+ }
+
+ // Bulk activation process.
+ if ( 'tgmpa-bulk-activate' === $this->current_action() ) {
+ check_admin_referer( 'bulk-' . $this->_args['plural'] );
+
+ // Did user actually select any plugins to activate ?
+ if ( empty( $_POST['plugin'] ) ) {
+ echo '<div id="message" class="error"><p>', esc_html__( 'No plugins were selected to be activated. No action taken.', 'cryout' ), '</p></div>';
+
+ return false;
+ }
+
+ // Grab plugin data from $_POST.
+ $plugins = array();
+ if ( isset( $_POST['plugin'] ) ) {
+ $plugins = array_map( 'urldecode', (array) $_POST['plugin'] );
+ $plugins = array_map( array( $this->tgmpa, 'sanitize_key' ), $plugins );
+ }
+
+ $plugins_to_activate = array();
+ $plugin_names = array();
+
+ // Grab the file paths for the selected & inactive plugins from the registration array.
+ foreach ( $plugins as $slug ) {
+ if ( $this->tgmpa->can_plugin_activate( $slug ) ) {
+ $plugins_to_activate[] = $this->tgmpa->plugins[ $slug ]['file_path'];
+ $plugin_names[] = $this->tgmpa->plugins[ $slug ]['name'];
+ }
+ }
+ unset( $slug );
+
+ // Return early if there are no plugins to activate.
+ if ( empty( $plugins_to_activate ) ) {
+ echo '<div id="message" class="error"><p>', esc_html__( 'No plugins are available to be activated at this time.', 'cryout' ), '</p></div>';
+
+ return false;
+ }
+
+ // Now we are good to go - let's start activating plugins.
+ $activate = activate_plugins( $plugins_to_activate );
+
+ if ( is_wp_error( $activate ) ) {
+ echo '<div id="message" class="error"><p>', wp_kses_post( $activate->get_error_message() ), '</p></div>';
+ } else {
+ $count = count( $plugin_names ); // Count so we can use _n function.
+ $plugin_names = array_map( array( 'TGMPA_Utils', 'wrap_in_strong' ), $plugin_names );
+ $last_plugin = array_pop( $plugin_names ); // Pop off last name to prep for readability.
+ $imploded = empty( $plugin_names ) ? $last_plugin : ( implode( ', ', $plugin_names ) . ' ' . esc_html_x( 'and', 'plugin A *and* plugin B', 'cryout' ) . ' ' . $last_plugin );
+
+ printf( // WPCS: xss ok.
+ '<div id="message" class="updated"><p>%1$s %2$s.</p></div>',
+ esc_html( _n( 'The following plugin was activated successfully:', 'The following plugins were activated successfully:', $count, 'cryout' ) ),
+ $imploded
+ );
+
+ // Update recently activated plugins option.
+ $recent = (array) get_option( 'recently_activated' );
+ foreach ( $plugins_to_activate as $plugin => $time ) {
+ if ( isset( $recent[ $plugin ] ) ) {
+ unset( $recent[ $plugin ] );
+ }
+ }
+ update_option( 'recently_activated', $recent );
+ }
+
+ unset( $_POST ); // Reset the $_POST variable in case user wants to perform one action after another.
+
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Prepares all of our information to be outputted into a usable table.
+ *
+ * @since 2.2.0
+ */
+ public function prepare_items() {
+ $columns = $this->get_columns(); // Get all necessary column information.
+ $hidden = array(); // No columns to hide, but we must set as an array.
+ $sortable = array(); // No reason to make sortable columns.
+ $primary = $this->get_primary_column_name(); // Column which has the row actions.
+ $this->_column_headers = array( $columns, $hidden, $sortable, $primary ); // Get all necessary column headers.
+
+ // Process our bulk activations here.
+ if ( 'tgmpa-bulk-activate' === $this->current_action() ) {
+ $this->process_bulk_actions();
+ }
+
+ // Store all of our plugin data into $items array so WP_List_Table can use it.
+ $this->items = apply_filters( 'tgmpa_table_data_items', $this->_gather_plugin_data() );
+ }
+
+ /* *********** DEPRECATED METHODS *********** */
+
+ /**
+ * Retrieve plugin data, given the plugin name.
+ *
+ * @since 2.2.0
+ * @deprecated 2.5.0 use {@see TGM_Plugin_Activation::_get_plugin_data_from_name()} instead.
+ * @see TGM_Plugin_Activation::_get_plugin_data_from_name()
+ *
+ * @param string $name Name of the plugin, as it was registered.
+ * @param string $data Optional. Array key of plugin data to return. Default is slug.
+ * @return string|boolean Plugin slug if found, false otherwise.
+ */
+ protected function _get_plugin_data_from_name( $name, $data = 'slug' ) {
+ _deprecated_function( __FUNCTION__, 'TGMPA 2.5.0', 'TGM_Plugin_Activation::_get_plugin_data_from_name()' );
+
+ return $this->tgmpa->_get_plugin_data_from_name( $name, $data );
+ }
+ }
+}
+
+
+if ( ! class_exists( 'TGM_Bulk_Installer' ) ) {
+
+ /**
+ * Hack: Prevent TGMPA v2.4.1- bulk installer class from being loaded if 2.4.1- is loaded after 2.5+.
+ */
+ class TGM_Bulk_Installer {
+ }
+}
+if ( ! class_exists( 'TGM_Bulk_Installer_Skin' ) ) {
+
+ /**
+ * Hack: Prevent TGMPA v2.4.1- bulk installer skin class from being loaded if 2.4.1- is loaded after 2.5+.
+ */
+ class TGM_Bulk_Installer_Skin {
+ }
+}
+
+/**
+ * The WP_Upgrader file isn't always available. If it isn't available,
+ * we load it here.
+ *
+ * We check to make sure no action or activation keys are set so that WordPress
+ * does not try to re-include the class when processing upgrades or installs outside
+ * of the class.
+ *
+ * @since 2.2.0
+ */
+add_action( 'admin_init', 'tgmpa_load_bulk_installer' );
+if ( ! function_exists( 'tgmpa_load_bulk_installer' ) ) {
+ /**
+ * Load bulk installer
+ */
+ function tgmpa_load_bulk_installer() {
+ // Silently fail if 2.5+ is loaded *after* an older version.
+ if ( ! isset( $GLOBALS['tgmpa'] ) ) {
+ return;
+ }
+
+ // Get TGMPA class instance.
+ $tgmpa_instance = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) );
+
+ if ( isset( $_GET['page'] ) && $tgmpa_instance->menu === $_GET['page'] ) {
+ if ( ! class_exists( 'Plugin_Upgrader', false ) ) {
+ require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
+ }
+
+ if ( ! class_exists( 'TGMPA_Bulk_Installer' ) ) {
+
+ /**
+ * Installer class to handle bulk plugin installations.
+ *
+ * Extends WP_Upgrader and customizes to suit the installation of multiple
+ * plugins.
+ *
+ * @since 2.2.0
+ *
+ * @internal Since 2.5.0 the class is an extension of Plugin_Upgrader rather than WP_Upgrader
+ * @internal Since 2.5.2 the class has been renamed from TGM_Bulk_Installer to TGMPA_Bulk_Installer.
+ * This was done to prevent backward compatibility issues with v2.3.6.
+ *
+ * @package TGM-Plugin-Activation
+ * @author Thomas Griffin
+ * @author Gary Jones
+ */
+ class TGMPA_Bulk_Installer extends Plugin_Upgrader {
+ /**
+ * Holds result of bulk plugin installation.
+ *
+ * @since 2.2.0
+ *
+ * @var string
+ */
+ public $result;
+
+ /**
+ * Flag to check if bulk installation is occurring or not.
+ *
+ * @since 2.2.0
+ *
+ * @var boolean
+ */
+ public $bulk = false;
+
+ /**
+ * TGMPA instance
+ *
+ * @since 2.5.0
+ *
+ * @var object
+ */
+ protected $tgmpa;
+
+ /**
+ * Whether or not the destination directory needs to be cleared ( = on update).
+ *
+ * @since 2.5.0
+ *
+ * @var bool
+ */
+ protected $clear_destination = false;
+
+ /**
+ * References parent constructor and sets defaults for class.
+ *
+ * @since 2.2.0
+ *
+ * @param \Bulk_Upgrader_Skin|null $skin Installer skin.
+ */
+ public function __construct( $skin = null ) {
+ // Get TGMPA class instance.
+ $this->tgmpa = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) );
+
+ parent::__construct( $skin );
+
+ if ( isset( $this->skin->options['install_type'] ) && 'update' === $this->skin->options['install_type'] ) {
+ $this->clear_destination = true;
+ }
+
+ if ( $this->tgmpa->is_automatic ) {
+ $this->activate_strings();
+ }
+
+ add_action( 'upgrader_process_complete', array( $this->tgmpa, 'populate_file_path' ) );
+ }
+
+ /**
+ * Sets the correct activation strings for the installer skin to use.
+ *
+ * @since 2.2.0
+ */
+ public function activate_strings() {
+ $this->strings['activation_failed'] = __( 'Plugin activation failed.', 'cryout' );
+ $this->strings['activation_success'] = __( 'Plugin activated successfully.', 'cryout' );
+ }
+
+ /**
+ * Performs the actual installation of each plugin.
+ *
+ * @since 2.2.0
+ *
+ * @see WP_Upgrader::run()
+ *
+ * @param array $options The installation config options.
+ * @return null|array Return early if error, array of installation data on success.
+ */
+ public function run( $options ) {
+ $result = parent::run( $options );
+
+ // Reset the strings in case we changed one during automatic activation.
+ if ( $this->tgmpa->is_automatic ) {
+ if ( 'update' === $this->skin->options['install_type'] ) {
+ $this->upgrade_strings();
+ } else {
+ $this->install_strings();
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Processes the bulk installation of plugins.
+ *
+ * @since 2.2.0
+ *
+ * @internal This is basically a near identical copy of the WP Core Plugin_Upgrader::bulk_upgrade()
+ * method, with minor adjustments to deal with new installs instead of upgrades.
+ * For ease of future synchronizations, the adjustments are clearly commented, but no other
+ * comments are added. Code style has been made to comply.
+ *
+ * @see Plugin_Upgrader::bulk_upgrade()
+ * @see https://core.trac.wordpress.org/browser/tags/4.2.1/src/wp-admin/includes/class-wp-upgrader.php#L838
+ *
+ * @param array $plugins The plugin sources needed for installation.
+ * @param array $args Arbitrary passed extra arguments.
+ * @return string|bool Install confirmation messages on success, false on failure.
+ */
+ public function bulk_install( $plugins, $args = array() ) {
+ // [TGMPA + ] Hook auto-activation in.
+ add_filter( 'upgrader_post_install', array( $this, 'auto_activate' ), 10 );
+
+ $defaults = array(
+ 'clear_update_cache' => true,
+ );
+ $parsed_args = wp_parse_args( $args, $defaults );
+
+ $this->init();
+ $this->bulk = true;
+
+ $this->install_strings(); // [TGMPA + ] adjusted.
+
+ /* [TGMPA - ] $current = get_site_transient( 'update_plugins' ); */
+
+ /* [TGMPA - ] add_filter('upgrader_clear_destination', array($this, 'delete_old_plugin'), 10, 4); */
+
+ $this->skin->header();
+
+ // Connect to the Filesystem first.
+ $res = $this->fs_connect( array( WP_CONTENT_DIR, WP_PLUGIN_DIR ) );
+ if ( ! $res ) {
+ $this->skin->footer();
+
+ return false;
+ }
+
+ $this->skin->bulk_header();
+
+ // Only start maintenance mode if:
+ // - running Multisite and there are one or more plugins specified, OR
+ // - a plugin with an update available is currently active.
+ // @TODO: For multisite, maintenance mode should only kick in for individual sites if at all possible.
+ $maintenance = ( is_multisite() && ! empty( $plugins ) );
+
+ /*
+ [TGMPA - ]
+ foreach ( $plugins as $plugin )
+ $maintenance = $maintenance || ( is_plugin_active( $plugin ) && isset( $current->response[ $plugin] ) );
+ */
+ if ( $maintenance ) {
+ $this->maintenance_mode( true );
+ }
+
+ $results = array();
+
+ $this->update_count = count( $plugins );
+ $this->update_current = 0;
+ foreach ( $plugins as $plugin ) {
+ $this->update_current++;
+
+ /*
+ [TGMPA - ]
+ $this->skin->plugin_info = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin, false, true);
+
+ if ( !isset( $current->response[ $plugin ] ) ) {
+ $this->skin->set_result('up_to_date');
+ $this->skin->before();
+ $this->skin->feedback('up_to_date');
+ $this->skin->after();
+ $results[$plugin] = true;
+ continue;
+ }
+
+ // Get the URL to the zip file
+ $r = $current->response[ $plugin ];
+
+ $this->skin->plugin_active = is_plugin_active($plugin);
+ */
+
+ $result = $this->run( array(
+ 'package' => $plugin, // [TGMPA + ] adjusted.
+ 'destination' => WP_PLUGIN_DIR,
+ 'clear_destination' => false, // [TGMPA + ] adjusted.
+ 'clear_working' => true,
+ 'is_multi' => true,
+ 'hook_extra' => array(
+ 'plugin' => $plugin,
+ ),
+ ) );
+
+ $results[ $plugin ] = $this->result;
+
+ // Prevent credentials auth screen from displaying multiple times.
+ if ( false === $result ) {
+ break;
+ }
+ } //end foreach $plugins
+
+ $this->maintenance_mode( false );
+
+ /**
+ * Fires when the bulk upgrader process is complete.
+ *
+ * @since WP 3.6.0 / TGMPA 2.5.0
+ *
+ * @param Plugin_Upgrader $this Plugin_Upgrader instance. In other contexts, $this, might
+ * be a Theme_Upgrader or Core_Upgrade instance.
+ * @param array $data {
+ * Array of bulk item update data.
+ *
+ * @type string $action Type of action. Default 'update'.
+ * @type string $type Type of update process. Accepts 'plugin', 'theme', or 'core'.
+ * @type bool $bulk Whether the update process is a bulk update. Default true.
+ * @type array $packages Array of plugin, theme, or core packages to update.
+ * }
+ */
+ do_action( 'upgrader_process_complete', $this, array(
+ 'action' => 'install', // [TGMPA + ] adjusted.
+ 'type' => 'plugin',
+ 'bulk' => true,
+ 'plugins' => $plugins,
+ ) );
+
+ $this->skin->bulk_footer();
+
+ $this->skin->footer();
+
+ // Cleanup our hooks, in case something else does a upgrade on this connection.
+ /* [TGMPA - ] remove_filter('upgrader_clear_destination', array($this, 'delete_old_plugin')); */
+
+ // [TGMPA + ] Remove our auto-activation hook.
+ remove_filter( 'upgrader_post_install', array( $this, 'auto_activate' ), 10 );
+
+ // Force refresh of plugin update information.
+ wp_clean_plugins_cache( $parsed_args['clear_update_cache'] );
+
+ return $results;
+ }
+
+ /**
+ * Handle a bulk upgrade request.
+ *
+ * @since 2.5.0
+ *
+ * @see Plugin_Upgrader::bulk_upgrade()
+ *
+ * @param array $plugins The local WP file_path's of the plugins which should be upgraded.
+ * @param array $args Arbitrary passed extra arguments.
+ * @return string|bool Install confirmation messages on success, false on failure.
+ */
+ public function bulk_upgrade( $plugins, $args = array() ) {
+
+ add_filter( 'upgrader_post_install', array( $this, 'auto_activate' ), 10 );
+
+ $result = parent::bulk_upgrade( $plugins, $args );
+
+ remove_filter( 'upgrader_post_install', array( $this, 'auto_activate' ), 10 );
+
+ return $result;
+ }
+
+ /**
+ * Abuse a filter to auto-activate plugins after installation.
+ *
+ * Hooked into the 'upgrader_post_install' filter hook.
+ *
+ * @since 2.5.0
+ *
+ * @param bool $bool The value we need to give back (true).
+ * @return bool
+ */
+ public function auto_activate( $bool ) {
+ // Only process the activation of installed plugins if the automatic flag is set to true.
+ if ( $this->tgmpa->is_automatic ) {
+ // Flush plugins cache so the headers of the newly installed plugins will be read correctly.
+ wp_clean_plugins_cache();
+
+ // Get the installed plugin file.
+ $plugin_info = $this->plugin_info();
+
+ // Don't try to activate on upgrade of active plugin as WP will do this already.
+ if ( ! is_plugin_active( $plugin_info ) ) {
+ $activate = activate_plugin( $plugin_info );
+
+ // Adjust the success string based on the activation result.
+ $this->strings['process_success'] = $this->strings['process_success'] . "<br />\n";
+
+ if ( is_wp_error( $activate ) ) {
+ $this->skin->error( $activate );
+ $this->strings['process_success'] .= $this->strings['activation_failed'];
+ } else {
+ $this->strings['process_success'] .= $this->strings['activation_success'];
+ }
+ }
+ }
+
+ return $bool;
+ }
+ }
+ }
+
+ if ( ! class_exists( 'TGMPA_Bulk_Installer_Skin' ) ) {
+
+ /**
+ * Installer skin to set strings for the bulk plugin installations..
+ *
+ * Extends Bulk_Upgrader_Skin and customizes to suit the installation of multiple
+ * plugins.
+ *
+ * @since 2.2.0
+ *
+ * @internal Since 2.5.2 the class has been renamed from TGM_Bulk_Installer_Skin to
+ * TGMPA_Bulk_Installer_Skin.
+ * This was done to prevent backward compatibility issues with v2.3.6.
+ *
+ * @see https://core.trac.wordpress.org/browser/trunk/src/wp-admin/includes/class-wp-upgrader-skins.php
+ *
+ * @package TGM-Plugin-Activation
+ * @author Thomas Griffin
+ * @author Gary Jones
+ */
+ class TGMPA_Bulk_Installer_Skin extends Bulk_Upgrader_Skin {
+ /**
+ * Holds plugin info for each individual plugin installation.
+ *
+ * @since 2.2.0
+ *
+ * @var array
+ */
+ public $plugin_info = array();
+
+ /**
+ * Holds names of plugins that are undergoing bulk installations.
+ *
+ * @since 2.2.0
+ *
+ * @var array
+ */
+ public $plugin_names = array();
+
+ /**
+ * Integer to use for iteration through each plugin installation.
+ *
+ * @since 2.2.0
+ *
+ * @var integer
+ */
+ public $i = 0;
+
+ /**
+ * TGMPA instance
+ *
+ * @since 2.5.0
+ *
+ * @var object
+ */
+ protected $tgmpa;
+
+ /**
+ * Constructor. Parses default args with new ones and extracts them for use.
+ *
+ * @since 2.2.0
+ *
+ * @param array $args Arguments to pass for use within the class.
+ */
+ public function __construct( $args = array() ) {
+ // Get TGMPA class instance.
+ $this->tgmpa = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) );
+
+ // Parse default and new args.
+ $defaults = array(
+ 'url' => '',
+ 'nonce' => '',
+ 'names' => array(),
+ 'install_type' => 'install',
+ );
+ $args = wp_parse_args( $args, $defaults );
+
+ // Set plugin names to $this->plugin_names property.
+ $this->plugin_names = $args['names'];
+
+ // Extract the new args.
+ parent::__construct( $args );
+ }
+
+ /**
+ * Sets install skin strings for each individual plugin.
+ *
+ * Checks to see if the automatic activation flag is set and uses the
+ * the proper strings accordingly.
+ *
+ * @since 2.2.0
+ */
+ public function add_strings() {
+ if ( 'update' === $this->options['install_type'] ) {
+ parent::add_strings();
+ $this->upgrader->strings['skin_before_update_header'] = __( 'Updating Plugin %1$s (%2$d/%3$d)', 'cryout' );
+ } else {
+ $this->upgrader->strings['skin_update_failed_error'] = __( 'An error occurred while installing %1$s: <strong>%2$s</strong>.', 'cryout' );
+ $this->upgrader->strings['skin_update_failed'] = __( 'The installation of %1$s failed.', 'cryout' );
+
+ if ( $this->tgmpa->is_automatic ) {
+ // Automatic activation strings.
+ $this->upgrader->strings['skin_upgrade_start'] = __( 'The installation and activation process is starting. This process may take a while on some hosts, so please be patient.', 'cryout' );
+ $this->upgrader->strings['skin_update_successful'] = __( '%1$s installed and activated successfully.', 'cryout' ) . ' <a href="#" class="hide-if-no-js" onclick="%2$s"><span>' . esc_html__( 'Show Details', 'cryout' ) . '</span><span class="hidden">' . esc_html__( 'Hide Details', 'cryout' ) . '</span>.</a>';
+ $this->upgrader->strings['skin_upgrade_end'] = __( 'All installations and activations have been completed.', 'cryout' );
+ $this->upgrader->strings['skin_before_update_header'] = __( 'Installing and Activating Plugin %1$s (%2$d/%3$d)', 'cryout' );
+ } else {
+ // Default installation strings.
+ $this->upgrader->strings['skin_upgrade_start'] = __( 'The installation process is starting. This process may take a while on some hosts, so please be patient.', 'cryout' );
+ $this->upgrader->strings['skin_update_successful'] = esc_html__( '%1$s installed successfully.', 'cryout' ) . ' <a href="#" class="hide-if-no-js" onclick="%2$s"><span>' . esc_html__( 'Show Details', 'cryout' ) . '</span><span class="hidden">' . esc_html__( 'Hide Details', 'cryout' ) . '</span>.</a>';
+ $this->upgrader->strings['skin_upgrade_end'] = __( 'All installations have been completed.', 'cryout' );
+ $this->upgrader->strings['skin_before_update_header'] = __( 'Installing Plugin %1$s (%2$d/%3$d)', 'cryout' );
+ }
+ }
+ }
+
+ /**
+ * Outputs the header strings and necessary JS before each plugin installation.
+ *
+ * @since 2.2.0
+ *
+ * @param string $title Unused in this implementation.
+ */
+ public function before( $title = '' ) {
+ if ( empty( $title ) ) {
+ $title = esc_html( $this->plugin_names[ $this->i ] );
+ }
+ parent::before( $title );
+ }
+
+ /**
+ * Outputs the footer strings and necessary JS after each plugin installation.
+ *
+ * Checks for any errors and outputs them if they exist, else output
+ * success strings.
+ *
+ * @since 2.2.0
+ *
+ * @param string $title Unused in this implementation.
+ */
+ public function after( $title = '' ) {
+ if ( empty( $title ) ) {
+ $title = esc_html( $this->plugin_names[ $this->i ] );
+ }
+ parent::after( $title );
+
+ $this->i++;
+ }
+
+ /**
+ * Outputs links after bulk plugin installation is complete.
+ *
+ * @since 2.2.0
+ */
+ public function bulk_footer() {
+ // Serve up the string to say installations (and possibly activations) are complete.
+ parent::bulk_footer();
+
+ // Flush plugins cache so we can make sure that the installed plugins list is always up to date.
+ wp_clean_plugins_cache();
+
+ $this->tgmpa->show_tgmpa_version();
+
+ // Display message based on if all plugins are now active or not.
+ $update_actions = array();
+
+ if ( $this->tgmpa->is_tgmpa_complete() ) {
+ // All plugins are active, so we display the complete string and hide the menu to protect users.
+ echo '<style type="text/css">#adminmenu .wp-submenu li.current { display: none !important; }</style>';
+ $update_actions['dashboard'] = sprintf(
+ esc_html( $this->tgmpa->strings['complete'] ),
+ '<a href="' . esc_url( self_admin_url() ) . '">' . esc_html__( 'Return to the Dashboard', 'cryout' ) . '</a>'
+ );
+ } else {
+ $update_actions['tgmpa_page'] = '<a href="' . esc_url( $this->tgmpa->get_tgmpa_url() ) . '" target="_parent">' . esc_html( $this->tgmpa->strings['return'] ) . '</a>';
+ }
+
+ /**
+ * Filter the list of action links available following bulk plugin installs/updates.
+ *
+ * @since 2.5.0
+ *
+ * @param array $update_actions Array of plugin action links.
+ * @param array $plugin_info Array of information for the last-handled plugin.
+ */
+ $update_actions = apply_filters( 'tgmpa_update_bulk_plugins_complete_actions', $update_actions, $this->plugin_info );
+
+ if ( ! empty( $update_actions ) ) {
+ $this->feedback( implode( ' | ', (array) $update_actions ) );
+ }
+ }
+
+ /* *********** DEPRECATED METHODS *********** */
+
+ /**
+ * Flush header output buffer.
+ *
+ * @since 2.2.0
+ * @deprecated 2.5.0 use {@see Bulk_Upgrader_Skin::flush_output()} instead
+ * @see Bulk_Upgrader_Skin::flush_output()
+ */
+ public function before_flush_output() {
+ _deprecated_function( __FUNCTION__, 'TGMPA 2.5.0', 'Bulk_Upgrader_Skin::flush_output()' );
+ $this->flush_output();
+ }
+
+ /**
+ * Flush footer output buffer and iterate $this->i to make sure the
+ * installation strings reference the correct plugin.
+ *
+ * @since 2.2.0
+ * @deprecated 2.5.0 use {@see Bulk_Upgrader_Skin::flush_output()} instead
+ * @see Bulk_Upgrader_Skin::flush_output()
+ */
+ public function after_flush_output() {
+ _deprecated_function( __FUNCTION__, 'TGMPA 2.5.0', 'Bulk_Upgrader_Skin::flush_output()' );
+ $this->flush_output();
+ $this->i++;
+ }
+ }
+ }
+ }
+ }
+}
+
+if ( ! class_exists( 'TGMPA_Utils' ) ) {
+
+ /**
+ * Generic utilities for TGMPA.
+ *
+ * All methods are static, poor-dev name-spacing class wrapper.
+ *
+ * Class was called TGM_Utils in 2.5.0 but renamed TGMPA_Utils in 2.5.1 as this was conflicting with Soliloquy.
+ *
+ * @since 2.5.0
+ *
+ * @package TGM-Plugin-Activation
+ * @author Juliette Reinders Folmer
+ */
+ class TGMPA_Utils {
+ /**
+ * Whether the PHP filter extension is enabled.
+ *
+ * @see http://php.net/book.filter
+ *
+ * @since 2.5.0
+ *
+ * @static
+ *
+ * @var bool $has_filters True is the extension is enabled.
+ */
+ public static $has_filters;
+
+ /**
+ * Wrap an arbitrary string in <em> tags. Meant to be used in combination with array_map().
+ *
+ * @since 2.5.0
+ *
+ * @static
+ *
+ * @param string $string Text to be wrapped.
+ * @return string
+ */
+ public static function wrap_in_em( $string ) {
+ return '<em>' . wp_kses_post( $string ) . '</em>';
+ }
+
+ /**
+ * Wrap an arbitrary string in <strong> tags. Meant to be used in combination with array_map().
+ *
+ * @since 2.5.0
+ *
+ * @static
+ *
+ * @param string $string Text to be wrapped.
+ * @return string
+ */
+ public static function wrap_in_strong( $string ) {
+ return '<strong>' . wp_kses_post( $string ) . '</strong>';
+ }
+
+ /**
+ * Helper function: Validate a value as boolean
+ *
+ * @since 2.5.0
+ *
+ * @static
+ *
+ * @param mixed $value Arbitrary value.
+ * @return bool
+ */
+ public static function validate_bool( $value ) {
+ if ( ! isset( self::$has_filters ) ) {
+ self::$has_filters = extension_loaded( 'filter' );
+ }
+
+ if ( self::$has_filters ) {
+ return filter_var( $value, FILTER_VALIDATE_BOOLEAN );
+ } else {
+ return self::emulate_filter_bool( $value );
+ }
+ }
+
+ /**
+ * Helper function: Cast a value to bool
+ *
+ * @since 2.5.0
+ *
+ * @static
+ *
+ * @param mixed $value Value to cast.
+ * @return bool
+ */
+ protected static function emulate_filter_bool( $value ) {
+ // @codingStandardsIgnoreStart
+ static $true = array(
+ '1',
+ 'true', 'True', 'TRUE',
+ 'y', 'Y',
+ 'yes', 'Yes', 'YES',
+ 'on', 'On', 'ON',
+ );
+ static $false = array(
+ '0',
+ 'false', 'False', 'FALSE',
+ 'n', 'N',
+ 'no', 'No', 'NO',
+ 'off', 'Off', 'OFF',
+ );
+ // @codingStandardsIgnoreEnd
+
+ if ( is_bool( $value ) ) {
+ return $value;
+ } else if ( is_int( $value ) && ( 0 === $value || 1 === $value ) ) {
+ return (bool) $value;
+ } else if ( ( is_float( $value ) && ! is_nan( $value ) ) && ( (float) 0 === $value || (float) 1 === $value ) ) {
+ return (bool) $value;
+ } else if ( is_string( $value ) ) {
+ $value = trim( $value );
+ if ( in_array( $value, $true, true ) ) {
+ return true;
+ } else if ( in_array( $value, $false, true ) ) {
+ return false;
+ } else {
+ return false;
+ }
+ }
+
+ return false;
+ }
+ } // End of class TGMPA_Utils
+} // End of class_exists wrapper
+
diff --git a/themes/mantra/includes/theme-comments.php b/themes/mantra/includes/theme-comments.php
index d53532ae..f5186c96 100644
--- a/themes/mantra/includes/theme-comments.php
+++ b/themes/mantra/includes/theme-comments.php
@@ -1,143 +1,143 @@
-<?php /*
- * Comments related functions - comments.php
- *
- * @package mantra
- * @subpackage Functions
- */
-
-if ( ! function_exists( 'mantra_comment' ) ) :
-/**
- * Template for comments and pingbacks.
- *
- * To override this walker in a child theme without modifying the comments template
- * simply create your own mantra_comment(), and that function will be used instead.
- *
- * Used as a callback by wp_list_comments() for displaying the comments.
- *
- * @since mantra 0.5
- */
-function mantra_comment( $comment, $args, $depth ) {
- $GLOBALS['comment'] = $comment;
- switch ( $comment->comment_type ) :
- case '' :
- ?>
- <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
- <div id="comment-<?php comment_ID(); ?>">
- <div class="comment-author vcard">
- <?php echo get_avatar( $comment, 40 );
- ?><?php printf( '%s <span class="says">'.__('says:', 'mantra' ).'</span>', sprintf( '<cite class="fn">%s</cite>', get_comment_author_link() ) ); ?>
-
-
-
- </div><!-- .comment-author .vcard -->
- <?php if ( $comment->comment_approved == '0' ) : ?>
- <em><?php _e( 'Your comment is awaiting moderation.', 'mantra' ); ?></em>
- <br />
- <?php endif; ?>
-
- <div class="comment-meta commentmetadata"><a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>">
- <?php
- /* translators: 1: date, 2: time */
- printf( '%1$s '.__('at', 'mantra' ).' %2$s', get_comment_date(), get_comment_time() ); ?></a><?php edit_comment_link( __( '(Edit)', 'mantra' ), ' ' );
- ?>
- </div><!-- .comment-meta .commentmetadata -->
-
- <div class="comment-body"><?php comment_text(); ?></div>
-
- <div class="reply">
- <?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
- </div><!-- .reply -->
- </div><!-- #comment-## -->
-
- <?php
- break;
- case 'pingback' :
- case 'trackback' :
- ?>
- <li class="post pingback">
- <p><?php _e( 'Pingback: ', 'mantra' ); ?><?php comment_author_link(); ?><?php edit_comment_link( __('(Edit)', 'mantra'), ' ' ); ?></p>
- <?php
- break;
- endswitch;
-}
-endif;
-
-/**
- * Removes the default styles that are packaged with the Recent Comments widget.
- *
- * To override this in a child theme, remove the filter and optionally add your own
- * function tied to the widgets_init action hook.
- *
- * @since mantra 0.5
- */
-function mantra_remove_recent_comments_style() {
- global $wp_widget_factory;
- remove_action( 'wp_head', array( $wp_widget_factory->widgets['WP_Widget_Recent_Comments'], 'recent_comments_style' ) );
-}
-
-add_action( 'widgets_init', 'mantra_remove_recent_comments_style' );
-
-if ( ! function_exists( 'mantra_comments_on' ) ) :
-/**
- * Number of comments on loop post if comments are enabled.
- */
-function mantra_comments_on() {
- printf ( comments_popup_link( __( 'Leave a comment', 'mantra' ), __( '<b>1</b> Comment', 'mantra' ), __( '<b>%</b> Comments', 'mantra' ) ));
-}
-endif;
-
-/**
- * The number of comments title
- */
-function mantra_number_comments() { ?>
- <h3 id="comments-title">
- <?php printf( _n( 'One Response to %2$s', '%1$s Responses to %2$s', get_comments_number(), 'mantra' ),
- number_format_i18n( get_comments_number() ), '<em>' . get_the_title() . '</em>' ); ?>
- </h3>
-<?php }
-
-add_action('cryout_before_comments_hook','mantra_number_comments');
-
-/**
- * The comments navigation in case of comments on multiple pages (both top and bottom)
- */
-function mantra_comments_navigation() {
-if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // Are there comments to navigate through? ?>
- <div class="navigation">
- <div class="nav-previous"><?php previous_comments_link( '<span class="meta-nav">&larr;</span>'.__('Older Comments', 'mantra' ) ); ?></div>
- <div class="nav-next"><?php next_comments_link( __( 'Newer Comments', 'mantra' ).' <span class="meta-nav">&rarr;</span>' ); ?></div>
- </div> <!-- .navigation -->
-<?php endif; // check for comment navigation
-}
-
-add_action('cryout_before_comments_hook','mantra_comments_navigation');
-add_action('cryout_after_comments_hook','mantra_comments_navigation');
-
-/*
-* Listing the actual comments
-*
-* Loop through and list the comments. Tell wp_list_comments()
-* to use mantra_comment() to format the comments.
-* If you want to overload this in a child theme then you can
-* define mantra_comment() and that will be used instead.
-* See mantra_comment() in mantra/functions.php for more.
- */
-function mantra_list_comments() {
- wp_list_comments( array( 'callback' => 'mantra_comment' ) );
- }
-
-add_action('cryout_comments_hook','mantra_list_comments');
-
-/*
- * If there are no comments and comments are closed
- */
-function mantra_comments_off() {
-if ( ! comments_open() ) : ?>
- <p class="nocomments"><?php _e( 'Comments are closed.', 'mantra' ); ?></p>
-<?php endif; // end ! comments_open()
-}
-
-
-add_action('cryout_nocomments_hook','mantra_comments_off');
-
+<?php /*
+ * Comments related functions - comments.php
+ *
+ * @package mantra
+ * @subpackage Functions
+ */
+
+if ( ! function_exists( 'mantra_comment' ) ) :
+/**
+ * Template for comments and pingbacks.
+ *
+ * To override this walker in a child theme without modifying the comments template
+ * simply create your own mantra_comment(), and that function will be used instead.
+ *
+ * Used as a callback by wp_list_comments() for displaying the comments.
+ *
+ * @since mantra 0.5
+ */
+function mantra_comment( $comment, $args, $depth ) {
+ $GLOBALS['comment'] = $comment;
+ switch ( $comment->comment_type ) :
+ case '' :
+ ?>
+ <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
+ <div id="comment-<?php comment_ID(); ?>">
+ <div class="comment-author vcard">
+ <?php echo get_avatar( $comment, 40 );
+ ?><?php printf( '%s <span class="says">'.__('says:', 'mantra' ).'</span>', sprintf( '<cite class="fn">%s</cite>', get_comment_author_link() ) ); ?>
+
+
+
+ </div><!-- .comment-author .vcard -->
+ <?php if ( $comment->comment_approved == '0' ) : ?>
+ <em><?php _e( 'Your comment is awaiting moderation.', 'mantra' ); ?></em>
+ <br />
+ <?php endif; ?>
+
+ <div class="comment-meta commentmetadata"><a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>">
+ <?php
+ /* translators: 1: date, 2: time */
+ printf( '%1$s '.__('at', 'mantra' ).' %2$s', get_comment_date(), get_comment_time() ); ?></a><?php edit_comment_link( __( '(Edit)', 'mantra' ), ' ' );
+ ?>
+ </div><!-- .comment-meta .commentmetadata -->
+
+ <div class="comment-body"><?php comment_text(); ?></div>
+
+ <div class="reply">
+ <?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
+ </div><!-- .reply -->
+ </div><!-- #comment-## -->
+
+ <?php
+ break;
+ case 'pingback' :
+ case 'trackback' :
+ ?>
+ <li class="post pingback">
+ <p><?php _e( 'Pingback: ', 'mantra' ); ?><?php comment_author_link(); ?><?php edit_comment_link( __('(Edit)', 'mantra'), ' ' ); ?></p>
+ <?php
+ break;
+ endswitch;
+}
+endif;
+
+/**
+ * Removes the default styles that are packaged with the Recent Comments widget.
+ *
+ * To override this in a child theme, remove the filter and optionally add your own
+ * function tied to the widgets_init action hook.
+ *
+ * @since mantra 0.5
+ */
+function mantra_remove_recent_comments_style() {
+ global $wp_widget_factory;
+ remove_action( 'wp_head', array( $wp_widget_factory->widgets['WP_Widget_Recent_Comments'], 'recent_comments_style' ) );
+}
+
+add_action( 'widgets_init', 'mantra_remove_recent_comments_style' );
+
+if ( ! function_exists( 'mantra_comments_on' ) ) :
+/**
+ * Number of comments on loop post if comments are enabled.
+ */
+function mantra_comments_on() {
+ printf ( comments_popup_link( __( 'Leave a comment', 'mantra' ), __( '<b>1</b> Comment', 'mantra' ), __( '<b>%</b> Comments', 'mantra' ) ));
+}
+endif;
+
+/**
+ * The number of comments title
+ */
+function mantra_number_comments() { ?>
+ <h3 id="comments-title">
+ <?php printf( _n( 'One Response to %2$s', '%1$s Responses to %2$s', get_comments_number(), 'mantra' ),
+ number_format_i18n( get_comments_number() ), '<em>' . get_the_title() . '</em>' ); ?>
+ </h3>
+<?php }
+
+add_action('cryout_before_comments_hook','mantra_number_comments');
+
+/**
+ * The comments navigation in case of comments on multiple pages (both top and bottom)
+ */
+function mantra_comments_navigation() {
+if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // Are there comments to navigate through? ?>
+ <div class="navigation">
+ <div class="nav-previous"><?php previous_comments_link( '<span class="meta-nav">&larr;</span>'.__('Older Comments', 'mantra' ) ); ?></div>
+ <div class="nav-next"><?php next_comments_link( __( 'Newer Comments', 'mantra' ).' <span class="meta-nav">&rarr;</span>' ); ?></div>
+ </div> <!-- .navigation -->
+<?php endif; // check for comment navigation
+}
+
+add_action('cryout_before_comments_hook','mantra_comments_navigation');
+add_action('cryout_after_comments_hook','mantra_comments_navigation');
+
+/*
+* Listing the actual comments
+*
+* Loop through and list the comments. Tell wp_list_comments()
+* to use mantra_comment() to format the comments.
+* If you want to overload this in a child theme then you can
+* define mantra_comment() and that will be used instead.
+* See mantra_comment() in mantra/functions.php for more.
+ */
+function mantra_list_comments() {
+ wp_list_comments( array( 'callback' => 'mantra_comment' ) );
+ }
+
+add_action('cryout_comments_hook','mantra_list_comments');
+
+/*
+ * If there are no comments and comments are closed
+ */
+function mantra_comments_off() {
+if ( ! comments_open() ) : ?>
+ <p class="nocomments"><?php _e( 'Comments are closed.', 'mantra' ); ?></p>
+<?php endif; // end ! comments_open()
+}
+
+
+add_action('cryout_nocomments_hook','mantra_comments_off');
+
?> \ No newline at end of file
diff --git a/themes/mantra/includes/theme-frontpage.php b/themes/mantra/includes/theme-frontpage.php
index 1a093221..ae82279c 100644
--- a/themes/mantra/includes/theme-frontpage.php
+++ b/themes/mantra/includes/theme-frontpage.php
@@ -1,237 +1,237 @@
-<?php
-/**
- * Frontpage generation functions
- * Creates the slider, the columns, the titles and the extra text
- *
- * @package mantra
- * @subpackage Functions
- */
-
-if ( ! function_exists( 'mantra_frontpage_css' ) ) :
-function mantra_frontpage_css() {
- $mantra_options= mantra_get_theme_options();
- foreach ($mantra_options as $key => $value) { ${"$key"} = $value; }
- ob_start();
- echo '<style type="text/css">/* Mantra frontpage CSS */'; ?>
-<?php if ($mantra_fronthideheader) {?> #branding {display:none;} <?php }
- if ($mantra_fronthidemenu) {?> #access {display:none;} <?php }
- if ($mantra_fronthidewidget) {?> #colophon {display:none;} <?php }
- if ($mantra_fronthidefooter) {?> #footer2 {display:none;} <?php }
- if ($mantra_fronthideback) {?> #main {background:none;} <?php } ?>
-
-.slider-wrapper { display:block; float:none; width:100%; margin:0 auto; }
-
-#slider{
- max-width:<?php echo $mantra_fpsliderwidth ?>px ;
- height:<?php echo $mantra_fpsliderheight ?>px ;
- margin:30px auto 20px; display:block; float:none;
- border:<?php echo $mantra_fpsliderborderwidth.'px solid '.$mantra_fpsliderbordercolor; ?>; }
-
-#front-text1 h1, #front-text2 h1 { display:block; float:none; margin:35px auto; text-align:center; font-size:32px;
- clear:both; line-height:32px; font-weight:bold; color:<?php echo $mantra_fronttitlecolor; ?>; }
-
-#front-text2 h1{ font-size:28px; line-height:28px; margin-top:0px; margin-bottom:25px; }
-
-#frontpage blockquote { width:88%; max-width:88% !important; margin-bottom:20px;
- font-size:16px; line-height:22px; color:#444; }
-
-#frontpage #front-text4 blockquote { font-size:14px; line-height:18px; color:#666; }
-
-#frontpage blockquote:before, #frontpage blockquote:after { content:none; }
-
-#front-columns > div { display:block; width:<?php
-switch ($mantra_nrcolumns) {
- case 0: break;
- case 1: echo "95"; break;
- case 2: echo "45"; break;
- case 3: echo "29"; break;
- case 4: echo "21"; break;
-} ?>%; height:auto; margin-left:2%; margin-right:2%; margin-bottom:10px; float:left; }
-
-.column-image { height:<?php echo $mantra_colimageheight ?>px; border:3px solid #eee; }
-
-.theme-default .nivo-controlNav {margin-left:0;}
-<?php
-switch($mantra_fpslidernav):
- case "Bullets": break;
- case "Numbers": ?>
-.theme-default .nivo-controlNav {bottom:-40px;}
-.theme-default .nivo-controlNav a { background: none; text-decoration:underline; text-indent:0; }
-<?php break;
- case "None": ?>
-.theme-default .nivo-controlNav { display:none; }
-<?php break;
-endswitch;
- echo "</style>\n";
- $mantra_presentation_page_styling = ob_get_contents();
- ob_end_clean();
- return $mantra_presentation_page_styling;
-} // mantra_frontpage_css()
-endif;
-
-if ( ! function_exists( 'mantra_frontpage_generator' ) ) :
-// Front page generator
-function mantra_frontpage_generator() {
-$mantra_options= mantra_get_theme_options();
-foreach ($mantra_options as $key => $value) {
- ${"$key"} = $value ;
-}
-?>
-
-<script type="text/javascript">
-
- // Flash animation for columns
-
-
- jQuery(document).ready(function() {
- // Slider creation
- jQuery('#slider').nivoSlider({
-
- effect: '<?php echo $mantra_fpslideranim; ?>',
- animSpeed: <?php echo $mantra_fpslidertime ?>,
- <?php if($mantra_fpsliderarrows=="Hidden") { ?> directionNav: false, <?php }
- if($mantra_fpsliderarrows=="Always Visible") { ?> directionNav: true, <?php } ?>
- pauseTime: <?php echo $mantra_fpsliderpause ?>
-
- });
-
- jQuery('#front-columns > div img').hover( function() {
- jQuery(this)
- .stop()
- .animate({opacity: 0.5}, 100)
- .fadeOut(100)
- .fadeIn(100)
- .animate({opacity: 0.999}, 100) ;
- }, function() {jQuery(this).stop();} )
-
- });
- </script>
-
-<div id="frontpage">
-<?php
-
-// First FrontPage Title
-if($mantra_fronttext1) {?><div id="front-text1"> <h1><?php echo esc_attr($mantra_fronttext1) ?> </h1></div><?php }
-
-// When a post query has been selected from the Slider type in the admin area
-if ($mantra_slideType != 'Custom Slides') {
-global $post;
-// Initiating query
-$custom_query = new WP_query();
-
-// Switch for Query type
-switch ($mantra_slideType) {
-
- case 'Latest Posts' :
-$custom_query->query('showposts='.$mantra_slideNumber.'&ignore_sticky_posts=1');
-break;
-
- case 'Random Posts' :
-$custom_query->query('showposts='.$mantra_slideNumber.'&orderby=rand&ignore_sticky_posts=1');
-break;
-
- case 'Latest Posts from Category' :
-$custom_query->query('showposts='.$mantra_slideNumber.'&category_name='.$mantra_slideCateg.'&ignore_sticky_posts=1');
-break;
-
- case 'Random Posts from Category' :
-$custom_query->query('showposts='.$mantra_slideNumber.'&category_name='.$mantra_slideCateg.'&orderby=rand&ignore_sticky_posts=1');
-break;
-
- case 'Sticky Posts' :
-$custom_query->query(array('post__in' => get_option( 'sticky_posts' ), 'showposts' =>$mantra_slideNumber,'ignore_sticky_posts' => 1));
-break;
-
- case 'Specific Posts' :
- // Transofm string separated by commas into array
-$pieces_array = explode(",", $mantra_slideSpecific);
-$custom_query->query(array( 'post_type' => 'any', 'showposts' => -1, 'post__in' => $pieces_array, 'ignore_sticky_posts' => 1, 'orderby' => 'post__in' ));
-break;
-
-}
- // Variables i and j for matching slider number with caption number
-$i=0; $j=0;?>
- <div class="slider-wrapper theme-default">
- <div class="ribbon"></div>
- <div id="slider" class="nivoSlider <?php if($mantra_fpsliderarrows=="Visible on Hover"): ?>slider-navhover<?php endif; ?>">
-
- <?php
- // Loop for creating the slides
- if ( $custom_query->have_posts() ) while ( $custom_query->have_posts()) : $custom_query->the_post();
-
- $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ),'slider');
- $i++; ?>
- <a href="<?php the_permalink(); ?>"><img src="<?php echo $image[0]; ?>" alt="" title="#caption<?php echo $i;?>" /></a>
-
- <?php endwhile; // end of the loop.
-?>
-</div>
- <?php
- // Loop for creating the captions
- if ($custom_query->have_posts() ) while ( $custom_query->have_posts() ) : $custom_query->the_post();
- $j++; ?>
-
- <div id="caption<?php echo $j;?>" class="nivo-html-caption">
- <?php the_title("<h2>","</h2>");the_excerpt(); ?>
- </div>
-
- <?php endwhile; // end of the loop. ?>
-
- </div>
-
-<?php } else {
-
-// If Custom Slides have been selected
-?>
- <div class="slider-wrapper theme-default">
- <div class="ribbon"></div>
- <div id="slider" class="nivoSlider <?php if($mantra_fpsliderarrows=="Visible on Hover"): ?>slider-navhover<?php endif; ?>">
- <?php for ($i=1;$i<=5;$i++)
- if(${"mantra_sliderimg$i"}) {?> <a href='<?php echo esc_url(${"mantra_sliderlink$i"}) ?>'><img src='<?php echo esc_url(${"mantra_sliderimg$i"}) ?>' alt="" <?php if (${"mantra_slidertitle$i"} || ${"mantra_slidertext$i"} ) { ?>title="#caption<?php echo $i;?>" <?php }?> /></a><?php } ?>
- </div>
- <?php for ($i=1;$i<=5;$i++) { ?>
- <div id="caption<?php echo $i;?>" class="nivo-html-caption">
- <?php echo '<h2>'.${"mantra_slidertitle$i"}.'</h2>'.${"mantra_slidertext$i"} ?>
- </div>
- <?php } ?>
-</div>
-<?php }
-
-// Second FrontPage title
- if($mantra_fronttext2) {?><div id="front-text2"> <h1><?php echo esc_attr($mantra_fronttext2) ?> </h1></div><?php }
-
-// Frontpage columns
- if($mantra_nrcolumns) { ?>
-<div id="front-columns">
- <div id="column1">
- <a href="<?php echo esc_url($mantra_columnlink1) ?>"> <div class="column-image" ><img src="<?php echo esc_url($mantra_columnimg1) ?>" id="columnImage1" alt="" /> </div> <h3><?php echo $mantra_columntitle1 ?></h3> </a><div class="column-text"><?php echo do_shortcode ($mantra_columntext1 ); ?></div>
- <?php if($mantra_columnreadmore) {?> <div class="columnmore"> <a href="<?php echo esc_url($mantra_columnlink1) ?>"><?php echo esc_attr($mantra_columnreadmore) ?> &raquo;</a> </div><?php } ?>
- </div>
-<?php if($mantra_nrcolumns != '1') { ?>
- <div id="column2">
- <a href="<?php echo esc_url($mantra_columnlink2) ?>"> <div class="column-image" ><img src="<?php echo esc_url($mantra_columnimg2) ?>" id="columnImage2" alt="" /> </div> <h3><?php echo $mantra_columntitle2 ?></h3> </a><div class="column-text"><?php echo do_shortcode ( $mantra_columntext2 );?></div>
- <?php if($mantra_columnreadmore) {?> <div class="columnmore"> <a href="<?php echo esc_url($mantra_columnlink2) ?>"><?php echo esc_attr($mantra_columnreadmore) ?> &raquo;</a> </div><?php } ?>
- </div>
-<?php if($mantra_nrcolumns != '2') { ?>
- <div id="column3">
- <a href="<?php echo esc_url($mantra_columnlink3) ?>"> <div class="column-image" ><img src="<?php echo esc_url($mantra_columnimg3) ?>" id="columnImage3" alt="" /> </div> <h3><?php echo $mantra_columntitle3 ?></h3> </a><div class="column-text"><?php echo do_shortcode ( $mantra_columntext3 );?></div>
- <?php if($mantra_columnreadmore) {?> <div class="columnmore"> <a href="<?php echo esc_url($mantra_columnlink3) ?>"><?php echo esc_attr($mantra_columnreadmore) ?> &raquo;</a> </div><?php } ?>
- </div>
-<?php if($mantra_nrcolumns == '4') { ?>
- <div id="column4">
- <a href="<?php echo esc_url($mantra_columnlink4) ?>"> <div class="column-image" ><img src="<?php echo esc_url($mantra_columnimg4) ?>" id="columnImage4" alt="" /> </div> <h3><?php echo $mantra_columntitle4 ?></h3> </a><div class="column-text"><?php echo do_shortcode ( $mantra_columntext4 ); ?></div>
- <?php if($mantra_columnreadmore) {?> <div class="columnmore"> <a href="<?php echo esc_url($mantra_columnlink4) ?>"><?php echo esc_attr($mantra_columnreadmore) ?> &raquo;</a> </div><?php } ?>
- </div>
-<?php } } }?>
-</div>
-<?php }
-
- // Frontpage text areas
- if($mantra_fronttext3) {?><div id="front-text3"> <blockquote><?php echo do_shortcode( $mantra_fronttext3 ) ?> </blockquote></div><?php }
- if($mantra_fronttext4) {?><div id="front-text4"> <blockquote><?php echo do_shortcode( $mantra_fronttext4 ) ?> </blockquote></div><?php }
-
- ?>
-</div> <!-- frontpage -->
- <?php } // End of mantra_frontpage_generator
-endif;
-?>
+<?php
+/**
+ * Frontpage generation functions
+ * Creates the slider, the columns, the titles and the extra text
+ *
+ * @package mantra
+ * @subpackage Functions
+ */
+
+if ( ! function_exists( 'mantra_frontpage_css' ) ) :
+function mantra_frontpage_css() {
+ $mantra_options= mantra_get_theme_options();
+ foreach ($mantra_options as $key => $value) { ${"$key"} = $value; }
+ ob_start();
+ echo '<style type="text/css">/* Mantra frontpage CSS */'; ?>
+<?php if ($mantra_fronthideheader) {?> #branding {display:none;} <?php }
+ if ($mantra_fronthidemenu) {?> #access {display:none;} <?php }
+ if ($mantra_fronthidewidget) {?> #colophon {display:none;} <?php }
+ if ($mantra_fronthidefooter) {?> #footer2 {display:none;} <?php }
+ if ($mantra_fronthideback) {?> #main {background:none;} <?php } ?>
+
+.slider-wrapper { display:block; float:none; width:100%; margin:0 auto; }
+
+#slider{
+ max-width:<?php echo $mantra_fpsliderwidth ?>px ;
+ height:<?php echo $mantra_fpsliderheight ?>px ;
+ margin:30px auto 20px; display:block; float:none;
+ border:<?php echo $mantra_fpsliderborderwidth.'px solid '.$mantra_fpsliderbordercolor; ?>; }
+
+#front-text1 h1, #front-text2 h1 { display:block; float:none; margin:35px auto; text-align:center; font-size:32px;
+ clear:both; line-height:32px; font-weight:bold; color:<?php echo $mantra_fronttitlecolor; ?>; }
+
+#front-text2 h1{ font-size:28px; line-height:28px; margin-top:0px; margin-bottom:25px; }
+
+#frontpage blockquote { width:88%; max-width:88% !important; margin-bottom:20px;
+ font-size:16px; line-height:22px; color:#444; }
+
+#frontpage #front-text4 blockquote { font-size:14px; line-height:18px; color:#666; }
+
+#frontpage blockquote:before, #frontpage blockquote:after { content:none; }
+
+#front-columns > div { display:block; width:<?php
+switch ($mantra_nrcolumns) {
+ case 0: break;
+ case 1: echo "95"; break;
+ case 2: echo "45"; break;
+ case 3: echo "29"; break;
+ case 4: echo "21"; break;
+} ?>%; height:auto; margin-left:2%; margin-right:2%; margin-bottom:10px; float:left; }
+
+.column-image { height:<?php echo $mantra_colimageheight ?>px; border:3px solid #eee; }
+
+.theme-default .nivo-controlNav {margin-left:0;}
+<?php
+switch($mantra_fpslidernav):
+ case "Bullets": break;
+ case "Numbers": ?>
+.theme-default .nivo-controlNav {bottom:-40px;}
+.theme-default .nivo-controlNav a { background: none; text-decoration:underline; text-indent:0; }
+<?php break;
+ case "None": ?>
+.theme-default .nivo-controlNav { display:none; }
+<?php break;
+endswitch;
+ echo "</style>\n";
+ $mantra_presentation_page_styling = ob_get_contents();
+ ob_end_clean();
+ return $mantra_presentation_page_styling;
+} // mantra_frontpage_css()
+endif;
+
+if ( ! function_exists( 'mantra_frontpage_generator' ) ) :
+// Front page generator
+function mantra_frontpage_generator() {
+$mantra_options= mantra_get_theme_options();
+foreach ($mantra_options as $key => $value) {
+ ${"$key"} = $value ;
+}
+?>
+
+<script type="text/javascript">
+
+ // Flash animation for columns
+
+
+ jQuery(document).ready(function() {
+ // Slider creation
+ jQuery('#slider').nivoSlider({
+
+ effect: '<?php echo $mantra_fpslideranim; ?>',
+ animSpeed: <?php echo $mantra_fpslidertime ?>,
+ <?php if($mantra_fpsliderarrows=="Hidden") { ?> directionNav: false, <?php }
+ if($mantra_fpsliderarrows=="Always Visible") { ?> directionNav: true, <?php } ?>
+ pauseTime: <?php echo $mantra_fpsliderpause ?>
+
+ });
+
+ jQuery('#front-columns > div img').hover( function() {
+ jQuery(this)
+ .stop()
+ .animate({opacity: 0.5}, 100)
+ .fadeOut(100)
+ .fadeIn(100)
+ .animate({opacity: 0.999}, 100) ;
+ }, function() {jQuery(this).stop();} )
+
+ });
+ </script>
+
+<div id="frontpage">
+<?php
+
+// First FrontPage Title
+if($mantra_fronttext1) {?><div id="front-text1"> <h1><?php echo esc_attr($mantra_fronttext1) ?> </h1></div><?php }
+
+// When a post query has been selected from the Slider type in the admin area
+if ($mantra_slideType != 'Custom Slides') {
+global $post;
+// Initiating query
+$custom_query = new WP_query();
+
+// Switch for Query type
+switch ($mantra_slideType) {
+
+ case 'Latest Posts' :
+$custom_query->query('showposts='.$mantra_slideNumber.'&ignore_sticky_posts=1');
+break;
+
+ case 'Random Posts' :
+$custom_query->query('showposts='.$mantra_slideNumber.'&orderby=rand&ignore_sticky_posts=1');
+break;
+
+ case 'Latest Posts from Category' :
+$custom_query->query('showposts='.$mantra_slideNumber.'&category_name='.$mantra_slideCateg.'&ignore_sticky_posts=1');
+break;
+
+ case 'Random Posts from Category' :
+$custom_query->query('showposts='.$mantra_slideNumber.'&category_name='.$mantra_slideCateg.'&orderby=rand&ignore_sticky_posts=1');
+break;
+
+ case 'Sticky Posts' :
+$custom_query->query(array('post__in' => get_option( 'sticky_posts' ), 'showposts' =>$mantra_slideNumber,'ignore_sticky_posts' => 1));
+break;
+
+ case 'Specific Posts' :
+ // Transofm string separated by commas into array
+$pieces_array = explode(",", $mantra_slideSpecific);
+$custom_query->query(array( 'post_type' => 'any', 'showposts' => -1, 'post__in' => $pieces_array, 'ignore_sticky_posts' => 1, 'orderby' => 'post__in' ));
+break;
+
+}
+ // Variables i and j for matching slider number with caption number
+$i=0; $j=0;?>
+ <div class="slider-wrapper theme-default">
+ <div class="ribbon"></div>
+ <div id="slider" class="nivoSlider <?php if($mantra_fpsliderarrows=="Visible on Hover"): ?>slider-navhover<?php endif; ?>">
+
+ <?php
+ // Loop for creating the slides
+ if ( $custom_query->have_posts() ) while ( $custom_query->have_posts()) : $custom_query->the_post();
+
+ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ),'slider');
+ $i++; ?>
+ <a href="<?php the_permalink(); ?>"><img src="<?php echo $image[0]; ?>" alt="" title="#caption<?php echo $i;?>" /></a>
+
+ <?php endwhile; // end of the loop.
+?>
+</div>
+ <?php
+ // Loop for creating the captions
+ if ($custom_query->have_posts() ) while ( $custom_query->have_posts() ) : $custom_query->the_post();
+ $j++; ?>
+
+ <div id="caption<?php echo $j;?>" class="nivo-html-caption">
+ <?php the_title("<h2>","</h2>");the_excerpt(); ?>
+ </div>
+
+ <?php endwhile; // end of the loop. ?>
+
+ </div>
+
+<?php } else {
+
+// If Custom Slides have been selected
+?>
+ <div class="slider-wrapper theme-default">
+ <div class="ribbon"></div>
+ <div id="slider" class="nivoSlider <?php if($mantra_fpsliderarrows=="Visible on Hover"): ?>slider-navhover<?php endif; ?>">
+ <?php for ($i=1;$i<=5;$i++)
+ if(${"mantra_sliderimg$i"}) {?> <a href='<?php echo esc_url(${"mantra_sliderlink$i"}) ?>'><img src='<?php echo esc_url(${"mantra_sliderimg$i"}) ?>' alt="" <?php if (${"mantra_slidertitle$i"} || ${"mantra_slidertext$i"} ) { ?>title="#caption<?php echo $i;?>" <?php }?> /></a><?php } ?>
+ </div>
+ <?php for ($i=1;$i<=5;$i++) { ?>
+ <div id="caption<?php echo $i;?>" class="nivo-html-caption">
+ <?php echo '<h2>'.${"mantra_slidertitle$i"}.'</h2>'.${"mantra_slidertext$i"} ?>
+ </div>
+ <?php } ?>
+</div>
+<?php }
+
+// Second FrontPage title
+ if($mantra_fronttext2) {?><div id="front-text2"> <h1><?php echo esc_attr($mantra_fronttext2) ?> </h1></div><?php }
+
+// Frontpage columns
+ if($mantra_nrcolumns) { ?>
+<div id="front-columns">
+ <div id="column1">
+ <a href="<?php echo esc_url($mantra_columnlink1) ?>"> <div class="column-image" ><img src="<?php echo esc_url($mantra_columnimg1) ?>" id="columnImage1" alt="" /> </div> <h3><?php echo $mantra_columntitle1 ?></h3> </a><div class="column-text"><?php echo do_shortcode ($mantra_columntext1 ); ?></div>
+ <?php if($mantra_columnreadmore) {?> <div class="columnmore"> <a href="<?php echo esc_url($mantra_columnlink1) ?>"><?php echo esc_attr($mantra_columnreadmore) ?> &raquo;</a> </div><?php } ?>
+ </div>
+<?php if($mantra_nrcolumns != '1') { ?>
+ <div id="column2">
+ <a href="<?php echo esc_url($mantra_columnlink2) ?>"> <div class="column-image" ><img src="<?php echo esc_url($mantra_columnimg2) ?>" id="columnImage2" alt="" /> </div> <h3><?php echo $mantra_columntitle2 ?></h3> </a><div class="column-text"><?php echo do_shortcode ( $mantra_columntext2 );?></div>
+ <?php if($mantra_columnreadmore) {?> <div class="columnmore"> <a href="<?php echo esc_url($mantra_columnlink2) ?>"><?php echo esc_attr($mantra_columnreadmore) ?> &raquo;</a> </div><?php } ?>
+ </div>
+<?php if($mantra_nrcolumns != '2') { ?>
+ <div id="column3">
+ <a href="<?php echo esc_url($mantra_columnlink3) ?>"> <div class="column-image" ><img src="<?php echo esc_url($mantra_columnimg3) ?>" id="columnImage3" alt="" /> </div> <h3><?php echo $mantra_columntitle3 ?></h3> </a><div class="column-text"><?php echo do_shortcode ( $mantra_columntext3 );?></div>
+ <?php if($mantra_columnreadmore) {?> <div class="columnmore"> <a href="<?php echo esc_url($mantra_columnlink3) ?>"><?php echo esc_attr($mantra_columnreadmore) ?> &raquo;</a> </div><?php } ?>
+ </div>
+<?php if($mantra_nrcolumns == '4') { ?>
+ <div id="column4">
+ <a href="<?php echo esc_url($mantra_columnlink4) ?>"> <div class="column-image" ><img src="<?php echo esc_url($mantra_columnimg4) ?>" id="columnImage4" alt="" /> </div> <h3><?php echo $mantra_columntitle4 ?></h3> </a><div class="column-text"><?php echo do_shortcode ( $mantra_columntext4 ); ?></div>
+ <?php if($mantra_columnreadmore) {?> <div class="columnmore"> <a href="<?php echo esc_url($mantra_columnlink4) ?>"><?php echo esc_attr($mantra_columnreadmore) ?> &raquo;</a> </div><?php } ?>
+ </div>
+<?php } } }?>
+</div>
+<?php }
+
+ // Frontpage text areas
+ if($mantra_fronttext3) {?><div id="front-text3"> <blockquote><?php echo do_shortcode( $mantra_fronttext3 ) ?> </blockquote></div><?php }
+ if($mantra_fronttext4) {?><div id="front-text4"> <blockquote><?php echo do_shortcode( $mantra_fronttext4 ) ?> </blockquote></div><?php }
+
+ ?>
+</div> <!-- frontpage -->
+ <?php } // End of mantra_frontpage_generator
+endif;
+?>
diff --git a/themes/mantra/includes/theme-functions.php b/themes/mantra/includes/theme-functions.php
index be80229e..573fd296 100644
--- a/themes/mantra/includes/theme-functions.php
+++ b/themes/mantra/includes/theme-functions.php
@@ -1,475 +1,485 @@
-<?php
-/**
- * Misc functions breadcrumbs / pagination / transient data /back to top button
- *
- * @package mantra
- * @subpackage Functions
- */
-
-
- /**
- * Loads necessary scripts
- * Adds HTML5 tags for IE8
- * Used in header.php
-*/
- function mantra_header_scripts() {
- $mantra_options= mantra_get_theme_options();
-foreach ($mantra_options as $key => $value) {
- ${"$key"} = $value ;
-}
-?>
-<!--[if lt IE 9]>
-<script>
-document.createElement('header');
-document.createElement('nav');
-document.createElement('section');
-document.createElement('article');
-document.createElement('aside');
-document.createElement('footer');
-document.createElement('hgroup');
-</script>
-<![endif]-->
-<script type="text/javascript">
-function makeDoubleDelegate(function1, function2) {
-// concatenate functions
- return function() { if (function1) function1(); if (function2) function2(); }
-}
-
-function mantra_onload() {
-
-<?php if ($mantra_mobile=="Enable") { // If mobile view is enabled ?>
-
- // Add responsive videos
- if (jQuery(window).width() < 800) jQuery(".entry-content").fitVids();
-<?php }
-if (($mantra_s1bg || $mantra_s2bg) ) { ?>
- // Check if sidebars have user colors and if so equalize their heights
- equalizeHeights();<?php } ?>
-}; // mantra_onload
-
-
-jQuery(document).ready(function(){
- // Add custom borders to images
- jQuery("img.alignnone, img.alignleft, img.aligncenter, img.alignright").addClass("<?php echo 'image'.$mantra_image;?>");
-<?php if ($mantra_mobile=="Enable") { // If mobile view is enabled ?>
-
- // Add select navigation to small screens
- jQuery("#access > .menu > ul").tinyNav({
- header: ' = <?php _e('Menu','mantra'); ?> = '
- });
-<?php } ?>
-});
-
-// make sure not to lose previous onload events
-window.onload = makeDoubleDelegate(window.onload, mantra_onload );
-</script>
-<?php
-}
-
-add_action('wp_head','mantra_header_scripts',100);
-
- /**
- * Adds title and description to heaer
- * Used in header.php
-*/
-function mantra_title_and_description() {
- $mantra_options = mantra_get_theme_options();
- foreach ($mantra_options as $key => $value) { ${"$key"} = $value; }
-
- // Header styling and image loading
- // Check if this is a post or page, if it has a thumbnail, and if it's a big one
-
- global $post;
-
- if (get_header_image() != '') { $himgsrc = get_header_image(); }
- if ( is_singular() && has_post_thumbnail( $post->ID ) && ($mantra_fheader == "Enable") && ($image = wp_get_attachment_image_src(get_post_thumbnail_id( $post->ID ), 'header' ) ) && ($image[1] >= HEADER_IMAGE_WIDTH) ):
- $himgsrc = $image[0];
- endif;
-
- if (isset($himgsrc) && ($himgsrc != '')) : echo '<img id="bg_image" alt="" title="" src="'.$himgsrc.'" />'; endif;
-
-?>
-
- <div id="header-container">
-
-
-<?php
- switch ($mantra_siteheader) {
-
- case 'Site Title and Description':
- echo '<div>';
- $heading_tag = ( ( is_home() || is_front_page() ) && !is_page() ) ? 'h1' : 'div';
- echo '<'.$heading_tag.' id="site-title">';
- echo '<span> <a href="'.esc_url( home_url( '/' ) ).'" title="'.esc_attr( get_bloginfo( 'name', 'display' ) ).'" rel="home">'.get_bloginfo( 'name' ).'</a> </span>';
- echo '</'.$heading_tag.'>';
- echo '<div id="site-description" >'.get_bloginfo( 'description' ).'</div></div>';
- break;
-
- case 'Clickable header image' :
- echo '<a href="'.esc_url( home_url( '/' ) ).'" id="linky"></a>' ;
- break;
-
- case 'Custom Logo' :
- if (isset($mantra_logoupload) && ($mantra_logoupload != '')) : echo '<div><a id="logo" href="'.esc_url( home_url( '/' ) ).'" ><img title="" alt="" src="'.$mantra_logoupload.'" /></a></div>'; endif;
- break;
-
- case 'Empty' :
- // nothing to do here
- break;
- }
-
- if ($mantra_socialsdisplay0): mantra_header_socials(); endif;
- echo '</div>';
-
-} // mantra_title_and_description()
-
-
-add_action ('cryout_branding_hook','mantra_title_and_description');
-
- /**
- * Add social icons in header / undermneu left / undermenu right / footer
- * Used in header.php and footer.php
-*/
- function mantra_header_socials() {
- mantra_set_social_icons('sheader');
- }
-
- function mantra_smenul_socials() {
- mantra_set_social_icons('smenul');
- }
-
- function mantra_smenur_socials() {
- mantra_set_social_icons('smenur');
- }
-
- function mantra_footer_socials() {
- mantra_set_social_icons('sfooter');
- }
-
-//if($mantra_socialsdisplay0) add_action('cryout_branding_hook', 'mantra_header_socials');
-if($mantra_socialsdisplay1) add_action('cryout_forbottom_hook', 'mantra_smenul_socials');
-if($mantra_socialsdisplay2) add_action('cryout_forbottom_hook', 'mantra_smenur_socials');
-if($mantra_socialsdisplay3) add_action('cryout_footer_hook', 'mantra_footer_socials',13);
-
-
-if ( ! function_exists( 'mantra_set_social_icons' ) ) :
-/**
- * Social icons function
- */
-function mantra_set_social_icons($id) {
- $cryout_special_keys = array('Mail', 'Skype');
- global $mantra_options;
- foreach ($mantra_options as $key => $value) {
- ${"$key"} = $value ;
- }
- echo '<div class="socials" id="'.$id.'">';
- for ($i=1; $i<=9; $i+=2) {
- $j=$i+1;
- if ( ${"mantra_social$j"} ) {
- if (in_array(${"mantra_social$i"},$cryout_special_keys)) :
- $cryout_current_social = esc_html( ${"mantra_social$j"} );
- else :
- $cryout_current_social = esc_url( ${"mantra_social$j"} );
- endif; ?>
-
- <a target="_blank" rel="nofollow" href="<?php echo $cryout_current_social; ?>" class="socialicons social-<?php echo esc_attr(${"mantra_social$i"}); ?>" title="<?php echo esc_attr(${"mantra_social$i"}); ?>"><img alt="<?php echo esc_attr(${"mantra_social$i"}); ?>" src="<?php echo get_template_directory_uri().'/images/socials/'.${"mantra_social$i"}.'.png'; ?>" /></a><?php
- }
- }
- echo '</div>';
-}
-endif;
-
-
-
- /**
- * Replaces header image with featured image if there is one for single pages
- * Used in header.php
-*/
-
-/* // Moved to custom-styles.php
-
-function mantra_header_featured_image() {
-global $post;
-global $mantra_options;
-foreach ($mantra_options as $key => $value) {
-${"$key"} = $value ;
-}
-// Check if this is a post or page, if it has a thumbnail, and if it's a big one
-if ( is_singular() && has_post_thumbnail( $post->ID ) && $mantra_fheader == "Enable" &&
- ( $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'post-thumbnail' ) ) &&
- $image[1] >= HEADER_IMAGE_WIDTH ) :
- // Houston, we have a new header image!
- //echo get_the_post_thumbnail( $post->ID, 'post-thumbnail' );
- $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), array(HEADER_IMAGE_WIDTH,HEADER_IMAGE_HEIGHT) );
-endif;
-}
-
-
-
-*/
-
-/**
- * Mantra back to top button
- * Creates div for js
-*/
-function mantra_back_top() {
- echo '<div id="toTop"> </div>';
- }
-
-
-if ($mantra_backtop=="Enable") add_action ('cryout_body_hook','mantra_back_top');
-
-
-
- /**
- * Creates breadcrumns with page sublevels and category sublevels.
- */
-function mantra_breadcrumbs() {
-$mantra_options= mantra_get_theme_options();
-foreach ($mantra_options as $key => $value) { ${"$key"} = $value; }
-global $post;
-echo '<div class="breadcrumbs">';
-if (is_page() && !is_front_page() || is_single() || is_category() || is_archive()) {
- echo '<a href="'.esc_url( home_url() ) .'">'.get_bloginfo('name').' &raquo; </a>';
-
- if (is_page()) {
- $ancestors = get_post_ancestors($post);
-
- if ($ancestors) {
- $ancestors = array_reverse($ancestors);
-
- foreach ($ancestors as $crumb) {
- echo '<a href="'.get_permalink($crumb).'">'.get_the_title($crumb).' &raquo; </a>';
- }
- }
- }
-
- if (is_single()) {
- if(has_category()) { $category = get_the_category();
- echo '<a href="'.get_category_link($category[0]->cat_ID).'">'.$category[0]->cat_name.' &raquo; </a>';
- }
- }
-
- if (is_category()) {
- $category = get_the_category();
- echo ''.$category[0]->cat_name.'';
- }
-
- if (is_tag()) {
- echo ''.__('Tag','mantra').' &raquo; '.single_tag_title('', false);
- }
-
- // Current page
- if (is_page() || is_single()) {
- echo ''.get_the_title().'';
- }
- echo '';
- } elseif (is_home() && $mantra_frontpage!="Enable" ) {
- // Front page
- echo '';
- echo '<a href="'.esc_url( home_url() ) .'">'.get_bloginfo('name').'</a> '."&raquo; ";
- _e('Home Page','mantra');
- echo '';
- }
-echo '</div>';
-}
-
-if($mantra_breadcrumbs=="Enable") add_action ('cryout_before_content_hook','mantra_breadcrumbs',0);
-
-
-if ( ! function_exists( 'mantra_pagination' ) ) :
-/**
- * Creates pagination for blog pages.
- */
-function mantra_pagination($pages = '', $range = 2, $prefix ='')
-{
- $showitems = ($range * 2)+1;
-
- global $paged;
- if(empty($paged)) $paged = 1;
-
- if($pages == '')
- {
- global $wp_query;
- $pages = $wp_query->max_num_pages;
- if(!$pages)
- {
- $pages = 1;
- }
- }
-
- if(1 != $pages)
- {
- echo "<div class='pagination_container'><nav class='pagination'>";
- if ($prefix) {echo "<span id='paginationPrefix'>$prefix </span>";}
- if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo "<a href='".get_pagenum_link(1)."'>&laquo;</a>";
- if($paged > 1 && $showitems < $pages) echo "<a href='".get_pagenum_link($paged - 1)."'>&lsaquo;</a>";
-
- for ($i=1; $i <= $pages; $i++)
- {
- if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems ))
- {
- echo ($paged == $i)? "<span class='current'>".$i."</span>":"<a href='".get_pagenum_link($i)."' class='inactive' >".$i."</a>";
- }
- }
-
- if ($paged < $pages && $showitems < $pages) echo "<a href='".get_pagenum_link($paged + 1)."'>&rsaquo;</a>";
- if ($paged < $pages-1 && $paged+$range-1 < $pages && $showitems < $pages) echo "<a href='".get_pagenum_link($pages)."'>&raquo;</a>";
- echo "</nav></div>\n";
- }
-}
-endif;
-
-function mantra_nextpage_links($defaults) {
-$args = array(
-'link_before' => '<em>',
-'link_after' => '</em>',
-);
-$r = wp_parse_args($args, $defaults);
-return $r;
-}
-add_filter('wp_link_pages_args','mantra_nextpage_links');
-
-
-/**
- * Site info
- */
-function mantra_site_info() {
-$mantra_options= mantra_get_theme_options();
-foreach ($mantra_options as $key => $value) {
- ${"$key"} = $value ;
-} ?>
- <div style="text-align:center;clear:both;padding-top:4px;" >
- <a href="<?php echo esc_url( home_url( '/' ) ) ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home">
- <?php bloginfo( 'name' ); ?></a> | <?php _e('Powered by','mantra')?> <a target="_blank" href="<?php echo 'http://www.cryoutcreations.eu';?>" title="<?php echo 'Mantra Theme by '.
- 'Cryout Creations';?>"><?php echo 'Mantra' ?></a> &amp; <a target="_blank" href="<?php echo esc_url('http://wordpress.org/' ); ?>"
- title="<?php esc_attr_e('Semantic Personal Publishing Platform', 'mantra'); ?>"> <?php printf(' %s.', 'WordPress' ); ?>
- </a>
- </div><!-- #site-info -->
-<?php }
-
-add_action('cryout_footer_hook','mantra_site_info',12);
-
-
-/**
- * Copyright text
- */
-function mantra_copyright() {
-$mantra_options= mantra_get_theme_options();
-foreach ($mantra_options as $key => $value) {
- ${"$key"} = $value ;
- }
- echo '<div id="site-copyright">'.$mantra_copyright.'</div>';
-}
-
-
-if ($mantra_copyright != '') add_action('cryout_footer_hook','mantra_copyright',11);
-
-add_action('wp_ajax_nopriv_do_ajax', 'mantra_ajax_function');
-add_action('wp_ajax_do_ajax', 'mantra_ajax_function');
-
-
-/**
-* Retrieves the IDs for images in a gallery.
-* @since mantra 2.1.1
-* @return array List of image IDs from the post gallery.
-*/
-function mantra_get_gallery_images() {
- $images = array();
-
- if ( function_exists( 'get_post_galleries' ) ) {
- $galleries = get_post_galleries( get_the_ID(), false );
- if ( isset( $galleries[0]['ids'] ) )
- $images = explode( ',', $galleries[0]['ids'] );
- } else {
- $pattern = get_shortcode_regex();
- preg_match( "/$pattern/s", get_the_content(), $match );
- $atts = shortcode_parse_atts( $match[3] );
- if ( isset( $atts['ids'] ) )
- $images = explode( ',', $atts['ids'] );
- }
-
- if ( ! $images ) {
- $images = get_posts( array(
- 'fields' => 'ids',
- 'numberposts' => 999,
- 'order' => 'ASC',
- 'orderby' => 'menu_order',
- 'post_mime_type' => 'image',
- 'post_parent' => get_the_ID(),
- 'post_type' => 'attachment',
- ) );
- }
-
- return $images;
-} // mantra_get_gallery_images()
-
-
-/**
-* Checks the browser agent string for mobile ids and adds "mobile" class to body if true
-* @since mantra 2.2.3
-* @return array list of classes.
-*/
-function mantra_mobile_body_class($classes){
-$mantra_options = mantra_get_theme_options();
- if ($mantra_options['mantra_mobile']=="Enable"):
- $browser = $_SERVER['HTTP_USER_AGENT'];
- $keys = 'mobile|android|mobi|tablet|ipad|opera mini|series 60|s60|blackberry';
- if (preg_match("/($keys)/i",$browser)): $classes[] = 'mobile'; endif; // mobile browser detected
- endif;
- return $classes;
-}
-
-add_filter('body_class', 'mantra_mobile_body_class');
-
-
-if ( ! function_exists( 'mantra_ajax_function' ) ) :
-
-function mantra_ajax_function(){
-ob_clean();
-
- // the first part is a SWTICHBOARD that fires specific functions
- // according to the value of Query Var 'fn'
-
- switch($_REQUEST['fn']){
- case 'get_latest_posts':
- $output = mantra_ajax_get_latest_posts($_REQUEST['count'],$_REQUEST['categName']);
- break;
- default:
- $output = 'No function specified, check your jQuery.ajax() call';
- break;
-
- }
-
- // at this point, $output contains some sort of valuable data!
- // Now, convert $output to JSON and echo it to the browser
- // That way, we can recapture it with jQuery and run our success function
-
- $output=json_encode($output);
- if(is_array($output)){
- print_r($output);
- }
- else{
- echo $output;
- }
- die;
-}
-endif;
-
-if ( ! function_exists( 'mantra_ajax_get_latest_posts' ) ) :
-function mantra_ajax_get_latest_posts($count,$categName){
- $testVar='';
- // The Query
- query_posts( 'category_name='.$categName);
- // The Loop
- if ( have_posts() ) : while ( have_posts() ) : the_post();
- $testVar .=the_title("<option>","</option>",0);
- endwhile; else: endif;
-
- // Reset Query
- wp_reset_query();
-
- return $testVar;
-}
-endif;
-?> \ No newline at end of file
+<?php
+/**
+ * Misc functions breadcrumbs / pagination / transient data /back to top button
+ *
+ * @package mantra
+ * @subpackage Functions
+ */
+
+
+ /**
+ * Loads necessary scripts
+ * Adds HTML5 tags for IE8
+ * Used in header.php
+*/
+ function mantra_header_scripts() {
+ $mantra_options= mantra_get_theme_options();
+foreach ($mantra_options as $key => $value) {
+ ${"$key"} = $value ;
+}
+?>
+<!--[if lt IE 9]>
+<script>
+document.createElement('header');
+document.createElement('nav');
+document.createElement('section');
+document.createElement('article');
+document.createElement('aside');
+document.createElement('footer');
+document.createElement('hgroup');
+</script>
+<![endif]-->
+<script type="text/javascript">
+function makeDoubleDelegate(function1, function2) {
+// concatenate functions
+ return function() { if (function1) function1(); if (function2) function2(); }
+}
+
+function mantra_onload() {
+
+<?php if ($mantra_mobile=="Enable") { // If mobile view is enabled ?>
+
+ // Add responsive videos
+ if (jQuery(window).width() < 800) jQuery(".entry-content").fitVids();
+<?php }
+if (($mantra_s1bg || $mantra_s2bg) ) { ?>
+ // Check if sidebars have user colors and if so equalize their heights
+ equalizeHeights();<?php } ?>
+}; // mantra_onload
+
+
+jQuery(document).ready(function(){
+ // Add custom borders to images
+ jQuery("img.alignnone, img.alignleft, img.aligncenter, img.alignright").addClass("<?php echo 'image'.$mantra_image;?>");
+<?php if ($mantra_mobile=="Enable") { // If mobile view is enabled ?>
+
+ // Add select navigation to small screens
+ jQuery("#access > .menu > ul").tinyNav({
+ header: ' = <?php _e('Menu','mantra'); ?> = '
+ });
+<?php } ?>
+});
+
+// make sure not to lose previous onload events
+window.onload = makeDoubleDelegate(window.onload, mantra_onload );
+</script>
+<?php
+}
+
+add_action('wp_head','mantra_header_scripts',100);
+
+ /**
+ * Adds title and description to heaer
+ * Used in header.php
+*/
+function mantra_title_and_description() {
+ $mantra_options = mantra_get_theme_options();
+ foreach ($mantra_options as $key => $value) { ${"$key"} = $value; }
+
+ // Header styling and image loading
+ // Check if this is a post or page, if it has a thumbnail, and if it's a big one
+
+ global $post;
+
+ if (get_header_image() != '') { $himgsrc = get_header_image(); }
+ if ( is_singular() && has_post_thumbnail( $post->ID ) && ($mantra_fheader == "Enable") && ($image = wp_get_attachment_image_src(get_post_thumbnail_id( $post->ID ), 'header' ) ) && ($image[1] >= HEADER_IMAGE_WIDTH) ):
+ $himgsrc = $image[0];
+ endif;
+
+ if (isset($himgsrc) && ($himgsrc != '')) : echo '<img id="bg_image" alt="" title="" src="'.$himgsrc.'" />'; endif;
+
+?>
+
+ <div id="header-container">
+
+
+<?php
+ switch ($mantra_siteheader) {
+
+ case 'Site Title and Description':
+ echo '<div>';
+ $heading_tag = ( ( is_home() || is_front_page() ) && !is_page() ) ? 'h1' : 'div';
+ echo '<'.$heading_tag.' id="site-title">';
+ echo '<span> <a href="'.esc_url( home_url( '/' ) ).'" title="'.esc_attr( get_bloginfo( 'name', 'display' ) ).'" rel="home">'.get_bloginfo( 'name' ).'</a> </span>';
+ echo '</'.$heading_tag.'>';
+ echo '<div id="site-description" >'.get_bloginfo( 'description' ).'</div></div>';
+ break;
+
+ case 'Clickable header image' :
+ echo '<a href="'.esc_url( home_url( '/' ) ).'" id="linky"></a>' ;
+ break;
+
+ case 'Custom Logo' :
+ if (isset($mantra_logoupload) && ($mantra_logoupload != '')) : echo '<div><a id="logo" href="'.esc_url( home_url( '/' ) ).'" ><img title="" alt="" src="'.$mantra_logoupload.'" /></a></div>'; endif;
+ break;
+
+ case 'Empty' :
+ // nothing to do here
+ break;
+ }
+
+ if ($mantra_socialsdisplay0): mantra_header_socials(); endif;
+ echo '</div>';
+
+} // mantra_title_and_description()
+
+
+add_action ('cryout_branding_hook','mantra_title_and_description');
+
+ /**
+ * Add social icons in header / undermneu left / undermenu right / footer
+ * Used in header.php and footer.php
+*/
+ function mantra_header_socials() {
+ mantra_set_social_icons('sheader');
+ }
+
+ function mantra_smenul_socials() {
+ mantra_set_social_icons('smenul');
+ }
+
+ function mantra_smenur_socials() {
+ mantra_set_social_icons('smenur');
+ }
+
+ function mantra_footer_socials() {
+ mantra_set_social_icons('sfooter');
+ }
+
+//if($mantra_socialsdisplay0) add_action('cryout_branding_hook', 'mantra_header_socials');
+if($mantra_socialsdisplay1) add_action('cryout_forbottom_hook', 'mantra_smenul_socials');
+if($mantra_socialsdisplay2) add_action('cryout_forbottom_hook', 'mantra_smenur_socials');
+if($mantra_socialsdisplay3) add_action('cryout_footer_hook', 'mantra_footer_socials',13);
+
+
+if ( ! function_exists( 'mantra_set_social_icons' ) ) :
+/**
+ * Social icons function
+ */
+function mantra_set_social_icons($id) {
+ $cryout_special_keys = array('Mail', 'Skype');
+ global $mantra_options;
+ foreach ($mantra_options as $key => $value) {
+ ${"$key"} = $value ;
+ }
+ echo '<div class="socials" id="'.$id.'">';
+ for ($i=1; $i<=9; $i+=2) {
+ $j=$i+1;
+ if ( ${"mantra_social$j"} ) {
+ if (in_array(${"mantra_social$i"},$cryout_special_keys)) :
+ $cryout_current_social = esc_html( ${"mantra_social$j"} );
+ else :
+ $cryout_current_social = esc_url( ${"mantra_social$j"} );
+ endif; ?>
+
+ <a target="_blank" rel="nofollow" href="<?php echo $cryout_current_social; ?>" class="socialicons social-<?php echo esc_attr(${"mantra_social$i"}); ?>" title="<?php echo esc_attr(${"mantra_social$i"}); ?>"><img alt="<?php echo esc_attr(${"mantra_social$i"}); ?>" src="<?php echo get_template_directory_uri().'/images/socials/'.${"mantra_social$i"}.'.png'; ?>" /></a><?php
+ }
+ }
+ echo '</div>';
+}
+endif;
+
+
+
+ /**
+ * Replaces header image with featured image if there is one for single pages
+ * Used in header.php
+*/
+
+/* // Moved to custom-styles.php
+
+function mantra_header_featured_image() {
+global $post;
+global $mantra_options;
+foreach ($mantra_options as $key => $value) {
+${"$key"} = $value ;
+}
+// Check if this is a post or page, if it has a thumbnail, and if it's a big one
+if ( is_singular() && has_post_thumbnail( $post->ID ) && $mantra_fheader == "Enable" &&
+ ( $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'post-thumbnail' ) ) &&
+ $image[1] >= HEADER_IMAGE_WIDTH ) :
+ // Houston, we have a new header image!
+ //echo get_the_post_thumbnail( $post->ID, 'post-thumbnail' );
+ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), array(HEADER_IMAGE_WIDTH,HEADER_IMAGE_HEIGHT) );
+endif;
+}
+
+
+
+*/
+
+/**
+ * Mantra back to top button
+ * Creates div for js
+*/
+function mantra_back_top() {
+ echo '<div id="toTop"> </div>';
+ }
+
+
+if ($mantra_backtop=="Enable") add_action ('cryout_body_hook','mantra_back_top');
+
+
+
+ /**
+ * Creates breadcrumns with page sublevels and category sublevels.
+ */
+function mantra_breadcrumbs() {
+$mantra_options= mantra_get_theme_options();
+foreach ($mantra_options as $key => $value) { ${"$key"} = $value; }
+global $post;
+echo '<div class="breadcrumbs">';
+if (is_page() && !is_front_page() || is_single() || is_category() || is_archive()) {
+ echo '<a href="'.esc_url( home_url() ) .'">'.get_bloginfo('name').' &raquo; </a>';
+
+ if (is_page()) {
+ $ancestors = get_post_ancestors($post);
+
+ if ($ancestors) {
+ $ancestors = array_reverse($ancestors);
+
+ foreach ($ancestors as $crumb) {
+ echo '<a href="'.get_permalink($crumb).'">'.get_the_title($crumb).' &raquo; </a>';
+ }
+ }
+ }
+
+ if (is_single()) {
+ if(has_category()) { $category = get_the_category();
+ echo '<a href="'.get_category_link($category[0]->cat_ID).'">'.$category[0]->cat_name.' &raquo; </a>';
+ }
+ }
+
+ if (is_category()) {
+ $category = get_the_category();
+ echo ''.$category[0]->cat_name.'';
+ }
+
+ if (is_tag()) {
+ echo ''.__('Tag','mantra').' &raquo; '.single_tag_title('', false);
+ }
+
+ // Current page
+ if (is_page() || is_single()) {
+ echo ''.get_the_title().'';
+ }
+ echo '';
+ } elseif (is_home() && $mantra_frontpage!="Enable" ) {
+ // Front page
+ echo '';
+ echo '<a href="'.esc_url( home_url() ) .'">'.get_bloginfo('name').'</a> '."&raquo; ";
+ _e('Home Page','mantra');
+ echo '';
+ }
+echo '</div>';
+}
+
+if($mantra_breadcrumbs=="Enable") add_action ('cryout_before_content_hook','mantra_breadcrumbs',0);
+
+
+if ( ! function_exists( 'mantra_pagination' ) ) :
+/**
+ * Creates pagination for blog pages.
+ */
+function mantra_pagination($pages = '', $range = 2, $prefix ='')
+{
+ $showitems = ($range * 2)+1;
+
+ global $paged;
+ if(empty($paged)) $paged = 1;
+
+ if($pages == '')
+ {
+ global $wp_query;
+ $pages = $wp_query->max_num_pages;
+ if(!$pages)
+ {
+ $pages = 1;
+ }
+ }
+
+ if(1 != $pages)
+ {
+ echo "<div class='pagination_container'><nav class='pagination'>";
+ if ($prefix) {echo "<span id='paginationPrefix'>$prefix </span>";}
+ if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo "<a href='".get_pagenum_link(1)."'>&laquo;</a>";
+ if($paged > 1 && $showitems < $pages) echo "<a href='".get_pagenum_link($paged - 1)."'>&lsaquo;</a>";
+
+ for ($i=1; $i <= $pages; $i++)
+ {
+ if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems ))
+ {
+ echo ($paged == $i)? "<span class='current'>".$i."</span>":"<a href='".get_pagenum_link($i)."' class='inactive' >".$i."</a>";
+ }
+ }
+
+ if ($paged < $pages && $showitems < $pages) echo "<a href='".get_pagenum_link($paged + 1)."'>&rsaquo;</a>";
+ if ($paged < $pages-1 && $paged+$range-1 < $pages && $showitems < $pages) echo "<a href='".get_pagenum_link($pages)."'>&raquo;</a>";
+ echo "</nav></div>\n";
+ }
+}
+endif;
+
+function mantra_nextpage_links($defaults) {
+$args = array(
+'link_before' => '<em>',
+'link_after' => '</em>',
+);
+$r = wp_parse_args($args, $defaults);
+return $r;
+}
+add_filter('wp_link_pages_args','mantra_nextpage_links');
+
+
+/**
+ * Site info
+ */
+function mantra_site_info() {
+$mantra_options= mantra_get_theme_options();
+foreach ($mantra_options as $key => $value) {
+ ${"$key"} = $value ;
+} ?>
+ <div style="text-align:center;clear:both;padding-top:4px;" >
+ <a href="<?php echo esc_url( home_url( '/' ) ) ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home">
+ <?php bloginfo( 'name' ); ?></a> | <?php _e('Powered by','mantra')?> <a target="_blank" href="<?php echo 'http://www.cryoutcreations.eu';?>" title="<?php echo 'Mantra Theme by '.
+ 'Cryout Creations';?>"><?php echo 'Mantra' ?></a> &amp; <a target="_blank" href="<?php echo esc_url('http://wordpress.org/' ); ?>"
+ title="<?php esc_attr_e('Semantic Personal Publishing Platform', 'mantra'); ?>"> <?php printf(' %s.', 'WordPress' ); ?>
+ </a>
+ </div><!-- #site-info -->
+<?php }
+
+add_action('cryout_footer_hook','mantra_site_info',12);
+
+
+/**
+ * Copyright text
+ */
+function mantra_copyright() {
+$mantra_options= mantra_get_theme_options();
+foreach ($mantra_options as $key => $value) {
+ ${"$key"} = $value ;
+ }
+ echo '<div id="site-copyright">'.$mantra_copyright.'</div>';
+}
+
+
+if ($mantra_copyright != '') add_action('cryout_footer_hook','mantra_copyright',11);
+
+add_action('wp_ajax_nopriv_do_ajax', 'mantra_ajax_function');
+add_action('wp_ajax_do_ajax', 'mantra_ajax_function');
+
+
+/**
+* Retrieves the IDs for images in a gallery.
+* @since mantra 2.1.1
+* @return array List of image IDs from the post gallery.
+*/
+function mantra_get_gallery_images() {
+ $images = array();
+
+ if ( function_exists( 'get_post_galleries' ) ) {
+ $galleries = get_post_galleries( get_the_ID(), false );
+ if ( isset( $galleries[0]['ids'] ) )
+ $images = explode( ',', $galleries[0]['ids'] );
+ } else {
+ $pattern = get_shortcode_regex();
+ preg_match( "/$pattern/s", get_the_content(), $match );
+ $atts = shortcode_parse_atts( $match[3] );
+ if ( isset( $atts['ids'] ) )
+ $images = explode( ',', $atts['ids'] );
+ }
+
+ if ( ! $images ) {
+ $images = get_posts( array(
+ 'fields' => 'ids',
+ 'numberposts' => 999,
+ 'order' => 'ASC',
+ 'orderby' => 'menu_order',
+ 'post_mime_type' => 'image',
+ 'post_parent' => get_the_ID(),
+ 'post_type' => 'attachment',
+ ) );
+ }
+
+ return $images;
+} // mantra_get_gallery_images()
+
+
+/**
+* Checks the browser agent string for mobile ids and adds "mobile" class to body if true
+* @since mantra 2.2.3
+* @return array list of classes.
+*/
+function mantra_mobile_body_class($classes){
+$mantra_options = mantra_get_theme_options();
+ if ($mantra_options['mantra_mobile']=="Enable"):
+ $browser = $_SERVER['HTTP_USER_AGENT'];
+ $keys = 'mobile|android|mobi|tablet|ipad|opera mini|series 60|s60|blackberry';
+ if (preg_match("/($keys)/i",$browser)): $classes[] = 'mobile'; endif; // mobile browser detected
+ endif;
+ return $classes;
+}
+
+add_filter('body_class', 'mantra_mobile_body_class');
+
+
+if ( ! function_exists( 'mantra_ajax_function' ) ) :
+
+function mantra_ajax_function(){
+ob_clean();
+
+ // the first part is a SWTICHBOARD that fires specific functions
+ // according to the value of Query Var 'fn'
+
+ switch($_REQUEST['fn']){
+ case 'get_latest_posts':
+ $output = mantra_ajax_get_latest_posts($_REQUEST['count'],$_REQUEST['categName']);
+ break;
+ default:
+ $output = 'No function specified, check your jQuery.ajax() call';
+ break;
+
+ }
+
+ // at this point, $output contains some sort of valuable data!
+ // Now, convert $output to JSON and echo it to the browser
+ // That way, we can recapture it with jQuery and run our success function
+
+ $output=json_encode($output);
+ if(is_array($output)){
+ print_r($output);
+ }
+ else{
+ echo $output;
+ }
+ die;
+}
+endif;
+
+if ( ! function_exists( 'mantra_ajax_get_latest_posts' ) ) :
+function mantra_ajax_get_latest_posts($count,$categName){
+ $testVar='';
+ // The Query
+ query_posts( 'category_name='.$categName);
+ // The Loop
+ if ( have_posts() ) : while ( have_posts() ) : the_post();
+ $testVar .=the_title("<option>","</option>",0);
+ endwhile; else: endif;
+
+ // Reset Query
+ wp_reset_query();
+
+ return $testVar;
+}
+endif;
+
+
+// Favicon
+function mantra_fav_icon() {
+ global $mantra_options;
+ foreach ($mantra_options as $key => $value) { ${"$key"} = $value ;}
+ echo '<link rel="shortcut icon" href="'.esc_url($mantra_options['mantra_favicon']).'" />';
+ echo '<link rel="apple-touch-icon" href="'.esc_url($mantra_options['mantra_favicon']).'" />';
+}
+
+if ($mantra_options['mantra_favicon']) add_action ('cryout_header_hook','mantra_fav_icon');
diff --git a/themes/mantra/includes/theme-hooks.php b/themes/mantra/includes/theme-hooks.php
index 14ca3bbe..f0d60b97 100644
--- a/themes/mantra/includes/theme-hooks.php
+++ b/themes/mantra/includes/theme-hooks.php
@@ -1,159 +1,159 @@
-<?php
-/*
- * Theme hooks
- *
- * @package mantra
- * @subpackage Functions
- */
-
-/**
- * HEADER.PHP HOOKS
-*/
-
-// Before wp_head hook
-function cryout_header_hook() {
- do_action('cryout_header_hook');
-}
-// SEO hook
-function cryout_seo_hook() {
- do_action('cryout_seo_hook');
-}
-
-// Before wrapper
-function cryout_body_hook() {
- do_action('cryout_body_hook');
-}
-
-// Inside wrapper
-function cryout_wrapper_hook() {
- do_action('cryout_wrapper_hook');
-}
-
-// Inside branding
-function cryout_branding_hook() {
- do_action('cryout_branding_hook');
-}
-
-// Inside access
-function cryout_access_hook() {
- do_action('cryout_access_hook');
-}
-
-// Inside forbottom
-function cryout_forbottom_hook() {
- do_action('cryout_forbottom_hook');
-}
-
-// Breadcrumbs
-function cryout_breadcrumbs_hook() {
- do_action('cryout_breadcrumbs_hook');
-}
-
-/**
- * FOOTER.PHP HOOKS
-*/
-
-// Footer hook
-function cryout_footer_hook() {
- do_action('cryout_footer_hook');
-}
-
-
-/**
- * COMMENTS.PHP HOOKS
-*/
-
-// Before comments hook
-function cryout_before_comments_hook() {
- do_action('cryout_before_comments_hook');
-}
-
-// Actual comments hook
-function cryout_comments_hook() {
- do_action('cryout_comments_hook');
-}
-
-// After comments hook
-function cryout_after_comments_hook() {
- do_action('cryout_after_comments_hook');
-}
-
-// No comments hook
-function cryout_nocomments_hook() {
- do_action('cryout_nocomments_hook');
-}
-
-
-/**
- * SIDEBAR.PHP HOOKS
-*/
-
-// No comments hook
-function cryout_before_primary_widgets_hook() {
- do_action('cryout_before_primary_widgets_hook');
-}
-
-// No comments hook
-function cryout_after_primary_widgets_hook() {
- do_action('cryout_after_primary_widgets_hook');
-}
-
-// No comments hook
-function cryout_before_secondary_widgets_hook() {
- do_action('cryout_before_secondary_widgets_hook');
-}
-
-// No comments hook
-function cryout_after_secondary_widgets_hook() {
- do_action('cryout_after_secondary_widgets_hook');
-}
-
-/**
- * LOOP.PHP HOOKS
-*/
-
-// Before each article hook
-function cryout_before_article_hook() {
- do_action('cryout_before_article_hook');
-}
-
-// After each article hook
-function cryout_after_article_hook() {
- do_action('cryout_after_article_hook');
-}
-
-// After each article title
-function cryout_post_title_hook() {
- do_action('cryout_post_title_hook');
-}
-
-// After each post meta
-function cryout_post_meta_hook() {
- do_action('cryout_post_meta_hook');
-}
-
-// Before the actual post content
-function cryout_post_before_content_hook() {
- do_action('cryout_post_before_content_hook');
-}
-
-// After the actual post content
-function cryout_post_after_content_hook() {
- do_action('cryout_post_after_content_hook');
-}
-
-// After the actual post content
-function cryout_post_footer_hook() {
- do_action('cryout_post_footer_hook');
-}
-
-//Content hooks
-
-function cryout_before_content_hook() {
- do_action('cryout_before_content_hook');
-}
-
-function cryout_after_content_hook() {
- do_action('cryout_after_content_hook');
-}
-?>
+<?php
+/*
+ * Theme hooks
+ *
+ * @package mantra
+ * @subpackage Functions
+ */
+
+/**
+ * HEADER.PHP HOOKS
+*/
+
+// Before wp_head hook
+function cryout_header_hook() {
+ do_action('cryout_header_hook');
+}
+// SEO hook
+function cryout_seo_hook() {
+ do_action('cryout_seo_hook');
+}
+
+// Before wrapper
+function cryout_body_hook() {
+ do_action('cryout_body_hook');
+}
+
+// Inside wrapper
+function cryout_wrapper_hook() {
+ do_action('cryout_wrapper_hook');
+}
+
+// Inside branding
+function cryout_branding_hook() {
+ do_action('cryout_branding_hook');
+}
+
+// Inside access
+function cryout_access_hook() {
+ do_action('cryout_access_hook');
+}
+
+// Inside forbottom
+function cryout_forbottom_hook() {
+ do_action('cryout_forbottom_hook');
+}
+
+// Breadcrumbs
+function cryout_breadcrumbs_hook() {
+ do_action('cryout_breadcrumbs_hook');
+}
+
+/**
+ * FOOTER.PHP HOOKS
+*/
+
+// Footer hook
+function cryout_footer_hook() {
+ do_action('cryout_footer_hook');
+}
+
+
+/**
+ * COMMENTS.PHP HOOKS
+*/
+
+// Before comments hook
+function cryout_before_comments_hook() {
+ do_action('cryout_before_comments_hook');
+}
+
+// Actual comments hook
+function cryout_comments_hook() {
+ do_action('cryout_comments_hook');
+}
+
+// After comments hook
+function cryout_after_comments_hook() {
+ do_action('cryout_after_comments_hook');
+}
+
+// No comments hook
+function cryout_nocomments_hook() {
+ do_action('cryout_nocomments_hook');
+}
+
+
+/**
+ * SIDEBAR.PHP HOOKS
+*/
+
+// No comments hook
+function cryout_before_primary_widgets_hook() {
+ do_action('cryout_before_primary_widgets_hook');
+}
+
+// No comments hook
+function cryout_after_primary_widgets_hook() {
+ do_action('cryout_after_primary_widgets_hook');
+}
+
+// No comments hook
+function cryout_before_secondary_widgets_hook() {
+ do_action('cryout_before_secondary_widgets_hook');
+}
+
+// No comments hook
+function cryout_after_secondary_widgets_hook() {
+ do_action('cryout_after_secondary_widgets_hook');
+}
+
+/**
+ * LOOP.PHP HOOKS
+*/
+
+// Before each article hook
+function cryout_before_article_hook() {
+ do_action('cryout_before_article_hook');
+}
+
+// After each article hook
+function cryout_after_article_hook() {
+ do_action('cryout_after_article_hook');
+}
+
+// After each article title
+function cryout_post_title_hook() {
+ do_action('cryout_post_title_hook');
+}
+
+// After each post meta
+function cryout_post_meta_hook() {
+ do_action('cryout_post_meta_hook');
+}
+
+// Before the actual post content
+function cryout_post_before_content_hook() {
+ do_action('cryout_post_before_content_hook');
+}
+
+// After the actual post content
+function cryout_post_after_content_hook() {
+ do_action('cryout_post_after_content_hook');
+}
+
+// After the actual post content
+function cryout_post_footer_hook() {
+ do_action('cryout_post_footer_hook');
+}
+
+//Content hooks
+
+function cryout_before_content_hook() {
+ do_action('cryout_before_content_hook');
+}
+
+function cryout_after_content_hook() {
+ do_action('cryout_after_content_hook');
+}
+?>
diff --git a/themes/mantra/includes/theme-loop.php b/themes/mantra/includes/theme-loop.php
index 77debcee..7dcbe135 100644
--- a/themes/mantra/includes/theme-loop.php
+++ b/themes/mantra/includes/theme-loop.php
@@ -1,306 +1,302 @@
-<?php /*
- * Main loop related functions
- *
- * @package mantra
- * @subpackage Functions
- */
-
-
- /**
- * Sets the post excerpt length to 40 characters.
- *
- * To override this length in a child theme, remove the filter and add your own
- * function tied to the excerpt_length filter hook.
- *
- * @since Mantra 1.0
- * @return int
- */
-function mantra_excerpt_length( $length ) {
- global $mantra_excerptwords;
- return $mantra_excerptwords;
-}
-add_filter( 'excerpt_length', 'mantra_excerpt_length' );
-
-/**
- * Returns a "Continue Reading" link for excerpts
- *
- * @since mantra 0.5
- * @return string "Continue Reading" link
- */
-function mantra_continue_reading_link() {
- global $mantra_excerptcont;
- return ' <a class="continue-reading-link" href="'. get_permalink() . '">' .$mantra_excerptcont.' <span class="meta-nav">&rarr; </span>' . '</a>';
-}
-
-/**
- * Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis and mantra_continue_reading_link().
- *
- * To override this in a child theme, remove the filter and add your own
- * function tied to the excerpt_more filter hook.
- *
- * @since mantra 0.5
- * @return string An ellipsis
- */
-function mantra_auto_excerpt_more( $more ) {
- global $mantra_excerptdots;
- return $mantra_excerptdots. mantra_continue_reading_link();
-}
-add_filter( 'excerpt_more', 'mantra_auto_excerpt_more' );
-
-
-/**
- * Adds a pretty "Continue Reading" link to custom post excerpts.
- *
- * To override this link in a child theme, remove the filter and add your own
- * function tied to the get_the_excerpt filter hook.
- *
- * @since mantra 0.5
- * @return string Excerpt with a pretty "Continue Reading" link
- */
-function mantra_custom_excerpt_more( $output ) {
- if ( has_excerpt() && ! is_attachment() ) {
- $output .= mantra_continue_reading_link();
- }
- return $output;
-}
-
-add_filter( 'get_the_excerpt', 'mantra_custom_excerpt_more' );
-
-/**
- * Adds a "Continue Reading" link to post excerpts created using the <!--more--> tag.
- *
- * To override this link in a child theme, remove the filter and add your own
- * function tied to the the_content_more_link filter hook.
- *
- * @since mantra 2.1
- * @return string Excerpt with a pretty "Continue Reading" link
- */
-function mantra_more_link($more_link, $more_link_text) {
- global $mantra_excerptcont;
- $new_link_text = $mantra_excerptcont;
- if (preg_match("/custom=(.*)/",$more_link_text,$m) ) {
- $new_link_text = $m[1];
- };
- $more_link = str_replace($more_link_text, $new_link_text.' <span class="meta-nav">&rarr; </span>', $more_link);
- $more_link = str_replace('more-link', 'continue-reading-link', $more_link);
- return $more_link;
-}
-add_filter('the_content_more_link', 'mantra_more_link',10,2);
-
-/**
- * Allows post excerpts to contain HTML tags
- * @since mantra 1.8.7
- * @return string Excerpt with most HTML tags intact
- */
-
-function mantra_trim_excerpt($text) {
-global $mantra_excerptwords;
-global $mantra_excerptcont;
-global $mantra_excerptdots;
-$raw_excerpt = $text;
-if ( '' == $text ) {
- //Retrieve the post content.
- $text = get_the_content('');
-
- //Delete all shortcode tags from the content.
- $text = strip_shortcodes( $text );
-
- $text = apply_filters('the_content', $text);
- $text = str_replace(']]>', ']]&gt;', $text);
-
- $allowed_tags = '<a>,<img>,<b>,<strong>,<ul>,<li>,<i>,<h1>,<h2>,<h3>,<h4>,<h5>,<h6>,<pre>,<code>,<em>,<u>,<br>,<p>';
- $text = strip_tags($text, $allowed_tags);
-
- $words = preg_split("/[\n\r\t ]+/", $text, $mantra_excerptwords + 1, PREG_SPLIT_NO_EMPTY);
- if ( count($words) > $mantra_excerptwords ) {
- array_pop($words);
- $text = implode(' ', $words);
- $text = $text .' '.$mantra_excerptdots. ' <a href="'. get_permalink() . '">' .$mantra_excerptcont.' <span class="meta-nav">&rarr; </span>' . '</a>';
- } else {
- $text = implode(' ', $words);
- }
-}
-return apply_filters('wp_trim_excerpt', $text, $raw_excerpt);
-}
-
-
-
-
-if ($mantra_excerpttags=='Enable') {
-remove_filter('get_the_excerpt', 'wp_trim_excerpt');
-add_filter('get_the_excerpt', 'mantra_trim_excerpt');
-}
-
-
-/**
- * Remove inline styles printed when the gallery shortcode is used.
- *
- * Galleries are styled by the theme in Mantra's style.css.
- *
- * @since mantra 0.5
- * @return string The gallery style filter, with the styles themselves removed.
- */
-function mantra_remove_gallery_css( $css ) {
- return preg_replace( "#<style type='text/css'>(.*?)</style>#s", '', $css );
-}
-add_filter( 'gallery_style', 'mantra_remove_gallery_css' );
-
-
-if ( ! function_exists( 'mantra_posted_on' ) ) :
-/**
- * Prints HTML with meta information for the current post—date/time and author.
- *
- * @since mantra 0.5
- */
-function mantra_posted_on() {
-global $mantra_options;
-foreach ($mantra_options as $key => $value) {
- ${"$key"} = $value ;
-}
-
-// If date is hidden don't give it a value
-$date_string='<span class="onDate"> %3$s <span class="bl_sep">|</span> </span>';
-if ($mantra_postdate == "Hide") $date_string='';
-
-// If author is hidden don't give it a value
-$author_string = sprintf( '<span class="author vcard" >'.__( 'By ','mantra'). ' <a class="url fn n" href="%1$s" title="%2$s">%3$s</a> <span class="bl_sep">|</span></span>',
- get_author_posts_url( get_the_author_meta( 'ID' ) ),
- sprintf( esc_attr__( 'View all posts by %s', 'mantra' ), get_the_author() ),
- get_the_author()
- ) ;
-if ($mantra_postauthor == "Hide") $author_string='';
-
-// Print the meta data
- printf( '&nbsp; %4$s '.$date_string.' <span class="bl_categ"> %2$s </span> ',
- 'meta-prep meta-prep-author',
- get_the_category_list( ', ' ),
- sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"><span class="entry-date">%3$s</span> <span class="entry-time"> - %2$s</span></a>',
- get_permalink(),
- esc_attr( get_the_time() ),
- get_the_date()
- ), $author_string
-
- );
-}
-endif;
-
-// Remove category from rel in categry tags.
-add_filter( 'the_category', 'mantra_remove_category_tag' );
-add_filter( 'get_the_category_list', 'mantra_remove_category_tag' );
-
-function mantra_remove_category_tag( $text ) {
-$text = str_replace('rel="category tag"', 'rel="tag"', $text); return $text;
-}
-
-
-if ( ! function_exists( 'mantra_posted_in' ) ) :
-/**
- * Prints HTML with meta information for the current post (category, tags and permalink).
- *
- * @since mantra 0.5
- */
-function mantra_posted_in() {
- // Retrieves tag list of current post, separated by commas.
- $tag_list = get_the_tag_list( '', ', ' );
- if ( $tag_list ) {
- $posted_in = '<span class="bl_posted">'.__( 'Tagged','mantra').' %2$s.</span><span class="bl_bookmark">'.__(' Bookmark the ','mantra').' <a href="%3$s" title="'.__('Permalink to','mantra').' %4$s" rel="bookmark"> '.__('permalink','mantra').'</a>.</span>';
- } elseif ( is_object_in_taxonomy( get_post_type(), 'category' ) ) {
- $posted_in = '<span class="bl_bookmark">'.__( 'Bookmark the ','mantra'). ' <a href="%3$s" title="'.__('Permalink to','mantra').' %4$s" rel="bookmark">'.__('permalink','mantra').'</a>. </span>';
- } else {
- $posted_in = '<span class="bl_bookmark">'.__( 'Bookmark the ','mantra'). ' <a href="%3$s" title="'.__('Permalink to','mantra').' %4$s" rel="bookmark">'.__('permalink','mantra').'</a>. </span>';
- }
- // Prints the string, replacing the placeholders.
- printf(
- $posted_in,
- get_the_category_list( ', ' ),
- $tag_list,
- get_permalink(),
- the_title_attribute( 'echo=0' )
- );
-}
-endif;
-
-if ( ! function_exists( 'mantra_content_nav' ) ) :
-/**
- * Display navigation to next/previous pages when applicable
- */
-function mantra_content_nav( $nav_id ) {
- global $wp_query;
-
- if ( $wp_query->max_num_pages > 1 ) : ?>
- <nav id="<?php echo $nav_id; ?>" class="navigation">
- <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&laquo;</span> Older posts', 'mantra' ) ); ?></div>
- <div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">&raquo;</span>', 'mantra' ) ); ?></div>
- </nav><!-- #nav-above -->
- <?php endif;
-}
-endif; // mantra_content_nav
-
-// Custom image size for use with post thumbnails
-if($mantra_fcrop)
-add_image_size( 'custom', $mantra_fwidth, $mantra_fheight, true );
-else
-add_image_size( 'custom', $mantra_fwidth, $mantra_fheight );
-
-
-function cryout_echo_first_image ($postID)
-{
- $args = array(
- 'numberposts' => 1,
- 'order'=> 'ASC',
- 'post_mime_type' => 'image',
- 'post_parent' => $postID,
- 'post_status' => 'any',
- 'post_type' => 'any'
- );
-
- $attachments = get_children( $args );
- //print_r($attachments);
-
- if ($attachments) {
- foreach($attachments as $attachment) {
- $image_attributes = wp_get_attachment_image_src( $attachment->ID, 'custom' ) ? wp_get_attachment_image_src( $attachment->ID, 'custom' ) : wp_get_attachment_image_src( $attachment->ID, 'custom' );
-
- return $image_attributes[0];
-
- }
- }
-}
-
-if ( ! function_exists( 'mantra_set_featured_thumb' ) ) :
-/**
- * Adds a post thumbnail and if one doesn't exist the first image from the post is used.
- */
-
-function mantra_set_featured_thumb() {
- global $mantra_options;
- foreach ($mantra_options as $key => $value) {
- ${"$key"} = $value ;
-}
-global $post;
-$image_src = cryout_echo_first_image($post->ID);
-
- if ( function_exists("has_post_thumbnail") && has_post_thumbnail() && $mantra_fpost=='Enable')
- the_post_thumbnail( 'custom', array("class" => "align".strtolower($mantra_falign)." post_thumbnail" ) );
-
- else if ($mantra_fpost=='Enable' && $mantra_fauto=="Enable" && $image_src && ($mantra_excerptarchive != "Full Post" || $mantra_excerpthome != "Full Post"))
- echo '<a title="'.the_title_attribute('echo=0').'" href="'.get_permalink().'" ><img width="'.$mantra_fwidth.'" title="" alt="" class="align'.strtolower($mantra_falign).' post_thumbnail" src="'.$image_src.'"></a>' ;
-
- }
-endif; // mantra_set_featured_thumb
-
-
-
-if ($mantra_fpost=='Enable' && $mantra_fpostlink) add_filter( 'post_thumbnail_html', 'mantra_thumbnail_link', 10, 3 );
-
-/**
- * The thumbnail gets a link to the post's page
- */
-
-function mantra_thumbnail_link( $html, $post_id, $post_image_id ) {
-
- $html = '<a href="' . get_permalink( $post_id ) . '" title="' . esc_attr( get_post_field( 'post_title', $post_id ) ) . '" alt="' . esc_attr( get_post_field( 'post_title', $post_id ) ) . '">' . $html . '</a>';
- return $html;
-
-}
-?> \ No newline at end of file
+<?php /*
+ * Main loop related functions
+ *
+ * @package mantra
+ * @subpackage Functions
+ */
+
+
+ /**
+ * Sets the post excerpt length to 40 characters.
+ *
+ * To override this length in a child theme, remove the filter and add your own
+ * function tied to the excerpt_length filter hook.
+ *
+ * @since Mantra 1.0
+ * @return int
+ */
+function mantra_excerpt_length( $length ) {
+ global $mantra_excerptwords;
+ return $mantra_excerptwords;
+}
+add_filter( 'excerpt_length', 'mantra_excerpt_length' );
+
+/**
+ * Returns a "Continue Reading" link for excerpts
+ *
+ * @since mantra 0.5
+ * @return string "Continue Reading" link
+ */
+function mantra_continue_reading_link() {
+ global $mantra_excerptcont;
+ return ' <a class="continue-reading-link" href="'. get_permalink() . '">' .$mantra_excerptcont.' <span class="meta-nav">&rarr; </span>' . '</a>';
+}
+
+/**
+ * Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis and mantra_continue_reading_link().
+ *
+ * To override this in a child theme, remove the filter and add your own
+ * function tied to the excerpt_more filter hook.
+ *
+ * @since mantra 0.5
+ * @return string An ellipsis
+ */
+function mantra_auto_excerpt_more( $more ) {
+ global $mantra_excerptdots;
+ return $mantra_excerptdots. mantra_continue_reading_link();
+}
+add_filter( 'excerpt_more', 'mantra_auto_excerpt_more' );
+
+
+/**
+ * Adds a pretty "Continue Reading" link to custom post excerpts.
+ *
+ * To override this link in a child theme, remove the filter and add your own
+ * function tied to the get_the_excerpt filter hook.
+ *
+ * @since mantra 0.5
+ * @return string Excerpt with a pretty "Continue Reading" link
+ */
+function mantra_custom_excerpt_more( $output ) {
+ if ( has_excerpt() && ! is_attachment() ) {
+ $output .= mantra_continue_reading_link();
+ }
+ return $output;
+}
+
+add_filter( 'get_the_excerpt', 'mantra_custom_excerpt_more' );
+
+/**
+ * Adds a "Continue Reading" link to post excerpts created using the <!--more--> tag.
+ *
+ * To override this link in a child theme, remove the filter and add your own
+ * function tied to the the_content_more_link filter hook.
+ *
+ * @since mantra 2.1
+ * @return string Excerpt with a pretty "Continue Reading" link
+ */
+function mantra_more_link($more_link, $more_link_text) {
+ global $mantra_excerptcont;
+ $new_link_text = $mantra_excerptcont;
+ if (preg_match("/custom=(.*)/",$more_link_text,$m) ) {
+ $new_link_text = $m[1];
+ };
+ $more_link = str_replace($more_link_text, $new_link_text.' <span class="meta-nav">&rarr; </span>', $more_link);
+ $more_link = str_replace('more-link', 'continue-reading-link', $more_link);
+ return $more_link;
+}
+add_filter('the_content_more_link', 'mantra_more_link',10,2);
+
+/**
+ * Allows post excerpts to contain HTML tags
+ * @since mantra 1.8.7
+ * @return string Excerpt with most HTML tags intact
+ */
+
+function mantra_trim_excerpt($text) {
+global $mantra_excerptwords;
+global $mantra_excerptcont;
+global $mantra_excerptdots;
+$raw_excerpt = $text;
+if ( '' == $text ) {
+ //Retrieve the post content.
+ $text = get_the_content('');
+
+ //Delete all shortcode tags from the content.
+ $text = strip_shortcodes( $text );
+
+ $text = apply_filters('the_content', $text);
+ $text = str_replace(']]>', ']]&gt;', $text);
+
+ $allowed_tags = '<a>,<img>,<b>,<strong>,<ul>,<li>,<i>,<h1>,<h2>,<h3>,<h4>,<h5>,<h6>,<pre>,<code>,<em>,<u>,<br>,<p>';
+ $text = strip_tags($text, $allowed_tags);
+
+ $words = preg_split("/[\n\r\t ]+/", $text, $mantra_excerptwords + 1, PREG_SPLIT_NO_EMPTY);
+ if ( count($words) > $mantra_excerptwords ) {
+ array_pop($words);
+ $text = implode(' ', $words);
+ $text = $text .' '.$mantra_excerptdots. ' <a href="'. get_permalink() . '">' .$mantra_excerptcont.' <span class="meta-nav">&rarr; </span>' . '</a>';
+ } else {
+ $text = implode(' ', $words);
+ }
+}
+return apply_filters('wp_trim_excerpt', $text, $raw_excerpt);
+}
+
+
+
+
+if ($mantra_excerpttags=='Enable') {
+remove_filter('get_the_excerpt', 'wp_trim_excerpt');
+add_filter('get_the_excerpt', 'mantra_trim_excerpt');
+}
+
+
+/**
+ * Remove inline styles printed when the gallery shortcode is used.
+ *
+ * Galleries are styled by the theme in Mantra's style.css.
+ *
+ * @since mantra 0.5
+ * @return string The gallery style filter, with the styles themselves removed.
+ */
+function mantra_remove_gallery_css( $css ) {
+ return preg_replace( "#<style type='text/css'>(.*?)</style>#s", '', $css );
+}
+add_filter( 'gallery_style', 'mantra_remove_gallery_css' );
+
+
+if ( ! function_exists( 'mantra_posted_on' ) ) :
+/**
+ * Prints HTML with meta information for the current post—date/time and author.
+ *
+ * @since mantra 0.5
+ */
+function mantra_posted_on() {
+global $mantra_options;
+foreach ($mantra_options as $key => $value) {
+ ${"$key"} = $value ;
+}
+
+
+$date_string = '<time class="onDate date published" datetime="' . get_the_time( 'c' ) . '"> %3$s <span class="bl_sep">|</span> </time>';
+$date_string .= '<time class="updated" datetime="' . get_the_modified_date( 'c' ) . '">' . get_the_modified_date() . '</time>';
+
+// If author is hidden don't give it a value
+$author_string = sprintf( '<span class="author vcard" >'.__( 'By ','mantra'). ' <a class="url fn n" rel="author" href="%1$s" title="%2$s">%3$s</a> <span class="bl_sep">|</span></span>',
+ get_author_posts_url( get_the_author_meta( 'ID' ) ),
+ sprintf( esc_attr__( 'View all posts by %s', 'mantra' ), get_the_author() ),
+ get_the_author()
+ ) ;
+if ($mantra_postauthor == "Hide") $author_string='';
+
+// Print the meta data
+ printf( '&nbsp; %4$s '.$date_string.' <span class="bl_categ"> %2$s </span> ',
+ 'meta-prep meta-prep-author',
+ get_the_category_list( ', ' ),
+ sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"><span class="entry-date">%3$s</span> <span class="entry-time"> - %2$s</span></a>',
+ get_permalink(),
+ esc_attr( get_the_time() ),
+ get_the_date()
+ ), $author_string
+
+ );
+}
+endif;
+
+// Remove category from rel in categry tags.
+add_filter( 'the_category', 'mantra_remove_category_tag' );
+add_filter( 'get_the_category_list', 'mantra_remove_category_tag' );
+
+function mantra_remove_category_tag( $text ) {
+$text = str_replace('rel="category tag"', 'rel="tag"', $text); return $text;
+}
+
+
+if ( ! function_exists( 'mantra_posted_in' ) ) :
+/**
+ * Prints HTML with meta information for the current post (category, tags and permalink).
+ *
+ * @since mantra 0.5
+ */
+function mantra_posted_in() {
+ // Retrieves tag list of current post, separated by commas.
+ $tag_list = get_the_tag_list( '', ', ' );
+ if ( $tag_list ) {
+ $posted_in = '<span class="bl_posted">'.__( 'Tagged','mantra').' %2$s.</span><span class="bl_bookmark">'.__(' Bookmark the ','mantra').' <a href="%3$s" title="'.__('Permalink to','mantra').' %4$s" rel="bookmark"> '.__('permalink','mantra').'</a>.</span>';
+ } elseif ( is_object_in_taxonomy( get_post_type(), 'category' ) ) {
+ $posted_in = '<span class="bl_bookmark">'.__( 'Bookmark the ','mantra'). ' <a href="%3$s" title="'.__('Permalink to','mantra').' %4$s" rel="bookmark">'.__('permalink','mantra').'</a>. </span>';
+ } else {
+ $posted_in = '<span class="bl_bookmark">'.__( 'Bookmark the ','mantra'). ' <a href="%3$s" title="'.__('Permalink to','mantra').' %4$s" rel="bookmark">'.__('permalink','mantra').'</a>. </span>';
+ }
+ // Prints the string, replacing the placeholders.
+ printf(
+ $posted_in,
+ get_the_category_list( ', ' ),
+ $tag_list,
+ get_permalink(),
+ the_title_attribute( 'echo=0' )
+ );
+}
+endif;
+
+if ( ! function_exists( 'mantra_content_nav' ) ) :
+/**
+ * Display navigation to next/previous pages when applicable
+ */
+function mantra_content_nav( $nav_id ) {
+ global $wp_query;
+
+ if ( $wp_query->max_num_pages > 1 ) : ?>
+ <nav id="<?php echo $nav_id; ?>" class="navigation">
+ <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&laquo;</span> Older posts', 'mantra' ) ); ?></div>
+ <div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">&raquo;</span>', 'mantra' ) ); ?></div>
+ </nav><!-- #nav-above -->
+ <?php endif;
+}
+endif; // mantra_content_nav
+
+// Custom image size for use with post thumbnails
+if($mantra_fcrop)
+add_image_size( 'custom', $mantra_fwidth, $mantra_fheight, true );
+else
+add_image_size( 'custom', $mantra_fwidth, $mantra_fheight );
+
+
+function cryout_echo_first_image ($postID)
+{
+ $args = array(
+ 'numberposts' => 1,
+ 'order'=> 'ASC',
+ 'post_mime_type' => 'image',
+ 'post_parent' => $postID,
+ 'post_status' => 'any',
+ 'post_type' => 'any'
+ );
+
+ $attachments = get_children( $args );
+ //print_r($attachments);
+
+ if ($attachments) {
+ foreach($attachments as $attachment) {
+ $image_attributes = wp_get_attachment_image_src( $attachment->ID, 'custom' ) ? wp_get_attachment_image_src( $attachment->ID, 'custom' ) : wp_get_attachment_image_src( $attachment->ID, 'custom' );
+
+ return $image_attributes[0];
+
+ }
+ }
+}
+
+if ( ! function_exists( 'mantra_set_featured_thumb' ) ) :
+/**
+ * Adds a post thumbnail and if one doesn't exist the first image from the post is used.
+ */
+
+function mantra_set_featured_thumb() {
+ global $mantra_options;
+ foreach ($mantra_options as $key => $value) {
+ ${"$key"} = $value ;
+}
+global $post;
+$image_src = cryout_echo_first_image($post->ID);
+
+ if ( function_exists("has_post_thumbnail") && has_post_thumbnail() && $mantra_fpost=='Enable')
+ the_post_thumbnail( 'custom', array("class" => "align".strtolower($mantra_falign)." post_thumbnail" ) );
+
+ else if ($mantra_fpost=='Enable' && $mantra_fauto=="Enable" && $image_src && ($mantra_excerptarchive != "Full Post" || $mantra_excerpthome != "Full Post"))
+ echo '<a title="'.the_title_attribute('echo=0').'" href="'.get_permalink().'" ><img width="'.$mantra_fwidth.'" title="" alt="" class="align'.strtolower($mantra_falign).' post_thumbnail" src="'.$image_src.'"></a>' ;
+
+ }
+endif; // mantra_set_featured_thumb
+
+if ($mantra_fpost=='Enable' && $mantra_fpostlink) add_filter( 'post_thumbnail_html', 'mantra_thumbnail_link', 10, 2 );
+
+/**
+ * The thumbnail gets a link to the post's page
+ */
+
+function mantra_thumbnail_link( $html, $post_id ) {
+ $html = '<a href="' . get_permalink( $post_id ) . '" title="' . esc_attr( get_post_field( 'post_title', $post_id ) ) . '">' . $html . '</a>';
+ return $html;
+}
+?>
diff --git a/themes/mantra/includes/theme-setup.php b/themes/mantra/includes/theme-setup.php
index 3502621f..5c42bdf8 100644
--- a/themes/mantra/includes/theme-setup.php
+++ b/themes/mantra/includes/theme-setup.php
@@ -1,432 +1,432 @@
-<?php
-/*
- * Theme setup functions. Theme initialization, theme support , widgets , navigation
- *
- * @package mantra
- * @subpackage Functions
- */
-
-/*
-// Bringing up Mantra Settings page after install
-if ( is_admin() && isset($_GET['activated'] ) && $pagenow == "themes.php" ) {
- wp_redirect( 'themes.php?page=mantra-page' );
-}
-*/
-
-$mantra_totalSize = $mantra_sidebar + $mantra_sidewidth+50;
-
- /**
-
- *
- * @package Cryout Creations
- * @subpackage mantra
- * @since mantra 0.5
- */
-
-/**
- * Set the content width based on the theme's design and stylesheet.
- *
- * Used to set the width of images and content. Should be equal to the width the theme
- * is designed for, generally via the style.css stylesheet.
- */
-if ( ! isset( $content_width ) )
- $content_width = $mantra_sidewidth;
-
-/** Tell WordPress to run mantra_setup() when the 'after_setup_theme' hook is run. */
-add_action( 'after_setup_theme', 'mantra_setup' );
-
-if ( ! function_exists( 'mantra_setup' ) ):
-/**
- * Sets up theme defaults and registers support for various WordPress features.
- *
- * Note that this function is hooked into the after_setup_theme hook, which runs
- * before the init hook. The init hook is too late for some features, such as indicating
- * support post thumbnails.
- *
- * To override mantra_setup() in a child theme, add your own mantra_setup to your child theme's
- * functions.php file.
- *
- * @uses add_theme_support() To add support for post thumbnails and automatic feed links.
- * @uses register_nav_menus() To add support for navigation menus.
- * @uses add_custom_background() To add support for a custom background.
- * @uses add_editor_style() To style the visual editor.
- * @uses load_theme_textdomain() For translation/localization support.
- * @uses add_custom_image_header() To add support for a custom header.
- * @uses register_default_headers() To register the default custom header images provided with the theme.
- * @uses set_post_thumbnail_size() To set a custom post thumbnail size.
- *
- * @since mantra 0.5
- */
-function mantra_setup() {
-
- // This theme styles the visual editor with editor-style.css to match the theme style.
- add_editor_style();
-
- // Support title tag since WP 4.1
- add_theme_support( 'title-tag' );
-
- // This theme uses post thumbnails
- add_theme_support( 'post-thumbnails' );
- set_post_thumbnail_size( 150, 150 ); // default Post Thumbnail dimensions (cropped)
-
- // Add default posts and comments RSS feed links to head
-
- add_theme_support( 'automatic-feed-links' );
- add_theme_support('post-formats', array( 'aside', 'chat', 'gallery', 'image', 'link', 'quote', 'status'));
-
- // Make theme available for translation
- // Translations can be filed in the /languages/ directory
-/**
- * Make theme available for translation
- * Translations can be filed in the /languages/ directory
- */
-load_theme_textdomain( 'mantra', get_template_directory() . '/languages' );
-
-$locale = get_locale();
-$locale_file = get_template_directory() . "/languages/$locale.php";
- if ( is_readable( $locale_file ) )
- require_once( $locale_file );
-
-
-
- // This theme uses wp_nav_menu() in 3 locations.
- register_nav_menus( array(
- 'primary' => __( 'Primary Navigation', 'mantra' ),
- 'top' => __( 'Top Navigation', 'mantra' ),
- 'footer' => __( 'Footer Navigation', 'mantra' ),
- ) );
-
- // This theme allows users to set a custom background
- add_theme_support( 'custom-background' );
-
- // We'll be using post thumbnails for custom header images on posts and pages.
- // We want them to be the same size as the header.
- // Larger images will be auto-cropped to fit, smaller ones will be ignored. See header.php.
- global $mantra_hheight;
- $mantra_hheight=(int)$mantra_hheight;
- global $mantra_totalSize;
- define( 'HEADER_IMAGE_WIDTH', apply_filters( 'mantra_header_image_width', $mantra_totalSize ) );
- define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'mantra_header_image_height', $mantra_hheight) );
- //set_post_thumbnail_size( HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true );
- add_image_size('header',HEADER_IMAGE_WIDTH,HEADER_IMAGE_HEIGHT,true);
-
- global $mantra_fpsliderwidth;
- global $mantra_fpsliderheight;
- add_image_size('slider',$mantra_fpsliderwidth,$mantra_fpsliderheight,true);
- // Add a way for the custom header to be styled in the admin panel that controls
- // custom headers. See mantra_admin_header_style(), below.
- define( 'NO_HEADER_TEXT', true );
- add_theme_support( 'custom-header' );
-
- // ... and thus ends the changeable header business.
-
-
-// Backwards compatibility with pre 3.4 versions for custom background and header
-
- // Default custom headers packaged with the theme. %s is a placeholder for the theme template directory URI.
- register_default_headers( array(
- 'mantra' => array(
- 'url' => '%s/images/headers/mantra.png',
- 'thumbnail_url' => '%s/images/headers/mantra-thumbnail.png',
- // translators: header image description
- 'description' => __( 'mantra', 'mantra' )
- ),
- ) );
-}
-endif;
-
-// remove obsolete mantra functions action hooks
-if ( ! function_exists( 'mantra_remove_obsolete_functions' ) ) :
-function mantra_remove_obsolete_functions() {
- remove_filter( 'wp_title', 'mantra_filter_wp_title' );
- remove_filter('wp_title_rss','mantra_filter_wp_title_rss');
-}
-add_action('init','mantra_remove_obsolete_functions');
-endif;
-
-// Backwards compatibility for the title-tag
-if ( ! function_exists( '_wp_render_title_tag' ) ) :
- add_action( 'wp_head', 'mantra_render_title' );
- add_filter( 'wp_title', 'mantra_filter_wp_title2' );
- add_filter('wp_title_rss','mantra_filter_wp_title_rss2');
-endif;
-
-function mantra_render_title() { ?>
- <title><?php wp_title( '', true, 'right' ); ?></title>
-<?php }
-
-function mantra_filter_wp_title2( $title ) {
- // Get the Site Name
- $site_name = get_bloginfo( 'name' );
- // Prepend name
- $filtered_title = (((strlen($site_name)>0)&&(strlen($title)>0))?$title.' - '.$site_name:$title.$site_name);
- // Get the Site Description
- $site_description = get_bloginfo( 'description' );
- // If site front page, append description
- if ( (is_home() || is_front_page()) && $site_description ) {
- // Append Site Description to title
- $filtered_title = ((strlen($site_name)>0)&&(strlen($site_description)>0))?$site_name. " | ".$site_description:$site_name.$site_description;
- }
- // Add pagination if that's the case
- global $page, $paged;
- if ( $paged >= 2 || $page >= 2 )
- $filtered_title .= ' | ' . sprintf( __( 'Page %s', 'mantra' ), max( $paged, $page ) );
-
- // Return the modified title
- return $filtered_title;
-}
-
-function nirvana_filter_wp_title_rss2($title) {
- return ' ';
-}
-
-if ( ! function_exists( 'mantra_admin_header_style' ) ) :
-/**
- * Styles the header image displayed on the Appearance > Header admin panel.
- *
- * Referenced via add_custom_image_header() in mantra_setup().
- *
- * @since mantra 0.5
- */
-function mantra_admin_header_style() {
-?>
-<style type="text/css">
-/* Shows the same border as on front end */
-#headimg {
- border-bottom: 1px solid #000;
- border-top: 4px solid #000;
-}
-/* If NO_HEADER_TEXT is false, you would style the text with these selectors:
- #headimg #name { }
- #headimg #desc { }
-*/
-</style>
-<?php
-}
-endif;
-
-/**
- * Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link.
- *
- * To override this in a child theme, remove the filter and optionally add
- * your own function tied to the wp_page_menu_args filter hook.
- *
- * @since mantra 0.5
- */
-function mantra_page_menu_args( $args ) {
- $args['show_home'] = true;
- return $args;
-}
-add_filter( 'wp_page_menu_args', 'mantra_page_menu_args' );
-
-/**
- * Create menus
- */
-
-// TOP MENU
-function mantra_top_menu() {
- if ( has_nav_menu( 'top' ) ) wp_nav_menu( array( 'container' => 'nav', 'container_class' => 'topmenu', 'theme_location' => 'top', 'depth' => 1 ) );
- }
-
- add_action ('cryout_wrapper_hook','mantra_top_menu');
-
- // MAIN MENU
- function mantra_main_menu() {
- /* Allow screen readers / text browsers to skip the navigation menu and get right to the good stuff */ ?>
-<div class="skip-link screen-reader-text"><a href="#content" title="<?php esc_attr_e( 'Skip to content', 'mantra' ); ?>"><?php _e( 'Skip to content', 'mantra' ); ?></a></div>
-<?php /* Main navigation menu. If one isn't filled out, wp_nav_menu falls back to wp_page_menu. The menu assiged to the primary position is the one used. If none is assigned, the menu with the lowest ID is used. */
-wp_nav_menu( array( 'container_class' => 'menu', 'menu_id' =>'prime_nav', 'theme_location' => 'primary' ) );
-}
-
-add_action ('cryout_access_hook','mantra_main_menu');
-
-// FOOTER MENU
- function mantra_footer_menu() {
- if ( has_nav_menu( 'footer' ) ) wp_nav_menu( array( 'container' => 'nav', 'container_class' => 'footermenu', 'theme_location' => 'footer', 'depth' => 1 ) );
- }
-
- add_action ('cryout_footer_hook','mantra_footer_menu',10);
-
-
-/**
- * Register widgetized areas, including two sidebars and four widget-ready columns in the footer.
- *
- * To override mantra_widgets_init() in a child theme, remove the action hook and add your own
- * function tied to the init hook.
- *
- * @since mantra 0.5
- * @uses register_sidebar
- */
-function mantra_widgets_init() {
- // Area 1, located at the top of the sidebar.
- register_sidebar( array(
- 'name' => __( 'Primary Widget Area - Sidebar 1', 'mantra' ),
- 'id' => 'primary-widget-area',
- 'description' => __( 'Primary widget area - Sidebar 1', 'mantra' ),
- 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
- 'after_widget' => '</li>',
- 'before_title' => '<h3 class="widget-title">',
- 'after_title' => '</h3>',
- ) );
-
- // Area 2, located below the Primary Widget Area in the sidebar. Empty by default.
- register_sidebar( array(
- 'name' => __( 'Secondary Widget Area - Sidebar 1', 'mantra' ),
- 'id' => 'secondary-widget-area',
- 'description' => __( 'Secondary widget area - Sidebar 1', 'mantra' ),
- 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
- 'after_widget' => '</li>',
- 'before_title' => '<h3 class="widget-title">',
- 'after_title' => '</h3>',
- ) );
-
- // Area 3 for the second sidebar. Empty be default
- register_sidebar( array(
- 'name' => __( 'Third Widget Area - Sidebar 2', 'mantra' ),
- 'id' => 'third-widget-area',
- 'description' => __( 'Third widget area - Sidebar 2', 'mantra' ),
- 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
- 'after_widget' => '</li>',
- 'before_title' => '<h3 class="widget-title">',
- 'after_title' => '</h3>',
- ) );
-
- // Area 4, located below the Third Widget Area in the second sidebar. Empty by default.
- register_sidebar( array(
- 'name' => __( 'Fourth Widget Area - Sidebar 2', 'mantra' ),
- 'id' => 'fourth-widget-area',
- 'description' => __( 'Fourth widget area - Sidebar 2', 'mantra' ),
- 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
- 'after_widget' => '</li>',
- 'before_title' => '<h3 class="widget-title">',
- 'after_title' => '</h3>',
- ) );
-
- // Area 5, located in the footer. Empty by default.
- register_sidebar( array(
- 'name' => __( 'First Footer Widget Area', 'mantra' ),
- 'id' => 'first-footer-widget-area',
- 'description' => __( 'First footer widget area', 'mantra' ),
- 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
- 'after_widget' => '</li>',
- 'before_title' => '<h3 class="widget-title">',
- 'after_title' => '</h3>',
- ) );
-
- // Area 6, located in the footer. Empty by default.
- register_sidebar( array(
- 'name' => __( 'Second Footer Widget Area', 'mantra' ),
- 'id' => 'second-footer-widget-area',
- 'description' => __( 'Second footer widget area', 'mantra' ),
- 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
- 'after_widget' => '</li>',
- 'before_title' => '<h3 class="widget-title">',
- 'after_title' => '</h3>',
- ) );
-
- // Area 7, located in the footer. Empty by default.
- register_sidebar( array(
- 'name' => __( 'Third Footer Widget Area', 'mantra' ),
- 'id' => 'third-footer-widget-area',
- 'description' => __( 'The third footer widget area', 'mantra' ),
- 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
- 'after_widget' => '</li>',
- 'before_title' => '<h3 class="widget-title">',
- 'after_title' => '</h3>',
- ) );
-
- // Area 8, located in the footer. Empty by default.
- register_sidebar( array(
- 'name' => __( 'Fourth Footer Widget Area', 'mantra' ),
- 'id' => 'fourth-footer-widget-area',
- 'description' => __( 'The fourth footer widget area', 'mantra' ),
- 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
- 'after_widget' => '</li>',
- 'before_title' => '<h3 class="widget-title">',
- 'after_title' => '</h3>',
- ) );
-
- // Area 9, located above the content area. Empty by default.
- register_sidebar( array(
- 'name' => __( 'Above content Widget Area', 'mantra' ),
- 'id' => 'above-content-widget-area',
- 'description' => __( 'Above content Widget Area', 'mantra' ),
- 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
- 'after_widget' => '</li>',
- 'before_title' => '<h3 class="widget-title">',
- 'after_title' => '</h3>',
- ) );
-
- // Area 10, located below the content area. Empty by default.
- register_sidebar( array(
- 'name' => __( 'Below Content Widget Area', 'mantra' ),
- 'id' => 'below-content-widget-area',
- 'description' => __( 'Below Content Widget Area', 'mantra' ),
- 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
- 'after_widget' => '</li>',
- 'before_title' => '<h3 class="widget-title">',
- 'after_title' => '</h3>',
- ) );
-}
-/** Register sidebars by running mantra_widgets_init() on the widgets_init hook. */
-add_action( 'widgets_init', 'mantra_widgets_init' );
-
-
-/**
- * Creates different class names for footer widgets depending on their number.
- * This way they can fit the footer area.
- */
-
-function mantra_footer_sidebar_class() {
- $count = 0;
-
- if ( is_active_sidebar( 'first-footer-widget-area' ) )
- $count++;
-
- if ( is_active_sidebar( 'second-footer-widget-area' ) )
- $count++;
-
- if ( is_active_sidebar( 'third-footer-widget-area' ) )
- $count++;
-
- if ( is_active_sidebar( 'fourth-footer-widget-area' ) )
- $count++;
-
- $class = '';
-
- switch ( $count ) {
- case '1':
- $class = 'one';
- break;
- case '2':
- $class = 'two';
- break;
- case '3':
- $class = 'three';
- break;
- case '4':
- $class = 'four';
- break;
- }
-
- if ( $class )
- echo 'class="footer' . $class . '"';
-}
-
-
- function mantra_above_widget() {
- if ( is_active_sidebar( 'above-content-widget-area' )) { ?>
- <ul class="yoyo">
- <?php dynamic_sidebar( 'above-content-widget-area' ); ?>
- </ul>
- <?php } }
-
-function mantra_below_widget() {
- if ( is_active_sidebar( 'below-content-widget-area' )) { ?>
- <ul class="yoyo">
- <?php dynamic_sidebar( 'below-content-widget-area' ); ?>
- </ul>
- <?php } }
-
-add_action ('cryout_before_content_hook','mantra_above_widget');
+<?php
+/*
+ * Theme setup functions. Theme initialization, theme support , widgets , navigation
+ *
+ * @package mantra
+ * @subpackage Functions
+ */
+
+/*
+// Bringing up Mantra Settings page after install
+if ( is_admin() && isset($_GET['activated'] ) && $pagenow == "themes.php" ) {
+ wp_redirect( 'themes.php?page=mantra-page' );
+}
+*/
+
+$mantra_totalSize = $mantra_sidebar + $mantra_sidewidth+50;
+
+ /**
+
+ *
+ * @package Cryout Creations
+ * @subpackage mantra
+ * @since mantra 0.5
+ */
+
+/**
+ * Set the content width based on the theme's design and stylesheet.
+ *
+ * Used to set the width of images and content. Should be equal to the width the theme
+ * is designed for, generally via the style.css stylesheet.
+ */
+if ( ! isset( $content_width ) )
+ $content_width = $mantra_sidewidth;
+
+/** Tell WordPress to run mantra_setup() when the 'after_setup_theme' hook is run. */
+add_action( 'after_setup_theme', 'mantra_setup' );
+
+if ( ! function_exists( 'mantra_setup' ) ):
+/**
+ * Sets up theme defaults and registers support for various WordPress features.
+ *
+ * Note that this function is hooked into the after_setup_theme hook, which runs
+ * before the init hook. The init hook is too late for some features, such as indicating
+ * support post thumbnails.
+ *
+ * To override mantra_setup() in a child theme, add your own mantra_setup to your child theme's
+ * functions.php file.
+ *
+ * @uses add_theme_support() To add support for post thumbnails and automatic feed links.
+ * @uses register_nav_menus() To add support for navigation menus.
+ * @uses add_custom_background() To add support for a custom background.
+ * @uses add_editor_style() To style the visual editor.
+ * @uses load_theme_textdomain() For translation/localization support.
+ * @uses add_custom_image_header() To add support for a custom header.
+ * @uses register_default_headers() To register the default custom header images provided with the theme.
+ * @uses set_post_thumbnail_size() To set a custom post thumbnail size.
+ *
+ * @since mantra 0.5
+ */
+function mantra_setup() {
+
+ // This theme styles the visual editor with editor-style.css to match the theme style.
+ add_editor_style();
+
+ // Support title tag since WP 4.1
+ add_theme_support( 'title-tag' );
+
+ // This theme uses post thumbnails
+ add_theme_support( 'post-thumbnails' );
+ set_post_thumbnail_size( 150, 150 ); // default Post Thumbnail dimensions (cropped)
+
+ // Add default posts and comments RSS feed links to head
+
+ add_theme_support( 'automatic-feed-links' );
+ add_theme_support('post-formats', array( 'aside', 'chat', 'gallery', 'image', 'link', 'quote', 'status'));
+
+ // Make theme available for translation
+ // Translations can be filed in the /languages/ directory
+/**
+ * Make theme available for translation
+ * Translations can be filed in the /languages/ directory
+ */
+load_theme_textdomain( 'mantra', get_template_directory() . '/languages' );
+
+$locale = get_locale();
+$locale_file = get_template_directory() . "/languages/$locale.php";
+ if ( is_readable( $locale_file ) )
+ require_once( $locale_file );
+
+
+
+ // This theme uses wp_nav_menu() in 3 locations.
+ register_nav_menus( array(
+ 'primary' => __( 'Primary Navigation', 'mantra' ),
+ 'top' => __( 'Top Navigation', 'mantra' ),
+ 'footer' => __( 'Footer Navigation', 'mantra' ),
+ ) );
+
+ // This theme allows users to set a custom background
+ add_theme_support( 'custom-background' );
+
+ // We'll be using post thumbnails for custom header images on posts and pages.
+ // We want them to be the same size as the header.
+ // Larger images will be auto-cropped to fit, smaller ones will be ignored. See header.php.
+ global $mantra_hheight;
+ $mantra_hheight=(int)$mantra_hheight;
+ global $mantra_totalSize;
+ define( 'HEADER_IMAGE_WIDTH', apply_filters( 'mantra_header_image_width', $mantra_totalSize ) );
+ define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'mantra_header_image_height', $mantra_hheight) );
+ //set_post_thumbnail_size( HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true );
+ add_image_size('header',HEADER_IMAGE_WIDTH,HEADER_IMAGE_HEIGHT,true);
+
+ global $mantra_fpsliderwidth;
+ global $mantra_fpsliderheight;
+ add_image_size('slider',$mantra_fpsliderwidth,$mantra_fpsliderheight,true);
+ // Add a way for the custom header to be styled in the admin panel that controls
+ // custom headers. See mantra_admin_header_style(), below.
+ define( 'NO_HEADER_TEXT', true );
+ add_theme_support( 'custom-header' );
+
+ // ... and thus ends the changeable header business.
+
+
+// Backwards compatibility with pre 3.4 versions for custom background and header
+
+ // Default custom headers packaged with the theme. %s is a placeholder for the theme template directory URI.
+ register_default_headers( array(
+ 'mantra' => array(
+ 'url' => '%s/images/headers/mantra.png',
+ 'thumbnail_url' => '%s/images/headers/mantra-thumbnail.png',
+ // translators: header image description
+ 'description' => __( 'mantra', 'mantra' )
+ ),
+ ) );
+}
+endif;
+
+// remove obsolete mantra functions action hooks
+if ( ! function_exists( 'mantra_remove_obsolete_functions' ) ) :
+function mantra_remove_obsolete_functions() {
+ remove_filter( 'wp_title', 'mantra_filter_wp_title' );
+ remove_filter('wp_title_rss','mantra_filter_wp_title_rss');
+}
+add_action('init','mantra_remove_obsolete_functions');
+endif;
+
+// Backwards compatibility for the title-tag
+if ( ! function_exists( '_wp_render_title_tag' ) ) :
+ add_action( 'wp_head', 'mantra_render_title' );
+ add_filter( 'wp_title', 'mantra_filter_wp_title2' );
+ add_filter('wp_title_rss','mantra_filter_wp_title_rss2');
+endif;
+
+function mantra_render_title() { ?>
+ <title><?php wp_title( '', true, 'right' ); ?></title>
+<?php }
+
+function mantra_filter_wp_title2( $title ) {
+ // Get the Site Name
+ $site_name = get_bloginfo( 'name' );
+ // Prepend name
+ $filtered_title = (((strlen($site_name)>0)&&(strlen($title)>0))?$title.' - '.$site_name:$title.$site_name);
+ // Get the Site Description
+ $site_description = get_bloginfo( 'description' );
+ // If site front page, append description
+ if ( (is_home() || is_front_page()) && $site_description ) {
+ // Append Site Description to title
+ $filtered_title = ((strlen($site_name)>0)&&(strlen($site_description)>0))?$site_name. " | ".$site_description:$site_name.$site_description;
+ }
+ // Add pagination if that's the case
+ global $page, $paged;
+ if ( $paged >= 2 || $page >= 2 )
+ $filtered_title .= ' | ' . sprintf( __( 'Page %s', 'mantra' ), max( $paged, $page ) );
+
+ // Return the modified title
+ return $filtered_title;
+}
+
+function nirvana_filter_wp_title_rss2($title) {
+ return ' ';
+}
+
+if ( ! function_exists( 'mantra_admin_header_style' ) ) :
+/**
+ * Styles the header image displayed on the Appearance > Header admin panel.
+ *
+ * Referenced via add_custom_image_header() in mantra_setup().
+ *
+ * @since mantra 0.5
+ */
+function mantra_admin_header_style() {
+?>
+<style type="text/css">
+/* Shows the same border as on front end */
+#headimg {
+ border-bottom: 1px solid #000;
+ border-top: 4px solid #000;
+}
+/* If NO_HEADER_TEXT is false, you would style the text with these selectors:
+ #headimg #name { }
+ #headimg #desc { }
+*/
+</style>
+<?php
+}
+endif;
+
+/**
+ * Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link.
+ *
+ * To override this in a child theme, remove the filter and optionally add
+ * your own function tied to the wp_page_menu_args filter hook.
+ *
+ * @since mantra 0.5
+ */
+function mantra_page_menu_args( $args ) {
+ $args['show_home'] = true;
+ return $args;
+}
+add_filter( 'wp_page_menu_args', 'mantra_page_menu_args' );
+
+/**
+ * Create menus
+ */
+
+// TOP MENU
+function mantra_top_menu() {
+ if ( has_nav_menu( 'top' ) ) wp_nav_menu( array( 'container' => 'nav', 'container_class' => 'topmenu', 'theme_location' => 'top', 'depth' => 1 ) );
+ }
+
+ add_action ('cryout_wrapper_hook','mantra_top_menu');
+
+ // MAIN MENU
+ function mantra_main_menu() {
+ /* Allow screen readers / text browsers to skip the navigation menu and get right to the good stuff */ ?>
+<div class="skip-link screen-reader-text"><a href="#content" title="<?php esc_attr_e( 'Skip to content', 'mantra' ); ?>"><?php _e( 'Skip to content', 'mantra' ); ?></a></div>
+<?php /* Main navigation menu. If one isn't filled out, wp_nav_menu falls back to wp_page_menu. The menu assiged to the primary position is the one used. If none is assigned, the menu with the lowest ID is used. */
+wp_nav_menu( array( 'container_class' => 'menu', 'menu_id' =>'prime_nav', 'theme_location' => 'primary' ) );
+}
+
+add_action ('cryout_access_hook','mantra_main_menu');
+
+// FOOTER MENU
+ function mantra_footer_menu() {
+ if ( has_nav_menu( 'footer' ) ) wp_nav_menu( array( 'container' => 'nav', 'container_class' => 'footermenu', 'theme_location' => 'footer', 'depth' => 1 ) );
+ }
+
+ add_action ('cryout_footer_hook','mantra_footer_menu',10);
+
+
+/**
+ * Register widgetized areas, including two sidebars and four widget-ready columns in the footer.
+ *
+ * To override mantra_widgets_init() in a child theme, remove the action hook and add your own
+ * function tied to the init hook.
+ *
+ * @since mantra 0.5
+ * @uses register_sidebar
+ */
+function mantra_widgets_init() {
+ // Area 1, located at the top of the sidebar.
+ register_sidebar( array(
+ 'name' => __( 'Primary Widget Area - Sidebar 1', 'mantra' ),
+ 'id' => 'primary-widget-area',
+ 'description' => __( 'Primary widget area - Sidebar 1', 'mantra' ),
+ 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
+ 'after_widget' => '</li>',
+ 'before_title' => '<h3 class="widget-title">',
+ 'after_title' => '</h3>',
+ ) );
+
+ // Area 2, located below the Primary Widget Area in the sidebar. Empty by default.
+ register_sidebar( array(
+ 'name' => __( 'Secondary Widget Area - Sidebar 1', 'mantra' ),
+ 'id' => 'secondary-widget-area',
+ 'description' => __( 'Secondary widget area - Sidebar 1', 'mantra' ),
+ 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
+ 'after_widget' => '</li>',
+ 'before_title' => '<h3 class="widget-title">',
+ 'after_title' => '</h3>',
+ ) );
+
+ // Area 3 for the second sidebar. Empty be default
+ register_sidebar( array(
+ 'name' => __( 'Third Widget Area - Sidebar 2', 'mantra' ),
+ 'id' => 'third-widget-area',
+ 'description' => __( 'Third widget area - Sidebar 2', 'mantra' ),
+ 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
+ 'after_widget' => '</li>',
+ 'before_title' => '<h3 class="widget-title">',
+ 'after_title' => '</h3>',
+ ) );
+
+ // Area 4, located below the Third Widget Area in the second sidebar. Empty by default.
+ register_sidebar( array(
+ 'name' => __( 'Fourth Widget Area - Sidebar 2', 'mantra' ),
+ 'id' => 'fourth-widget-area',
+ 'description' => __( 'Fourth widget area - Sidebar 2', 'mantra' ),
+ 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
+ 'after_widget' => '</li>',
+ 'before_title' => '<h3 class="widget-title">',
+ 'after_title' => '</h3>',
+ ) );
+
+ // Area 5, located in the footer. Empty by default.
+ register_sidebar( array(
+ 'name' => __( 'First Footer Widget Area', 'mantra' ),
+ 'id' => 'first-footer-widget-area',
+ 'description' => __( 'First footer widget area', 'mantra' ),
+ 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
+ 'after_widget' => '</li>',
+ 'before_title' => '<h3 class="widget-title">',
+ 'after_title' => '</h3>',
+ ) );
+
+ // Area 6, located in the footer. Empty by default.
+ register_sidebar( array(
+ 'name' => __( 'Second Footer Widget Area', 'mantra' ),
+ 'id' => 'second-footer-widget-area',
+ 'description' => __( 'Second footer widget area', 'mantra' ),
+ 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
+ 'after_widget' => '</li>',
+ 'before_title' => '<h3 class="widget-title">',
+ 'after_title' => '</h3>',
+ ) );
+
+ // Area 7, located in the footer. Empty by default.
+ register_sidebar( array(
+ 'name' => __( 'Third Footer Widget Area', 'mantra' ),
+ 'id' => 'third-footer-widget-area',
+ 'description' => __( 'The third footer widget area', 'mantra' ),
+ 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
+ 'after_widget' => '</li>',
+ 'before_title' => '<h3 class="widget-title">',
+ 'after_title' => '</h3>',
+ ) );
+
+ // Area 8, located in the footer. Empty by default.
+ register_sidebar( array(
+ 'name' => __( 'Fourth Footer Widget Area', 'mantra' ),
+ 'id' => 'fourth-footer-widget-area',
+ 'description' => __( 'The fourth footer widget area', 'mantra' ),
+ 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
+ 'after_widget' => '</li>',
+ 'before_title' => '<h3 class="widget-title">',
+ 'after_title' => '</h3>',
+ ) );
+
+ // Area 9, located above the content area. Empty by default.
+ register_sidebar( array(
+ 'name' => __( 'Above content Widget Area', 'mantra' ),
+ 'id' => 'above-content-widget-area',
+ 'description' => __( 'Above content Widget Area', 'mantra' ),
+ 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
+ 'after_widget' => '</li>',
+ 'before_title' => '<h3 class="widget-title">',
+ 'after_title' => '</h3>',
+ ) );
+
+ // Area 10, located below the content area. Empty by default.
+ register_sidebar( array(
+ 'name' => __( 'Below Content Widget Area', 'mantra' ),
+ 'id' => 'below-content-widget-area',
+ 'description' => __( 'Below Content Widget Area', 'mantra' ),
+ 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
+ 'after_widget' => '</li>',
+ 'before_title' => '<h3 class="widget-title">',
+ 'after_title' => '</h3>',
+ ) );
+}
+/** Register sidebars by running mantra_widgets_init() on the widgets_init hook. */
+add_action( 'widgets_init', 'mantra_widgets_init' );
+
+
+/**
+ * Creates different class names for footer widgets depending on their number.
+ * This way they can fit the footer area.
+ */
+
+function mantra_footer_sidebar_class() {
+ $count = 0;
+
+ if ( is_active_sidebar( 'first-footer-widget-area' ) )
+ $count++;
+
+ if ( is_active_sidebar( 'second-footer-widget-area' ) )
+ $count++;
+
+ if ( is_active_sidebar( 'third-footer-widget-area' ) )
+ $count++;
+
+ if ( is_active_sidebar( 'fourth-footer-widget-area' ) )
+ $count++;
+
+ $class = '';
+
+ switch ( $count ) {
+ case '1':
+ $class = 'one';
+ break;
+ case '2':
+ $class = 'two';
+ break;
+ case '3':
+ $class = 'three';
+ break;
+ case '4':
+ $class = 'four';
+ break;
+ }
+
+ if ( $class )
+ echo 'class="footer' . $class . '"';
+}
+
+
+ function mantra_above_widget() {
+ if ( is_active_sidebar( 'above-content-widget-area' )) { ?>
+ <ul class="yoyo">
+ <?php dynamic_sidebar( 'above-content-widget-area' ); ?>
+ </ul>
+ <?php } }
+
+function mantra_below_widget() {
+ if ( is_active_sidebar( 'below-content-widget-area' )) { ?>
+ <ul class="yoyo">
+ <?php dynamic_sidebar( 'below-content-widget-area' ); ?>
+ </ul>
+ <?php } }
+
+add_action ('cryout_before_content_hook','mantra_above_widget');
add_action ('cryout_after_content_hook','mantra_below_widget'); ?> \ No newline at end of file
diff --git a/themes/mantra/includes/theme-styles.php b/themes/mantra/includes/theme-styles.php
index 1d0a7ef1..0576d6fc 100644
--- a/themes/mantra/includes/theme-styles.php
+++ b/themes/mantra/includes/theme-styles.php
@@ -1,133 +1,133 @@
-<?php
-/*
- * Styles and scripts registration and enqueuing
- *
- * @package mantra
- * @subpackage Functions
- */
-
-// Adding the viewport meta if the mobile view has been enabled
-
-function mantra_mobile_meta() {
-global $mantra_options;
-if ($mantra_options['mantra_zoom'] == 1)
- return '<meta name="viewport" content="width=device-width, user-scalable=yes, initial-scale=1.0, minimum-scale=1.0, maximum-scale=3.0">';
-else return '<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0">';
-}
-
-
-function mantra_register_styles() {
- global $mantra_options;
- foreach ($mantra_options as $key => $value) { ${"$key"} = $value ;}
-
- wp_register_style( 'mantras', get_stylesheet_uri(), NULL, _CRYOUT_THEME_VERSION );
-
- if($mantra_mobile=="Enable") { wp_register_style( 'mantra-mobile', get_template_directory_uri() . '/style-mobile.css', NULL, _CRYOUT_THEME_VERSION );}
-
- wp_register_style( 'mantra_googlefont', esc_attr($mantra_googlefont2 ));
- wp_register_style( 'mantra_googlefonttitle', esc_attr($mantra_googlefonttitle2 ));
- wp_register_style( 'mantra_googlefontside',esc_attr($mantra_googlefontside2) );
- wp_register_style( 'mantra_googlefontsubheader', esc_attr($mantra_googlefontsubheader2) );
-
-}
-
-add_action('init', 'mantra_register_styles' );
-
-
-function mantra_enqueue_styles() {
- global $mantra_options;
- foreach ($mantra_options as $key => $value) { ${"$key"} = $value ;}
-
- wp_enqueue_style( 'mantras');
-
- wp_enqueue_style( 'mantra_googlefont');
- wp_enqueue_style( 'mantra_googlefonttitle');
- wp_enqueue_style( 'mantra_googlefontside');
- wp_enqueue_style( 'mantra_googlefontsubheader');
-
-
-}
-
-add_action('wp_enqueue_scripts', 'mantra_enqueue_styles' );
-
-function mantra_styles_echo() {
- global $mantra_options;
-
- foreach ($mantra_options as $key => $value) { ${"$key"} = $value ;}
-
- echo preg_replace("/[\n\r\t\s]+/"," " ,mantra_custom_styles())."\n";
- if(($mantra_frontpage=="Enable")&&is_front_page()) { echo preg_replace("/[\n\r\t\s]+/"," " ,mantra_frontpage_css())."\n";}
- if($mantra_mobile=="Enable") {wp_enqueue_style( 'mantra-mobile'); echo mantra_mobile_meta();}
- echo preg_replace("/[\n\r\t\s]+/"," " ,mantra_customcss())."\n";
-}
-
-add_action('wp_head', 'mantra_styles_echo');
-
-
-// JS loading and hook into wp_enque_scripts
-
-add_action('wp_head', 'mantra_customjs' );
-
-
-
-
-// Scripts loading and hook into wp_enque_scripts
-
-function mantra_scripts_method() {
-global $mantra_options;
-foreach ($mantra_options as $key => $value) {
- ${"$key"} = $value ;
- }
-
-// If frontend - load the js for the menu and the social icons animations
- if ( !is_admin() ) {
- wp_register_script('cryout-frontend',get_template_directory_uri() . '/js/frontend.js', array('jquery'), _CRYOUT_THEME_VERSION );
- wp_enqueue_script('cryout-frontend');
- // If mantra from page is enabled and the current page is home page - load the nivo slider js
- if($mantra_frontpage == "Enable" && is_front_page()) {
- wp_register_script('cryout-nivoSlider',get_template_directory_uri() . '/js/nivo-slider.js', array('jquery'), _CRYOUT_THEME_VERSION );
- wp_enqueue_script('cryout-nivoSlider');
- }
- }
-
-
- /* We add some JavaScript to pages with the comment form
- * to support sites with threaded comments (when in use).
- */
- if ( is_singular() && get_option( 'thread_comments' ) )
- wp_enqueue_script( 'comment-reply' );
-}
-
-add_action('wp_enqueue_scripts', 'mantra_scripts_method');
-
-/**
- * Adding CSS3 PIE behavior to elements that need it
- */
-function mantra_ie_pie() {
- echo '
-<!--[if lte IE 8]>
-<style type="text/css" media="screen">
- #access ul li,
-.edit-link a ,
- #footer-widget-area .widget-title, .entry-meta,.entry-meta .comments-link,
-.short-button-light, .short-button-dark ,.short-button-color ,blockquote {
- position:relative;
- behavior: url('.get_template_directory_uri().'/js/PIE/PIE.php);
- }
-
-#access ul ul {
--pie-box-shadow:0px 5px 5px #999;
-}
-
-#access ul li.current_page_item, #access ul li.current-menu-item ,
-#access ul li ,#access ul ul ,#access ul ul li, .commentlist li.comment ,.commentlist .avatar,
- .nivo-caption, .theme-default .nivoSlider {
- behavior: url('.get_template_directory_uri().'/js/PIE/PIE.php);
- }
-</style>
-<![endif]-->
-';
-}
-add_action('wp_head', 'mantra_ie_pie', 10);
-
+<?php
+/*
+ * Styles and scripts registration and enqueuing
+ *
+ * @package mantra
+ * @subpackage Functions
+ */
+
+// Adding the viewport meta if the mobile view has been enabled
+
+function mantra_mobile_meta() {
+global $mantra_options;
+if ($mantra_options['mantra_zoom'] == 1)
+ return '<meta name="viewport" content="width=device-width, user-scalable=yes, initial-scale=1.0, minimum-scale=1.0, maximum-scale=3.0">';
+else return '<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0">';
+}
+
+
+function mantra_register_styles() {
+ global $mantra_options;
+ foreach ($mantra_options as $key => $value) { ${"$key"} = $value ;}
+
+ wp_register_style( 'mantras', get_stylesheet_uri(), NULL, _CRYOUT_THEME_VERSION );
+
+ if($mantra_mobile=="Enable") { wp_register_style( 'mantra-mobile', get_template_directory_uri() . '/style-mobile.css', NULL, _CRYOUT_THEME_VERSION );}
+
+ wp_register_style( 'mantra_googlefont', esc_attr($mantra_googlefont2 ));
+ wp_register_style( 'mantra_googlefonttitle', esc_attr($mantra_googlefonttitle2 ));
+ wp_register_style( 'mantra_googlefontside',esc_attr($mantra_googlefontside2) );
+ wp_register_style( 'mantra_googlefontsubheader', esc_attr($mantra_googlefontsubheader2) );
+
+}
+
+add_action('init', 'mantra_register_styles' );
+
+
+function mantra_enqueue_styles() {
+ global $mantra_options;
+ foreach ($mantra_options as $key => $value) { ${"$key"} = $value ;}
+
+ wp_enqueue_style( 'mantras');
+
+ wp_enqueue_style( 'mantra_googlefont');
+ wp_enqueue_style( 'mantra_googlefonttitle');
+ wp_enqueue_style( 'mantra_googlefontside');
+ wp_enqueue_style( 'mantra_googlefontsubheader');
+
+
+}
+
+add_action('wp_enqueue_scripts', 'mantra_enqueue_styles' );
+
+function mantra_styles_echo() {
+ global $mantra_options;
+
+ foreach ($mantra_options as $key => $value) { ${"$key"} = $value ;}
+
+ echo preg_replace("/[\n\r\t\s]+/"," " ,mantra_custom_styles())."\n";
+ if(($mantra_frontpage=="Enable")&&is_front_page()) { echo preg_replace("/[\n\r\t\s]+/"," " ,mantra_frontpage_css())."\n";}
+ if($mantra_mobile=="Enable") {wp_enqueue_style( 'mantra-mobile'); echo mantra_mobile_meta();}
+ echo preg_replace("/[\n\r\t\s]+/"," " ,mantra_customcss())."\n";
+}
+
+add_action('wp_head', 'mantra_styles_echo');
+
+
+// JS loading and hook into wp_enque_scripts
+
+add_action('wp_head', 'mantra_customjs' );
+
+
+
+
+// Scripts loading and hook into wp_enque_scripts
+
+function mantra_scripts_method() {
+global $mantra_options;
+foreach ($mantra_options as $key => $value) {
+ ${"$key"} = $value ;
+ }
+
+// If frontend - load the js for the menu and the social icons animations
+ if ( !is_admin() ) {
+ wp_register_script('cryout-frontend',get_template_directory_uri() . '/js/frontend.js', array('jquery'), _CRYOUT_THEME_VERSION );
+ wp_enqueue_script('cryout-frontend');
+ // If mantra from page is enabled and the current page is home page - load the nivo slider js
+ if($mantra_frontpage == "Enable" && is_front_page()) {
+ wp_register_script('cryout-nivoSlider',get_template_directory_uri() . '/js/nivo-slider.js', array('jquery'), _CRYOUT_THEME_VERSION );
+ wp_enqueue_script('cryout-nivoSlider');
+ }
+ }
+
+
+ /* We add some JavaScript to pages with the comment form
+ * to support sites with threaded comments (when in use).
+ */
+ if ( is_singular() && get_option( 'thread_comments' ) )
+ wp_enqueue_script( 'comment-reply' );
+}
+
+add_action('wp_enqueue_scripts', 'mantra_scripts_method');
+
+/**
+ * Adding CSS3 PIE behavior to elements that need it
+ */
+function mantra_ie_pie() {
+ echo '
+<!--[if lte IE 8]>
+<style type="text/css" media="screen">
+ #access ul li,
+.edit-link a ,
+ #footer-widget-area .widget-title, .entry-meta,.entry-meta .comments-link,
+.short-button-light, .short-button-dark ,.short-button-color ,blockquote {
+ position:relative;
+ behavior: url('.get_template_directory_uri().'/js/PIE/PIE.php);
+ }
+
+#access ul ul {
+-pie-box-shadow:0px 5px 5px #999;
+}
+
+#access ul li.current_page_item, #access ul li.current-menu-item ,
+#access ul li ,#access ul ul ,#access ul ul li, .commentlist li.comment ,.commentlist .avatar,
+ .nivo-caption, .theme-default .nivoSlider {
+ behavior: url('.get_template_directory_uri().'/js/PIE/PIE.php);
+ }
+</style>
+<![endif]-->
+';
+}
+add_action('wp_head', 'mantra_ie_pie', 10);
+
?> \ No newline at end of file