'; if ( isset( $_GET[ 'invalidkey' ] ) ):?>

%s', LILAEAMEDIA_URL, __( 'contact us.', 'child-theme-configurator' ) ) ); ?>

'; endif; ?>

self::$version, 'key' => $key, 'product' => dirname( self::$old ), ); //Various options for the wp_remote_get() call. Plugins can filter these, too. $options = array( 'timeout' => 10, //seconds 'headers' => array( 'Accept' => 'application/json' ), ); //The plugin info should be at 'http://your-api.com/url/here/$slug/info.json' $url = add_query_arg( $args, self::$lilaeaupdateurl ); $result = wp_remote_get( $url, $options ); //Try to parse the response $pluginInfo = NULL; if ( !is_wp_error( $result ) && isset( $result[ 'response' ][ 'code' ] ) && ( $result[ 'response' ][ 'code' ] == 200 ) && !empty( $result['body'] ) ): $pluginInfo = json_decode( $result['body'] ); if ( empty( $pluginInfo ) || version_compare( $pluginInfo->version, self::$version, '<' ) ): $query = array( 'invalidkey' => 1 ); $url = add_query_arg( $query ); wp_redirect( $url ); die(); endif; // create update object $update = new StdClass; $update->id = 0; $update->slug = $pluginInfo->slug; $update->new_version = $pluginInfo->version; $update->url = $pluginInfo->homepage; $update->package = $pluginInfo->download_url; if ( !empty( $pluginInfo->upgrade_notice ) ) $update->upgrade_notice = $pluginInfo->upgrade_notice; self::$update = $update; // add update to cache wp_update_plugins(); // run upgrader $title = __( 'Update Plugin', 'child-theme-configurator' ); $plugin = self::$old; //$nonce = 'ctc_pro_upgrade'; //'upgrade-plugin_' . $plugin; $nonce = 'upgrade-plugin_' . self::$old; $url = 'update.php?action=upgrade-plugin&plugin=' . urlencode( self::$old ) . '&ctc_pro_upgrade=1&ctcnonce=' . $_REQUEST[ 'ctcnonce' ]; wp_enqueue_script( 'updates' ); include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); require_once( ABSPATH . 'wp-admin/admin-header.php' ); $upgrader = new Plugin_Upgrader( new Plugin_Upgrader_Skin( compact( 'title', 'nonce', 'url', 'plugin' ) ) ); //return; $upgrader->upgrade( $plugin ); include(ABSPATH . 'wp-admin/admin-footer.php'); self::set_update_key( $key ); endif; } static function injectUpdate( $updates ){ if ( !empty( self::$update ) ): if ( !is_object( $updates ) ): $updates = new StdClass(); $updates->response = array(); endif; $updates->response[ self::$old ] = self::$update; elseif ( isset( $updates, $updates->response ) ): unset( $updates->response[ self::$old ] ); endif; return $updates; } static function clearCachedVersion( $args = NULL ){ self::$update = NULL; return $args; } /** * deletes old version of plugin without removing option settings */ static function delete_old_version() { if ( isset( $_REQUEST[ 'deleted' ] ) ) return; $slug = dirname( self::$old ); // clean up hooks from < 2.2.0 wp_clear_scheduled_hook( 'check_plugin_updates-' . $slug ); delete_option( 'external_updates-' . $slug ); // remove old Pro version if ( current_user_can( 'delete_plugins' ) ): $redir = NULL; if ( isset( $_GET[ 'action' ] ) ): // unset action parameter if it is for old CTC Pro if ( 'activate' == $_GET[ 'action' ] && isset( $_GET[ 'plugin' ] ) && self::$old == $_GET[ 'plugin' ] ): unset( $_GET[ 'action' ] ); // handle two-step FTP Authentication form elseif ( 'delete-selected' == $_GET[ 'action' ] && isset( $_GET[ 'verify-delete' ] ) && isset( $_GET[ 'checked' ] ) && self::$old == $_GET[ 'checked' ][ 0 ] ): unset( $_GET[ 'action' ] ); unset( $_GET[ 'checked' ] ); unset( $_GET[ 'verify-delete' ] ); unset( $_REQUEST[ 'action' ] ); unset( $_REQUEST[ 'checked' ] ); unset( $_REQUEST[ 'verify-delete' ] ); $redir = self_admin_url( "plugins.php?activate=true" ); elseif ( 'activate' != $_GET[ 'action' ] ): return; endif; endif; // deactivate old Pro version deactivate_plugins( self::$old, FALSE, is_network_admin() ); // remove uninstall hook so that options are preserved $uninstallable_plugins = (array) get_option( 'uninstall_plugins' ); if ( isset( $uninstallable_plugins[ self::$old ] ) ): unset( $uninstallable_plugins[ self::$old ] ); update_option( 'uninstall_plugins', $uninstallable_plugins ); endif; unset( $uninstallable_plugins ); // remove old Pro version $delete_result = delete_plugins( array( self::$old ) ); //Store the result in a cache rather than a URL param due to object type & length global $user_ID; set_transient( 'plugins_delete_result_' . $user_ID, $delete_result ); // force plugin cache to reload wp_cache_delete( 'plugins', 'plugins' ); // if this is two-step FTP authentication, redirect back to activated if ( $redir ): if ( is_wp_error( $delete_result ) ) $redir = self_admin_url( "plugins.php?deleted=" . self::$old ); wp_redirect( $redir ); exit; endif; endif; } }