コード例 #1
0
 /**
  * Return module name translation. Uses matching string created in modules/module-headings.php.
  *
  * @since 3.9.2
  *
  * @param array $modules
  *
  * @return string|void
  */
 public static function get_translated_modules($modules)
 {
     foreach ($modules as $index => $module) {
         $i18n_module = jetpack_get_module_i18n($module['module']);
         if (isset($module['name'])) {
             $modules[$index]['name'] = $i18n_module['name'];
         }
         if (isset($module['description'])) {
             $modules[$index]['description'] = $i18n_module['description'];
             $modules[$index]['short_description'] = $i18n_module['description'];
         }
     }
     return $modules;
 }
コード例 #2
0
 /**
  * Get information about a specific and valid Jetpack module.
  *
  * @since 4.3.0
  *
  * @param WP_REST_Request $data {
  *     Array of parameters received by request.
  *
  *     @type string $slug Module slug.
  * }
  *
  * @return mixed|void|WP_Error
  */
 public function get_module($data)
 {
     if (Jetpack::is_module($data['slug'])) {
         $module = Jetpack::get_module($data['slug']);
         $module['options'] = Jetpack_Core_Json_Api_Endpoints::prepare_options_for_response($data['slug']);
         if (isset($module['requires_connection']) && $module['requires_connection'] && Jetpack::is_development_mode()) {
             $module['activated'] = false;
         }
         $i18n = jetpack_get_module_i18n($data['slug']);
         if (isset($module['name'])) {
             $module['name'] = $i18n['name'];
         }
         if (isset($module['description'])) {
             $module['description'] = $i18n['description'];
             $module['short_description'] = $i18n['description'];
         }
         return Jetpack_Core_Json_Api_Endpoints::prepare_modules_for_response($module);
     }
     return new WP_Error('not_found', esc_html__('The requested Jetpack module was not found.', 'jetpack'), array('status' => 404));
 }