当前位置: 首页>>代码示例>>PHP>>正文


PHP Jetpack::get_module_path方法代码示例

本文整理汇总了PHP中Jetpack::get_module_path方法的典型用法代码示例。如果您正苦于以下问题:PHP Jetpack::get_module_path方法的具体用法?PHP Jetpack::get_module_path怎么用?PHP Jetpack::get_module_path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Jetpack的用法示例。


在下文中一共展示了Jetpack::get_module_path方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: activate_module

 public static function activate_module($module, $exit = true, $redirect = true)
 {
     do_action('jetpack_pre_activate_module', $module, $exit);
     $jetpack = Jetpack::init();
     if (!strlen($module)) {
         return false;
     }
     if (!Jetpack::is_module($module)) {
         return false;
     }
     // If it's already active, then don't do it again
     $active = Jetpack::get_active_modules();
     foreach ($active as $act) {
         if ($act == $module) {
             return true;
         }
     }
     $module_data = Jetpack::get_module($module);
     if (!Jetpack::is_active()) {
         if (!Jetpack::is_development_mode()) {
             return false;
         }
         // If we're not connected but in development mode, make sure the module doesn't require a connection
         if (Jetpack::is_development_mode() && $module_data['requires_connection']) {
             return false;
         }
     }
     // Check and see if the old plugin is active
     if (isset($jetpack->plugins_to_deactivate[$module])) {
         // Deactivate the old plugin
         if (Jetpack_Client_Server::deactivate_plugin($jetpack->plugins_to_deactivate[$module][0], $jetpack->plugins_to_deactivate[$module][1])) {
             // If we deactivated the old plugin, remembere that with ::state() and redirect back to this page to activate the module
             // We can't activate the module on this page load since the newly deactivated old plugin is still loaded on this page load.
             Jetpack::state('deactivated_plugins', $module);
             wp_safe_redirect(add_query_arg('jetpack_restate', 1));
             exit;
         }
     }
     // Check the file for fatal errors, a la wp-admin/plugins.php::activate
     Jetpack::state('module', $module);
     Jetpack::state('error', 'module_activation_failed');
     // we'll override this later if the plugin can be included without fatal error
     Jetpack::catch_errors(true);
     ob_start();
     require Jetpack::get_module_path($module);
     do_action('jetpack_activate_module', $module);
     $active[] = $module;
     Jetpack_Options::update_option('active_modules', array_unique($active));
     Jetpack::state('error', false);
     // the override
     Jetpack::state('message', 'module_activated');
     Jetpack::state('module', $module);
     ob_end_clean();
     Jetpack::catch_errors(false);
     if ($redirect) {
         wp_safe_redirect(Jetpack::admin_url('page=jetpack'));
     }
     if ($exit) {
         exit;
     }
 }
开发者ID:lokenxo,项目名称:familygenerator,代码行数:61,代码来源:class.jetpack.php

示例2: activate_module

 public static function activate_module($module, $exit = true, $redirect = true)
 {
     /**
      * Fires before a module is activated.
      *
      * @since 2.6.0
      *
      * @param string $module Module slug.
      * @param bool $exit Should we exit after the module has been activated. Default to true.
      * @param bool $redirect Should the user be redirected after module activation? Default to true.
      */
     do_action('jetpack_pre_activate_module', $module, $exit, $redirect);
     $jetpack = Jetpack::init();
     if (!strlen($module)) {
         return false;
     }
     if (!Jetpack::is_module($module)) {
         return false;
     }
     // If it's already active, then don't do it again
     $active = Jetpack::get_active_modules();
     foreach ($active as $act) {
         if ($act == $module) {
             return true;
         }
     }
     $module_data = Jetpack::get_module($module);
     if (!Jetpack::is_active()) {
         if (!Jetpack::is_development_mode()) {
             return false;
         }
         // If we're not connected but in development mode, make sure the module doesn't require a connection
         if (Jetpack::is_development_mode() && $module_data['requires_connection']) {
             return false;
         }
     }
     // Check and see if the old plugin is active
     if (isset($jetpack->plugins_to_deactivate[$module])) {
         // Deactivate the old plugin
         if (Jetpack_Client_Server::deactivate_plugin($jetpack->plugins_to_deactivate[$module][0], $jetpack->plugins_to_deactivate[$module][1])) {
             // If we deactivated the old plugin, remembere that with ::state() and redirect back to this page to activate the module
             // We can't activate the module on this page load since the newly deactivated old plugin is still loaded on this page load.
             Jetpack::state('deactivated_plugins', $module);
             wp_safe_redirect(add_query_arg('jetpack_restate', 1));
             exit;
         }
     }
     // Check the file for fatal errors, a la wp-admin/plugins.php::activate
     Jetpack::state('module', $module);
     Jetpack::state('error', 'module_activation_failed');
     // we'll override this later if the plugin can be included without fatal error
     Jetpack::catch_errors(true);
     ob_start();
     require Jetpack::get_module_path($module);
     /** This action is documented in class.jetpack.php */
     do_action('jetpack_activate_module', $module);
     $active[] = $module;
     Jetpack_Options::update_option('active_modules', array_unique($active));
     Jetpack::state('error', false);
     // the override
     Jetpack::state('message', 'module_activated');
     Jetpack::state('module', $module);
     ob_end_clean();
     Jetpack::catch_errors(false);
     // A flag for Jump Start so it's not shown again. Only set if it hasn't been yet.
     if ('new_connection' === Jetpack_Options::get_option('jumpstart')) {
         Jetpack_Options::update_option('jumpstart', 'jetpack_action_taken');
         //Jump start is being dismissed send data to MC Stats
         $jetpack->stat('jumpstart', 'manual,' . $module);
         $jetpack->do_stats('server_side');
     }
     if ($redirect) {
         wp_safe_redirect(Jetpack::admin_url('page=jetpack'));
     }
     if ($exit) {
         exit;
     }
     return true;
 }
开发者ID:jordankoschei,项目名称:jordankoschei-dot-com,代码行数:79,代码来源:class.jetpack.php

示例3: get_remote_value

 /**
  * Get a value not saved locally.
  *
  * @since 4.3.0
  *
  * @param string $module Module slug.
  * @param string $option Option name.
  *
  * @return bool Whether user is receiving notifications or not.
  */
 public static function get_remote_value($module, $option)
 {
     if (in_array($module, array('post-by-email'), true)) {
         $option .= get_current_user_id();
     }
     // If option doesn't exist, 'does_not_exist' will be returned.
     $value = get_option($option, 'does_not_exist');
     // If option exists, just return it.
     if ('does_not_exist' !== $value) {
         return $value;
     }
     // Only check a remote option if Jetpack is connected.
     if (!Jetpack::is_active()) {
         return false;
     }
     // If the module is inactive, load the class to use the method.
     if (!did_action('jetpack_module_loaded_' . $module)) {
         // Class can't be found so do nothing.
         if (!@(include Jetpack::get_module_path($module))) {
             return false;
         }
     }
     // Do what is necessary for each module.
     switch ($module) {
         case 'monitor':
             $monitor = new Jetpack_Monitor();
             $value = $monitor->user_receives_notifications(false);
             break;
         case 'post-by-email':
             $post_by_email = new Jetpack_Post_By_Email();
             $value = $post_by_email->get_post_by_email_address();
             if ($value === null) {
                 $value = 'NULL';
                 // sentinel value so it actually gets set
             }
             break;
     }
     // Normalize value to boolean.
     if (is_wp_error($value) || is_null($value)) {
         $value = false;
     }
     // Save option to use it next time.
     update_option($option, $value);
     return $value;
 }
开发者ID:iamtakashi,项目名称:jetpack,代码行数:55,代码来源:class.core-rest-api-endpoints.php

示例4: admin_screen_list_modules

    function admin_screen_list_modules()
    {
        require_once dirname(__FILE__) . '/modules/module-info.php';
        $jetpack_connected = true;
        if (!Jetpack::is_active()) {
            $jetpack_connected = false;
        }
        ?>
		<div class="module-container">
		<?php 
        $avail_raw = Jetpack::get_available_modules();
        $available = array();
        $active = Jetpack::get_active_modules();
        $counter = 0;
        foreach ((array) $avail_raw as $module) {
            if ($plugin = Jetpack::get_module($module)) {
                $plugin['module'] = $module;
                $available[] = $plugin;
            }
        }
        unset($avail_raw);
        usort($available, array('Jetpack', 'sort_modules'));
        $jetpack_version = Jetpack::get_option('version');
        if ($jetpack_version) {
            list($jetpack_version, $jetpack_version_time) = explode(':', $jetpack_version);
        } else {
            $jetpack_version = 0;
            $jetpack_version_time = 0;
        }
        $jetpack_old_version = Jetpack::get_option('old_version');
        if ($jetpack_old_version) {
            list($jetpack_old_version) = explode(':', $jetpack_old_version);
        } else {
            $jetpack_old_version = 0;
        }
        $now = time();
        foreach ((array) $available as $module_data) {
            $module = $module_data['module'];
            $activated = in_array($module, $active);
            if ($activated) {
                $css = 'active';
                $toggle = __('Deactivate', 'jetpack');
                $toggle_url = wp_nonce_url(Jetpack::admin_url(array('action' => 'deactivate', 'module' => $module)), "jetpack_deactivate-{$module}");
            } else {
                $css = 'inactive';
                $toggle = __('Activate', 'jetpack');
                $toggle_url = wp_nonce_url(Jetpack::admin_url(array('action' => 'activate', 'module' => $module)), "jetpack_activate-{$module}");
            }
            $file = Jetpack::get_module_path($module);
            $png = str_replace('.php', '.png', $file);
            if (is_readable(dirname(__FILE__) . '/_inc/images/icons/' . basename($png))) {
                $module_img = plugins_url(basename(dirname(__FILE__)) . '/_inc/images/icons/' . basename($png));
            } else {
                $module_img = plugins_url(basename(dirname(__FILE__)) . '/_inc/images/module-blank.png');
            }
            if ($counter % 4 == 0) {
                $classes = $css . ' jetpack-newline';
                $counter = 0;
            } else {
                $classes = $css;
            }
            $free_text = esc_html($module_data['free'] ? __('Free', 'jetpack') : __('Purchase', 'jetpack'));
            $free_text = apply_filters('jetpack_module_free_text_' . $module, $free_text);
            $badge_text = $free_text;
            if (!$jetpack_connected) {
                $classes = 'x disabled';
            } else {
                if ($jetpack_version_time + 604800 > $now) {
                    // 1 week
                    if (version_compare($module_data['introduced'], $jetpack_old_version, '>')) {
                        $badge_text = esc_html__('New', 'jetpack');
                        $classes .= ' jetpack-new-module';
                    } elseif (isset($module_data['changed']) && version_compare($module_data['changed'], $jetpack_old_version, '>')) {
                        $badge_text = esc_html__('Updated', 'jetpack');
                        $classes .= ' jetpack-updated-module';
                    } else {
                        $badge_text = $free_text;
                    }
                }
            }
            ?>
			<div class="jetpack-module jetpack-<?php 
            echo $classes;
            ?>
" id="<?php 
            echo $module;
            ?>
">
				<h3><?php 
            echo $module_data['name'];
            ?>
</h3>
				<div class="jetpack-module-description">
						<div class="module-image">
							<img src="<?php 
            echo esc_url($module_img);
            ?>
" align="right" width="71" height="45" />
							<p><span class="module-image-badge"><?php 
            echo $badge_text;
//.........这里部分代码省略.........
开发者ID:Bencheci,项目名称:blueRavenStudiosProject,代码行数:101,代码来源:jetpack.php

示例5: get_module

 /**
  * Load module data from module file. Headers differ from WordPress
  * plugin headers to avoid them being identified as standalone
  * plugins on the WordPress plugins page.
  */
 public static function get_module($module)
 {
     $headers = array('name' => 'Module Name', 'description' => 'Module Description', 'jumpstart_desc' => 'Jumpstart Description', 'sort' => 'Sort Order', 'recommendation_order' => 'Recommendation Order', 'introduced' => 'First Introduced', 'changed' => 'Major Changes In', 'deactivate' => 'Deactivate', 'free' => 'Free', 'requires_connection' => 'Requires Connection', 'auto_activate' => 'Auto Activate', 'module_tags' => 'Module Tags', 'feature' => 'Feature');
     $file = Jetpack::get_module_path(Jetpack::get_module_slug($module));
     $mod = Jetpack::get_file_data($file, $headers);
     if (empty($mod['name'])) {
         return false;
     }
     $mod['jumpstart_desc'] = _x($mod['jumpstart_desc'], 'Jumpstart Description', 'jetpack');
     $mod['name'] = _x($mod['name'], 'Module Name', 'jetpack');
     $mod['description'] = _x($mod['description'], 'Module Description', 'jetpack');
     $mod['sort'] = empty($mod['sort']) ? 10 : (int) $mod['sort'];
     $mod['recommendation_order'] = empty($mod['recommendation_order']) ? 20 : (int) $mod['recommendation_order'];
     $mod['deactivate'] = empty($mod['deactivate']);
     $mod['free'] = empty($mod['free']);
     $mod['requires_connection'] = !empty($mod['requires_connection']) && 'No' == $mod['requires_connection'] ? false : true;
     if (empty($mod['auto_activate']) || !in_array(strtolower($mod['auto_activate']), array('yes', 'no', 'public'))) {
         $mod['auto_activate'] = 'No';
     } else {
         $mod['auto_activate'] = (string) $mod['auto_activate'];
     }
     if ($mod['module_tags']) {
         $mod['module_tags'] = explode(',', $mod['module_tags']);
         $mod['module_tags'] = array_map('trim', $mod['module_tags']);
         $mod['module_tags'] = array_map(array(__CLASS__, 'translate_module_tag'), $mod['module_tags']);
     } else {
         $mod['module_tags'] = array(self::translate_module_tag('Other'));
     }
     if ($mod['feature']) {
         $mod['feature'] = explode(',', $mod['feature']);
         $mod['feature'] = array_map('trim', $mod['feature']);
     } else {
         $mod['feature'] = array(self::translate_module_tag('Other'));
     }
     /**
      * Filter the feature array on a module
      *
      * This filter allows you to control where each module is filtered: Recommended,
      * Jumpstart, and the default "Other" listing.
      *
      * @since 3.5
      *
      * @param array   $mod['feature'] The areas to feature this module:
      *     'Jumpstart' adds to the "Jumpstart" option to activate many modules at once
      *     'Recommended' shows on the main Jetpack admin screen
      *     'Other' should be the default if no other value is in the array
      * @param string  $module The slug of the module, e.g. sharedaddy
      * @param array   $mod All the currently assembled module data
      */
     $mod['feature'] = apply_filters('jetpack_module_feature', $mod['feature'], $module, $mod);
     /**
      * Filter the returned data about a module.
      *
      * This filter allows overriding any info about Jetpack modules. It is dangerous,
      * so please be careful.
      *
      * @since 3.6
      *
      * @param array   $mod    The details of the requested module.
      * @param string  $module The slug of the module, e.g. sharedaddy
      * @param string  $file   The path to the module source file.
      */
     return apply_filters('jetpack_get_module', $mod, $module, $file);
 }
开发者ID:jjloomis,项目名称:slimpack,代码行数:69,代码来源:class.jetpack.php


注:本文中的Jetpack::get_module_path方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。