300,"message"=>esc_html__('Request not valid','accelerated-mobile-pages'))); exit(); } // Exit if the user does not have proper permissions if(! current_user_can( 'install_plugins' ) ) { echo wp_json_encode(array("status"=>300,"message"=>esc_html__('User Request not valid','accelerated-mobile-pages'))); exit(); } $plugins = array(); $redirectSettingsUrl = ''; /* phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated */ $currentActivateModule = sanitize_text_field( wp_unslash($_REQUEST['activate'])); switch($currentActivateModule){ case 'pwa': $nonceUrl = add_query_arg( array( 'action' => 'activate', 'plugin' => 'pwa-for-wp', 'plugin_status' => 'all', 'paged' => '1', '_wpnonce' => wp_create_nonce( 'activate-plugin_pwa-for-wp' ), ), esc_url(network_admin_url( 'plugins.php' )) ); $plugins[] = array( 'name' => 'pwa-for-wp', 'path_' => 'https://downloads.wordpress.org/plugin/pwa-for-wp.zip', 'path' => $nonceUrl, 'install' => 'pwa-for-wp/pwa-for-wp.php', ); $redirectSettingsUrl = admin_url('admin.php?page=pwaforwp&reference=ampforwp'); break; case 'structure_data': $nonceUrl = add_query_arg( array( 'action' => 'activate', 'plugin' => 'schema-and-structured-data-for-wp', 'plugin_status' => 'all', 'paged' => '1', '_wpnonce' => wp_create_nonce( 'schema-and-structured-data-for-wp' ), ), network_admin_url( 'plugins.php' ) ); $plugins[] = array( 'name' => 'schema-and-structured-data-for-wp', 'path_' => 'https://downloads.wordpress.org/plugin/schema-and-structured-data-for-wp.zip', 'path' => add_query_arg( array( 'action' => 'activate', 'plugin' => 'schema-and-structured-data-for-wp', 'plugin_status' => 'all', 'paged' => '1', '_wpnonce' => $nonceUrl, ) ), 'install' => 'schema-and-structured-data-for-wp/structured-data-for-wp.php', ); $redirectSettingsUrl = admin_url('admin.php?page=structured_data_options&tab=general&reference=ampforwp'); break; case 'adsforwp': $nonceUrl = add_query_arg( array( 'action' => 'activate', 'plugin' => 'ads-for-wp', 'plugin_status' => 'all', 'paged' => '1', '_wpnonce' => wp_create_nonce( 'ads-for-wp' ), ), network_admin_url( 'plugins.php' ) ); $plugins[] = array( 'name' => 'ads-for-wp', 'path_' => 'https://downloads.wordpress.org/plugin/ads-for-wp.zip', 'path' => add_query_arg( array( 'action' => 'activate', 'plugin' => 'ads-for-wp', 'plugin_status' => 'all', 'paged' => '1', '_wpnonce' => $nonceUrl, ) ), 'install' => 'ads-for-wp/ads-for-wp.php', ); $redirectSettingsUrl = admin_url('edit.php?post_type=adsforwp'); break; case 'wp_quads': $nonceUrl = add_query_arg( array( 'action' => 'activate', 'plugin' => 'quick-adsense-reloaded', 'plugin_status' => 'all', 'paged' => '1', '_wpnonce' => wp_create_nonce( 'activate-plugin_quick-adsense-reloaded' ), ), esc_url(network_admin_url( 'plugins.php' )) ); $plugins[] = array( 'name' => 'quick-adsense-reloaded', 'path_' => 'https://downloads.wordpress.org/plugin/quick-adsense-reloaded.zip', 'path' => $nonceUrl, 'install' => 'quick-adsense-reloaded/quick-adsense-reloaded.php', ); $redirectSettingsUrl = admin_url('admin.php?page=quads-settings'); break; case 'cwvpsb': $nonceUrl = add_query_arg( array( 'action' => 'activate', 'plugin' => 'core-web-vitals-pagespeed-booster', 'plugin_status' => 'all', 'paged' => '1', '_wpnonce' => wp_create_nonce( 'core-web-vitals-pagespeed-booster' ), ), esc_url(network_admin_url( 'plugins.php' )) ); $plugins[] = array( 'name' => 'core-web-vitals-pagespeed-booster', 'path_' => 'https://downloads.wordpress.org/plugin/core-web-vitals-pagespeed-booster.zip', 'path' => $nonceUrl, 'install' => 'core-web-vitals-pagespeed-booster/core-web-vitals-pagespeed-booster.php', ); $redirectSettingsUrl = admin_url('admin.php?page=cwvpsb'); break; default: $plugins = array(); break; } if(count($plugins)>0){ echo wp_json_encode( array( "status"=>200, "message"=>esc_html__("Module successfully Added",'accelerated-mobile-pages'),'redirect_url'=>esc_url($redirectSettingsUrl) , "slug"=>$plugins[0]['name'], 'path'=> $plugins[0]['path'] ) ); }else{ echo wp_json_encode(array("status"=>300, "message"=>esc_html__("Modules not Found",'accelerated-mobile-pages'))); } wp_die(); } function ampforwp_admin_notice_module_reference_install() { // Exit if the user does not have proper permissions if(! current_user_can( 'manage_options' )) { return ; } // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form information. $reference = isset($_GET['reference']) ? sanitize_text_field( wp_unslash($_GET['reference'])) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form information. $page = isset($_GET['page']) ? sanitize_text_field( wp_unslash($_GET['page'])) : ''; $message = ''; if($reference=='ampforwp'){ switch( $page ){ case 'pwaforwp': $message = 'AMPforWP PWA Module has been activated. You may configure it below:'; break; case 'structured_data_options': $message = 'AMPforWP Structured data Module has been Upgraded. You may configure it below:'; break; case 'adsforwp_options': $message = 'AMPforWP AdsforWP Module has been Upgraded. You may configure it below:'; break; } } if($message){ ?>