is_module_active() public static method

Check whether or not a Jetpack module is active.
public static is_module_active ( string $module ) : boolean
$module string The slug of a Jetpack module.
return boolean
Beispiel #1
1
    /**
     * Display navigation to next/previous set of posts when applicable.
     */
    function create_paging_nav()
    {
        // Don't print empty markup if there's only one page.
        if ($GLOBALS['wp_query']->max_num_pages < 2) {
            return;
        }
        $pagination_type = get_theme_mod('pagination_type', create_get_default_theme_options('pagination_type'));
        /**
         * Check if navigation type is Jetpack Infinite Scroll and if it is enabled, else goto default pagination
         * if it's active then disable pagination
         */
        if (('infinite-scroll-click' == $pagination_type || 'infinite-scroll-scroll' == $pagination_type) && class_exists('Jetpack') && Jetpack::is_module_active('infinite-scroll')) {
            return false;
        } elseif ('numeric' == $pagination_type && function_exists('the_posts_pagination')) {
            // Previous/next page navigation.
            the_posts_pagination(array('prev_text' => __('Previous page', 'create'), 'next_text' => __('Next page', 'create'), 'before_page_number' => '<span class="meta-nav screen-reader-text">' . __('Page', 'create') . ' </span>'));
        } else {
            ?>
		<nav class="navigation paging-navigation" role="navigation">
			<h1 class="screen-reader-text"><?php 
            _e('Posts navigation', 'create');
            ?>
</h1>
			<div class="nav-links">

				<?php 
            if (get_next_posts_link()) {
                ?>
				<div class="nav-previous"><?php 
                next_posts_link(__('<span class="meta-nav">&larr;</span> Older posts', 'create'));
                ?>
</div>
				<?php 
            }
            ?>

				<?php 
            if (get_previous_posts_link()) {
                ?>
				<div class="nav-next"><?php 
                previous_posts_link(__('Newer posts <span class="meta-nav">&rarr;</span>', 'create'));
                ?>
</div>
				<?php 
            }
            ?>

			</div><!-- .nav-links -->
		</nav><!-- .navigation -->
	<?php 
        }
    }
/**
 * Checks if Jetpack Photon module is enabled.
 *
 * @return boolean
 */
function eduardodomingos_photon_enabled()
{
    if (class_exists('Jetpack') && Jetpack::is_module_active('photon')) {
        return true;
    }
    return false;
}
 protected static function format_module($module_slug)
 {
     $module_data = Jetpack::get_module($module_slug);
     $module = array();
     $module['id'] = $module_slug;
     $module['active'] = Jetpack::is_module_active($module_slug);
     $module['name'] = $module_data['name'];
     $module['short_description'] = $module_data['description'];
     $module['sort'] = $module_data['sort'];
     $module['introduced'] = $module_data['introduced'];
     $module['changed'] = $module_data['changed'];
     $module['free'] = $module_data['free'];
     $module['module_tags'] = $module_data['module_tags'];
     // Fetch the HTML formatted long description
     ob_start();
     if (Jetpack::is_active() && has_action('jetpack_module_more_info_connected_' . $module_slug)) {
         /** This action is documented in class.jetpack-modules-list-table.php */
         do_action('jetpack_module_more_info_connected_' . $module_slug);
     } else {
         /** This action is documented in class.jetpack-modules-list-table.php */
         do_action('jetpack_module_more_info_' . $module_slug);
     }
     $module['description'] = ob_get_clean();
     return $module;
 }
Beispiel #4
0
 function init()
 {
     if (fastfood_is_mobile()) {
         return;
     }
     //Infinite Scroll
     if (Jetpack::is_module_active('infinite-scroll')) {
         //nop
     }
     //Sharedaddy
     if (Jetpack::is_module_active('sharedaddy')) {
         remove_filter('the_content', 'sharing_display', 19);
         remove_filter('the_excerpt', 'sharing_display', 19);
         add_action('fastfood_hook_entry_bottom', array($this, 'sharedaddy'));
     }
     //Carousel
     if (Jetpack::is_module_active('carousel')) {
         //nop
     }
     //Likes
     if (Jetpack::is_module_active('likes')) {
         add_action('fastfood_hook_entry_bottom', array($this, 'likes'));
         remove_filter('the_content', array(Jetpack_Likes::init(), 'post_likes'), 30, 1);
         add_filter('fastfood_filter_likes', array(Jetpack_Likes::init(), 'post_likes'), 30, 1);
     }
 }
function sandwich_myshortcode()
{
    // No need to register our shortcode since it already exists
    // Check if Shortcake exists
    if (!function_exists('shortcode_ui_register_for_shortcode')) {
        return;
    }
    // Only create the UI when in the admin
    if (!is_admin()) {
        return;
    }
    // Register Shortcake UI
    shortcode_ui_register_for_shortcode('myshortcode', array('label' => __('Some Existing Shortcode', 'pbsandwich'), 'listItemImage' => 'dashicons-wordpress', 'attrs' => array(array('label' => __('Content', 'pbsandwich'), 'attr' => 'content', 'type' => 'textarea'), array('label' => __('Some Text', 'pbsandwich'), 'attr' => 'some_text', 'type' => 'text'), array('label' => __('Some Color', 'pbsandwich'), 'attr' => 'some_color', 'type' => 'color', 'value' => '#333333'))));
    // TODO: If the rendered shortcode in the editor NEEDS to be previewed in a logged out state (e.g. login forms)
    // uncomment this and add in your shortcode here.
    // sandwich_add_logged_out_shortcode( 'myshortcode' );
    // Make sure Jetpack is activated
    if (!class_exists('Jetpack')) {
        add_action('print_media_templates', 'sandwich_jetpack_myshortcode_disabled');
        return;
    }
    // Make sure our required Jetpack module is turned on
    if (!Jetpack::is_module_active('some-jetpack-module')) {
        add_action('print_media_templates', 'sandwich_jetpack_myshortcode_disabled');
        return;
    }
}
Beispiel #6
0
/**
 * Load stylesheets for the front end.
 *
 * @since 1.0
 * @access public
 * @return void
 */
function hoot_base_enqueue_styles()
{
    /* Gets ".min" suffix. */
    $suffix = hoot_get_min_suffix();
    /* Load Google Fonts if 'google-fonts' is active. */
    if (current_theme_supports('google-fonts')) {
        wp_enqueue_style('hoot-google-fonts', hoot_google_fonts_enqueue_url(), array(), null);
    }
    /* Load lightSlider style if 'light-slider' is active. */
    if (current_theme_supports('slick-slider')) {
        wp_enqueue_style('slick', trailingslashit(THEME_URI) . "css/slick{$suffix}.css", false, '1.5.9');
        wp_enqueue_style('slick-theme', trailingslashit(THEME_URI) . "css/slick-theme{$suffix}.css", false, '1.5.9');
    }
    /* Load gallery style if 'cleaner-gallery' is active. */
    if (current_theme_supports('cleaner-gallery')) {
        wp_enqueue_style('gallery', trailingslashit(HOOT_CSS) . "gallery{$suffix}.css");
    }
    /* Load gallery styles if Jetpack 'tiled-gallery' module is active */
    if (class_exists('Jetpack') && Jetpack::is_module_active('tiled-gallery')) {
        wp_enqueue_style('gallery', trailingslashit(HOOT_CSS) . "gallery{$suffix}.css");
        wp_enqueue_style('hoot-jetpack', trailingslashit(THEME_URI) . "css/jetpack{$suffix}.css");
    }
    /* Load font awesome if 'font-awesome' is active. */
    if (current_theme_supports('font-awesome')) {
        wp_enqueue_style('font-awesome', trailingslashit(HOOT_CSS) . "font-awesome{$suffix}.css", false, '4.2.0');
    }
}
Beispiel #7
0
 /**
  * Registers the custom post types and adds action/filter handlers, but
  * only if the site supports it
  */
 function maybe_register_cpt()
 {
     // Add an option to enable the CPT
     add_action('admin_init', array($this, 'settings_api_init'));
     // Check on theme switch if theme supports CPT and setting is disabled
     add_action('after_switch_theme', array($this, 'activation_post_type_support'));
     $setting = Jetpack_Options::get_option_and_ensure_autoload(self::OPTION_NAME, '0');
     // Bail early if Testimonial option is not set and the theme doesn't declare support
     if (empty($setting) && !$this->site_supports_custom_post_type()) {
         return;
     }
     if ((!defined('IS_WPCOM') || !IS_WPCOM) && !Jetpack::is_module_active('custom-content-types')) {
         return;
     }
     // Enable Omnisearch for CPT.
     if (class_exists('Jetpack_Omnisearch_Posts')) {
         new Jetpack_Omnisearch_Posts(self::CUSTOM_POST_TYPE);
     }
     // CPT magic
     $this->register_post_types();
     add_action(sprintf('add_option_%s', self::OPTION_NAME), array($this, 'flush_rules_on_enable'), 10);
     add_action(sprintf('update_option_%s', self::OPTION_NAME), array($this, 'flush_rules_on_enable'), 10);
     add_action(sprintf('publish_%s', self::CUSTOM_POST_TYPE), array($this, 'flush_rules_on_first_testimonial'));
     add_action('after_switch_theme', array($this, 'flush_rules_on_switch'));
     // Admin Customization
     add_filter('enter_title_here', array($this, 'change_default_title'));
     add_filter(sprintf('manage_%s_posts_columns', self::CUSTOM_POST_TYPE), array($this, 'edit_title_column_label'));
     add_filter('post_updated_messages', array($this, 'updated_messages'));
     add_action('customize_register', array($this, 'customize_register'));
     // Only add the 'Customize' sub-menu if the theme supports it.
     $num_testimonials = self::count_testimonials();
     if (!empty($num_testimonials) && current_theme_supports(self::CUSTOM_POST_TYPE)) {
         add_action('admin_menu', array($this, 'add_customize_page'));
     }
     if (defined('IS_WPCOM') && IS_WPCOM) {
         // Track all the things
         add_action(sprintf('add_option_%s', self::OPTION_NAME), array($this, 'new_activation_stat_bump'));
         add_action(sprintf('update_option_%s', self::OPTION_NAME), array($this, 'update_option_stat_bump'), 11, 2);
         add_action(sprintf('publish_%s', self::CUSTOM_POST_TYPE), array($this, 'new_testimonial_stat_bump'));
         // Add to Dotcom XML sitemaps
         add_filter('wpcom_sitemap_post_types', array($this, 'add_to_sitemap'));
     } else {
         // Add to Jetpack XML sitemap
         add_filter('jetpack_sitemap_post_types', array($this, 'add_to_sitemap'));
     }
     // Adjust CPT archive and custom taxonomies to obey CPT reading setting
     add_filter('pre_get_posts', array($this, 'query_reading_setting'), 20);
     add_filter('infinite_scroll_settings', array($this, 'infinite_scroll_click_posts_per_page'));
     // Register [jetpack_testimonials] always and
     // register [testimonials] if [testimonials] isn't already set
     add_shortcode('jetpack_testimonials', array($this, 'jetpack_testimonial_shortcode'));
     if (!shortcode_exists('testimonials')) {
         add_shortcode('testimonials', array($this, 'jetpack_testimonial_shortcode'));
     }
     // If CPT was enabled programatically and no CPT items exist when user switches away, disable
     if ($setting && $this->site_supports_custom_post_type()) {
         add_action('switch_theme', array($this, 'deactivation_post_type_support'));
     }
 }
Beispiel #8
0
/**
 * Disable Jetpack features that are not compatible with AMP.
 *
 **/
function amp_jetpack_mods()
{
    if (Jetpack::is_module_active('stats')) {
        add_action('amp_post_template_footer', 'jetpack_amp_add_stats_pixel');
    }
    amp_jetpack_disable_sharing();
    amp_jetpack_disable_related_posts();
}
 private function __construct()
 {
     global $pagenow;
     $jetpack_hide_jitm = Jetpack_Options::get_option('hide_jitm');
     if ('media-new.php' == $pagenow && !Jetpack::is_module_active('photon') && 'hide' != $jetpack_hide_jitm['photon']) {
         add_action('admin_enqueue_scripts', array($this, 'jitm_enqueue_files'));
         add_action('post-plupload-upload-ui', array($this, 'photon_msg'));
     }
 }
 private function __construct()
 {
     if (Jetpack::is_module_active('manage')) {
         add_filter('auto_update_plugin', array($this, 'autoupdate_plugin'), 10, 2);
         add_filter('auto_update_theme', array($this, 'autoupdate_theme'), 10, 2);
         add_filter('auto_update_core', array($this, 'autoupdate_core'), 10, 2);
         add_action('automatic_updates_complete', array($this, 'automatic_updates_complete'), 999, 1);
     }
 }
 function plugins_loaded()
 {
     $this->role = apply_filters('jetpack_force_2fa_cap', 'manage_options');
     // Bail if Jetpack SSO is not active
     if (!class_exists('Jetpack') || !Jetpack::is_module_active('sso')) {
         add_action('admin_notices', array($this, 'admin_notice'));
         return;
     }
     $this->force_2fa();
 }
Beispiel #12
0
/**
 * Our photon hook prefix as this plugin supports both Jetpack Photon and My-Photon
 * @return string. (Either 'jetpack' or 'my');
 */
function photonfill_hook_prefix()
{
    // If photon module is active, then use it over my photon.
    if (class_exists('Jetpack') && Jetpack::is_module_active('photon')) {
        return 'jetpack';
    } elseif (class_exists('My_Photon_Settings') && My_Photon_Settings::get('active')) {
        return 'my';
    }
    return 'jetpack';
}
 static function init()
 {
     if (!Jetpack::is_module_active('sharedaddy')) {
         return false;
     }
     if (!self::$instance) {
         self::$instance = new jetwhats_Sharing_Service();
     }
     return self::$instance;
 }
 protected function setup()
 {
     $this->sharing_service = new Sharing_Service();
     if (!current_user_can('manage_options')) {
         return new WP_Error('forbidden', 'You do not have the capability to manage sharing buttons for this site', 403);
     } else {
         if (!class_exists('Sharing_Service') || !class_exists('Sharing_Source') || method_exists('Jetpack', 'is_module_active') && !Jetpack::is_module_active('sharedaddy')) {
             return new WP_Error('missing_jetpack_module', 'The Sharing module must be activated in order to use this endpoint', 400);
         }
     }
 }
 /**
  * Add Jetpack Dashboard sub-link and point it to AAG if the user can view stats, manage modules or if Protect is active.
  * Otherwise and only if user is allowed to see the Jetpack Admin, the Dashboard sub-link is added but pointed to Apps tab.
  *
  * Works in Dev Mode or when user is connected.
  *
  * @since 4.3.0
  */
 function jetpack_add_dashboard_sub_nav_item()
 {
     if (Jetpack::is_development_mode() || Jetpack::is_active()) {
         global $submenu;
         if (current_user_can('jetpack_manage_modules') || Jetpack::is_module_active('protect') || current_user_can('view_stats')) {
             $submenu['jetpack'][] = array(__('Dashboard', 'jetpack'), 'jetpack_admin_page', Jetpack::admin_url('page=jetpack#/dashboard'));
         } elseif (current_user_can('jetpack_admin_page')) {
             $submenu['jetpack'][] = array(__('Dashboard', 'jetpack'), 'jetpack_admin_page', Jetpack::admin_url('page=jetpack#/apps'));
         }
     }
 }
 private function __construct()
 {
     $active_plugins = self::get_active_plugins();
     // Check if Jetpack and the sharing module is active, and if the "WP Post to PDF Enhanced" plugin is installed.
     if (class_exists('Jetpack') && Jetpack::is_module_active('sharedaddy') && in_array('wp-post-to-pdf-enhanced/wp-post-to-pdf-enhanced.php', $active_plugins)) {
         add_action('plugins_loaded', array($this, 'setup'));
         add_action('wp_print_styles', array($this, 'get_css'), 2);
     } else {
         add_action('admin_notices', array($this, 'install_jetpack'));
     }
 }
 /**
  * Notice when Jetpack and Jetpack Markdown Module
  * are not active.
  *
  * @since 1.0.0
  */
 public function notice()
 {
     if (!class_exists('Jetpack')) {
         $notice = __('Jetpack Markdown Support requires Jetpack.', 'jetpack-markdown-support');
     } else {
         if (!Jetpack::is_module_active('markdown')) {
             $notice = __('Jetpack Markdown Support requires Jetpack\'s Markdown Module.', 'jetpack-markdown-support');
         }
     }
     echo '<div class="error"><p>' . $notice . '</p></div>';
 }
 /**
  * @return Push7SB_Jetpack
  * @since 0.0.1-dev
  */
 public static function init()
 {
     if (!class_exists('Jetpack') or !Jetpack::is_module_active('sharedaddy')) {
         return null;
         // end
     }
     if (!static::$instance) {
         static::$instance = new static();
     }
     return static::$instance;
 }
    function manage_msg()
    {
        if (current_user_can('jetpack_manage_modules')) {
            $normalized_site_url = Jetpack::build_raw_urls(get_home_url());
            $manage_active = Jetpack::is_module_active('manage');
            ?>
			<div class="jp-jitm">
				<a href="#"  data-module="manage" class="dismiss"><span class="genericon genericon-close"></span></a>
				<div class="jp-emblem">
					<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Layer_1" x="0" y="0" viewBox="0 0 172.9 172.9" enable-background="new 0 0 172.9 172.9" xml:space="preserve">
						<path d="M86.4 0C38.7 0 0 38.7 0 86.4c0 47.7 38.7 86.4 86.4 86.4s86.4-38.7 86.4-86.4C172.9 38.7 134.2 0 86.4 0zM83.1 106.6l-27.1-6.9C49 98 45.7 90.1 49.3 84l33.8-58.5V106.6zM124.9 88.9l-33.8 58.5V66.3l27.1 6.9C125.1 74.9 128.4 82.8 124.9 88.9z"/>
					</svg>
				</div>
				<p class="msg">
					<?php 
            _e('Reduce security risks with automated plugin updates.', 'jetpack');
            ?>
				</p>
				<p>
					<img class="jetpack-spinner hide" style="margin-top: 13px;" width="17" height="17" src="<?php 
            echo esc_url(includes_url('images/spinner-2x.gif'));
            ?>
" alt="Loading ..." /><a href="#" data-module="manage" class="activate button button-jetpack <?php 
            if (Jetpack::is_module_active('manage')) {
                echo 'hide';
            }
            ?>
"><?php 
            esc_html_e('Activate Now', 'jetpack');
            ?>
</a><a href="<?php 
            echo esc_url('https://wordpress.com/plugins/' . $normalized_site_url);
            ?>
" target="_blank" title="<?php 
            esc_attr_e('Go to WordPress.com to try these features', 'jetpack');
            ?>
" id="jetpack-wordpressdotcom" class="button button-jetpack <?php 
            if (!Jetpack::is_module_active('manage')) {
                echo 'hide';
            }
            ?>
"><?php 
            esc_html_e('Go to WordPress.com', 'jetpack');
            ?>
</a>
				</p>
			</div>
		<?php 
            //jitm is being viewed, track it
            $jetpack = Jetpack::init();
            $jetpack->stat('jitm', 'manage-viewed-' . JETPACK__VERSION);
            $jetpack->do_stats('server_side');
        }
    }
 private function __construct()
 {
     $this->updates_allowed = Jetpack::is_module_active('manage');
     // Only run automatic updates if a user as opted in by activating the manage module.
     if ($this->updates_allowed) {
         add_filter('auto_update_plugin', array($this, 'autoupdate_plugin'), 10, 2);
         add_filter('auto_update_theme', array($this, 'autoupdate_theme'), 10, 2);
         add_filter('auto_update_core', array($this, 'autoupdate_core'), 10, 2);
         add_action('automatic_updates_complete', array($this, 'automatic_updates_complete'), 10, 1);
         add_action('shutdown', array($this, 'log_results'));
     }
 }
 function jumpstart_list_modules()
 {
     $jumpstart_recommended = $this->jumpstart_module_tag('Jumpstart');
     $module_name = array();
     foreach ($jumpstart_recommended as $module => $val) {
         if (!Jetpack::is_module_active($val['module_slug'])) {
             $module_name[] = $val['module_name'];
         }
     }
     $jumpstart_module_list = implode($module_name, ', ');
     return $jumpstart_module_list;
 }
/**
 * Our photon hook prefix as this plugin supports both Jetpack Photon and My-Photon
 * @return string. (Either 'jetpack' or 'my');
 */
function photonfill_hook_prefix()
{
    // If photon module is active, then use it over my photon.
    $prefix = 'jetpack';
    if (class_exists('Jetpack') && Jetpack::is_module_active('photon')) {
        $prefix = 'jetpack';
    } elseif (class_exists('My_Photon_Settings') && My_Photon_Settings::get('active')) {
        $prefix = 'my';
    }
    // This setting fails under certain circumstances, like with VIP Go mu-plugins, so a filter is necessary.
    return apply_filters('photonfill_hook_prefix', $prefix);
}
Beispiel #23
0
function legacy_get_fit_remote_image_url($url, $width, $height, $escape = true)
{
    if (class_exists('Jetpack') && Jetpack::is_module_active('photon')) {
        $width = (int) $width;
        $height = (int) $height;
        // Photon doesn't support redirects, so help it out by doing http://foobar.wordpress.com/files/ to http://foobar.files.wordpress.com/
        if (function_exists('new_file_urls')) {
            $url = new_file_urls($url);
        }
        $thumburl = jetpack_photon_url($url, array('fit' => array($width, $height)));
        return $escape ? esc_url($thumburl) : $thumburl;
    }
}
/**
 * Convert a link to WP.me
 * @param string $link The link, before shortening
 * @return string      The link, after shortening through wp.me
 */
function ppp_apply_wpme($link)
{
    if (class_exists('Jetpack') && Jetpack::is_module_active('shortlinks')) {
        $id = url_to_postid($link);
        $result = wpme_get_shortlink($id);
        if (!empty($result)) {
            return $result;
        } else {
            return $link;
        }
    }
    return $link;
}
 /**
  * Switches to the blog and checks current user capabilities.
  * @return bool|WP_Error a WP_Error object or true if things are good.
  */
 protected function validate_call($_blog_id, $capability, $check_manage_active = true)
 {
     $blog_id = $this->api->switch_to_blog_and_validate_user($this->api->get_blog_id($_blog_id));
     if (is_wp_error($blog_id)) {
         return $blog_id;
     }
     if (is_wp_error($error = $this->check_capability($capability))) {
         return $error;
     }
     if ($check_manage_active && 'GET' !== $this->method && !Jetpack::is_module_active('manage')) {
         return new WP_Error('unauthorized_full_access', __('Full management mode is off for this site.', 'jetpack'), 403);
     }
     return true;
 }
 protected function deactivate_module()
 {
     foreach ($this->modules as $module) {
         if (!Jetpack::is_module_active($module)) {
             $error = $this->log[$module][] = __('The Jetpack Module is already deactivated.', 'jetpack');
             continue;
         }
         $result = Jetpack::deactivate_module($module);
         if (false === $result || Jetpack::is_module_active($module)) {
             $error = $this->log[$module][] = __('There was an error while deactivating the module.', 'jetpack');
         }
     }
     if (!$this->bulk && isset($error)) {
         return new WP_Error('deactivation_error', $error, 400);
     }
     return true;
 }
 function activate_manage($request)
 {
     foreach (array('secret', 'state') as $required) {
         if (!isset($request[$required]) || empty($request[$required])) {
             return $this->error(new Jetpack_Error('missing_parameter', 'One or more parameters is missing from the request.', 400));
         }
     }
     $verified = $this->verify_action(array('activate_manage', $request['secret'], $request['state']));
     if (is_a($verified, 'IXR_Error')) {
         return $verified;
     }
     $activated = Jetpack::activate_module('manage', false, false);
     if (false === $activated || !Jetpack::is_module_active('manage')) {
         return $this->error(new Jetpack_Error('activation_error', 'There was an error while activating the module.', 500));
     }
     return 'active';
 }
 private function __construct()
 {
     $this->updates_allowed = Jetpack::is_module_active('manage');
     // Only run automatic updates if a user as opted in by activating the manage module.
     if ($this->updates_allowed) {
         add_filter('auto_update_plugin', array($this, 'autoupdate_plugin'), 10, 2);
         add_filter('auto_update_theme', array($this, 'autoupdate_theme'), 10, 2);
         add_filter('auto_update_core', array($this, 'autoupdate_core'), 10, 2);
         add_action('automatic_updates_complete', array($this, 'automatic_updates_complete'), 10, 1);
         add_action('shutdown', array($this, 'log_results'));
     }
     // Anytime WordPress saves update data, we'll want to update our Jetpack option as well.
     if (is_main_site()) {
         add_action('set_site_transient_update_plugins', array($this, 'save_update_data'));
         add_action('set_site_transient_update_themes', array($this, 'save_update_data'));
         add_action('set_site_transient_update_core', array($this, 'save_update_data'));
     }
 }
 /**
  * Collects the necessary information to return for a get settings response.
  *
  * @return (array)
  */
 public function get_settings_response()
 {
     $response_format = self::$site_format;
     $blog_id = (int) $this->api->get_blog_id_for_output();
     foreach (array_keys($response_format) as $key) {
         switch ($key) {
             case 'ID':
                 $response[$key] = $blog_id;
                 break;
             case 'name':
                 $response[$key] = (string) htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES);
                 break;
             case 'description':
                 $response[$key] = (string) htmlspecialchars_decode(get_bloginfo('description'), ENT_QUOTES);
                 break;
             case 'URL':
                 $response[$key] = (string) home_url();
                 break;
             case 'lang':
                 $response[$key] = (string) get_bloginfo('language');
                 break;
             case 'settings':
                 if (class_exists('The_Neverending_Home_Page')) {
                     $infinity = new The_Neverending_Home_Page();
                     $infinity_settings = $infinity->get_settings();
                     $infinity_posts_per_page = $infinity_settings->posts_per_page;
                 }
                 $jetpack_relatedposts_options = Jetpack_Options::get_option('relatedposts');
                 if (method_exists('Jetpack', 'is_module_active')) {
                     $jetpack_relatedposts_options['enabled'] = Jetpack::is_module_active('related-posts');
                 }
                 // array_values() is necessary to ensure the array starts at index 0.
                 $post_categories = array_values(array_map(function ($category) {
                     return array('value' => $category->term_id, 'name' => $category->name);
                 }, get_categories(array('hide_empty' => false))));
                 $response[$key] = array('admin_url' => get_admin_url(), 'default_ping_status' => (bool) ('closed' != get_option('default_ping_status')), 'default_comment_status' => (bool) ('closed' != get_option('default_comment_status')), 'blog_public' => (int) (defined('WPCOM') && WPCOM ? get_option('blog_public') : 1), 'jetpack_relatedposts_allowed' => (bool) $this->jetpack_relatedposts_supported(), 'jetpack_relatedposts_enabled' => (bool) $jetpack_relatedposts_options['enabled'], 'jetpack_relatedposts_show_headline' => (bool) $jetpack_relatedposts_options['show_headline'], 'jetpack_relatedposts_show_thumbnails' => (bool) $jetpack_relatedposts_options['show_thumbnails'], 'infinite_scroll_supported' => (bool) current_theme_supports('infinite-scroll'), 'infinite_scroll' => (bool) get_option('infinite_scroll'), 'posts_per_page' => (int) $infinity_posts_per_page, 'default_category' => get_option('default_category'), 'post_categories' => (array) $post_categories, 'default_post_format' => get_option('default_post_format'), 'default_pingback_flag' => (bool) get_option('default_pingback_flag'), 'require_name_email' => (bool) get_option('require_name_email'), 'comment_registration' => (bool) get_option('comment_registration'), 'close_comments_for_old_posts' => (bool) get_option('close_comments_for_old_posts'), 'close_comments_days_old' => (int) get_option('close_comments_days_old'), 'thread_comments' => (bool) get_option('thread_comments'), 'thread_comments_depth' => (int) get_option('thread_comments_depth'), 'page_comments' => (bool) get_option('page_comments'), 'comments_per_page' => (int) get_option('comments_per_page'), 'default_comments_page' => get_option('default_comments_page'), 'comment_order' => get_option('comment_order'), 'comments_notify' => (bool) get_option('comments_notify'), 'moderation_notify' => (bool) get_option('moderation_notify'), 'social_notifications_like' => "on" == get_option('social_notifications_like'), 'social_notifications_reblog' => "on" == get_option('social_notifications_reblog'), 'social_notifications_subscribe' => "on" == get_option('social_notifications_subscribe'), 'comment_moderation' => (bool) get_option('comment_moderation'), 'comment_whitelist' => (bool) get_option('comment_whitelist'), 'comment_max_links' => (int) get_option('comment_max_links'), 'moderation_keys' => get_option('moderation_keys'), 'blacklist_keys' => get_option('blacklist_keys'), 'lang_id' => get_option('lang_id'));
                 if (!current_user_can('edit_posts')) {
                     unset($response[$key]);
                 }
                 break;
         }
     }
     return $response;
 }
function sandwich_jetpack_portfolio()
{
    // Check if Shortcake exists
    if (!function_exists('shortcode_ui_register_for_shortcode')) {
        return;
    }
    if (!is_admin()) {
        return;
    }
    shortcode_ui_register_for_shortcode('portfolio', array('label' => __('Jetpack', 'jetpack') . ' ' . _x('Portfolio', 'Module Name', 'jetpack'), 'listItemImage' => 'dashicons-portfolio', 'attrs' => array(array('label' => __('Display Portfolio Project Types', 'pbsandwich'), 'attr' => 'display_types', 'type' => 'checkbox'), array('label' => __('Display Portfolio Project Tags', 'pbsandwich'), 'attr' => 'display_tags', 'type' => 'checkbox'), array('label' => __('Display Portfolio Post Content', 'pbsandwich'), 'attr' => 'display_content', 'type' => 'checkbox'), array('label' => __('Project Types to display', 'pbsandwich'), 'attr' => 'include_type', 'type' => 'text', 'description' => __('Enter slug names of Project Types to display. Multiple slugs can be added by separating them with a comma. This entry must not be left blank in order to work.', 'pbsandwich'), 'value' => 'all'), array('label' => __('Tags to display', 'pbsandwich'), 'attr' => 'include_tag', 'type' => 'text', 'description' => __('Enter slug names of tags to display. Multiple slugs can be added by separating them with a comma. If none entered, it will not influence the post display.', 'pbsandwich')), array('label' => __('Columns to display', 'pbsandwich'), 'attr' => 'columns', 'type' => 'select', 'description' => __('Select the number of columns to use to display entries.', 'pbsandwich'), 'options' => array(1, 2, 3, 4, 5, 6), 'value' => '2'), array('label' => __('Amount of posts to display', 'pbsandwich'), 'attr' => 'showposts', 'type' => 'text', 'description' => __('Enter the number of entries to display. If none entered, defaults to 5', 'pbsandwich'), 'value' => '5'), array('label' => __('Display Order', 'pbsandwich'), 'attr' => 'order', 'type' => 'select', 'description' => __('Choose sorting direction. Ascending displays your oldest post first, while Descending displays your latest post first.', 'pbsandwich'), 'options' => sandwich_functions_display_dir(), 'value' => 'DESC'), array('label' => __('Display Order criteria', 'pbsandwich'), 'attr' => 'orderby', 'type' => 'select', 'description' => __('Choose the criteria of entries to be sorted by.', 'pbsandwich'), 'options' => sandwich_functions_display_order(), 'value' => 'date'))));
    // Make sure Jetpack is activated
    if (!class_exists('Jetpack')) {
        add_action('print_media_templates', 'sandwich_jetpack_portfolio_disabled');
        return;
    }
    // Make sure the contact form module is turned on
    if (!Jetpack::is_module_active('custom-content-types')) {
        add_action('print_media_templates', 'sandwich_jetpack_portfolio_disabled');
        return;
    }
}