Created
May 10, 2018 03:54
-
-
Save shrimp2t/fb084ffa6009c45fc3f47fc406ed1288 to your computer and use it in GitHub Desktop.
Install and active by url or ajax
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// get_current_screen() | |
//$class= 'updated notice notice-success notice-alt is-dismissible'; | |
// install theme url esc_url( wp_nonce_url( $install_url, 'install-theme_' . $theme->slug ) ) | |
$theme_slug = 'twentyseventeen'; | |
$install_url = add_query_arg( array( | |
'action' => 'install-theme', | |
'theme' => $theme_slug, | |
), self_admin_url( 'update.php' ) ); | |
/** ajax_install_theme | |
slug: appsetter | |
action: install-theme | |
_ajax_nonce: 14550356f5 | |
_fs_nonce: | |
username: | |
password: | |
connection_type: | |
public_key: | |
Respond: {"success":true,"data":{"install":"theme","slug":"appsetter","debug":["Downloading installation package from https:\/\/downloads.wordpress.org\/theme\/appsetter.1.0.7.zip…","Unpacking the package…","Installing the theme…","Theme installed successfully."],"themeName":"AppSetter","activateUrl":"https:\/\/onepress.dev\/wp-admin\/themes.php?action=activate&_wpnonce=63ec2e200a&stylesheet=appsetter","customizeUrl":"https:\/\/onepress.dev\/wp-admin\/customize.php?theme=appsetter&return=%2Fwp-admin%2Ftheme-install.php"}} | |
*button button-primary theme-install updating-message | |
*/ | |
$ajax_data = array( | |
'action' => 'install-theme', | |
'theme' => $theme_slug, | |
'_ajax_nonce' => wp_create_nonce( 'install-theme_' . $theme_slug ) | |
); | |
$url = wp_nonce_url( $install_url, 'install-theme_' . $theme_slug ); | |
$active_url = wp_nonce_url( admin_url( 'themes.php?action=activate&stylesheet=' . $theme_slug ), 'switch-theme_' . $theme_slug ); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment