• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
Jetpack a2z

Jetpack a2z

Jetpack a2z

  • Home
  • Plugins
  • Blocks
  • Shortcodes
  • APIs
  • Classes
  • Files
  • Hooks
  • Sitemap
  • Blog
Home / APIs / Jetpack_Core_API_Module_Toggle_Endpoint::activate_module() – If it’s a valid Jetpack module, activate it.

You appear to be a bot. Output may be restricted

Description

If it's a valid Jetpack module, activate it.

Usage

$bool|WP_Error = Jetpack_Core_API_Module_Toggle_Endpoint::activate_module( $request );

Parameters

$request
( string|WP_REST_Request ) required – It's a WP_REST_Request when called from endpoint /module/<slug>/* and a string when called from Jetpack_Core_API_Data->update_data. { Array of parameters received by request.
$slug
( string ) required – Module slug. }

Returns

bool|WP_Error True if module was activated. Otherwise, a WP_Error instance with the corresponding error.

Source

File name: jetpack/_inc/lib/core-api/class.jetpack-core-api-module-endpoints.php
Lines:

1 to 44 of 44
  public function activate_module( $request ) {
    $module_slug = '';

    if (
      (
        is_array( $request )
        || is_object( $request )
      )
      && isset( $request['slug'] )
    ) {
      $module_slug = $request['slug'];
    } else {
      $module_slug = $request;
    }

    if ( ! Jetpack::is_module( $module_slug ) ) {
      return new WP_Error(
        'not_found',
        esc_html__( 'The requested Jetpack module was not found.', 'jetpack' ),
        array( 'status' => 404 )
      );
    }

    if ( ! Jetpack_Plan::supports( $module_slug ) ) {
      return new WP_Error(
        'not_supported',
        esc_html__( 'The requested Jetpack module is not supported by your plan.', 'jetpack' ),
        array( 'status' => 424 )
      );
    }

    if ( Jetpack::activate_module( $module_slug, false, false ) ) {
      return rest_ensure_response( array(
        'code'     => 'success',
        'message' => esc_html__( 'The requested Jetpack module was activated.', 'jetpack' ),
      ) );
    }

    return new WP_Error(
      'activation_failed',
      esc_html__( 'The requested Jetpack module could not be activated.', 'jetpack' ),
      array( 'status' => 424 )
    );
  }
 

 View on GitHub View on Trac

Share this:

  • Click to share on Twitter (Opens in new window)
  • Click to share on Facebook (Opens in new window)
  • Click to share on LinkedIn (Opens in new window)
  • Click to share on Pinterest (Opens in new window)

Related

Published: 27 November 2019 | Last updated: 27 November 2019

Primary Sidebar

Information

Function name: Jetpack_Core_API_Module_Toggle_Endpoint::activate_module
Class ref: Jetpack_Core_API_Module_Toggle_Endpoint
Plugin ref: Jetpack
Version: 9.2
Sourcefile: _inc/lib/core-api/class.jetpack-core-api-module-endpoints.php
File ref: _inc/lib/core-api/class.jetpack-core-api-module-endpoints.php
Deprecated?: No
API Letters: A,C,J,M,T

Footer

Jetpack a2z
Jetpack a2z
Jetpack a2z
WordPress 5.6
WordPress a2z
WordPress core a2z
Genesis Theme Framework a2z
Jetpack a2z
WordPress develop tests
Easy Digital Downloads a2z
WooCommerce a2z
Yoast SEO a2z
WordPress Blocks

Site:  jetpack.wp-a2z.org
© Copyright Jetpack a2z 2014-2021. All rights reserved.


Website designed and developed by Herb Miller
Proudly powered by WordPress and oik plugins

  • Home
  • Blog
  • Sitemap
  • Sites