$plug ) { self::$slugs[ $plug[ 'id' ] ] = $plug[ 'slug' ]; if ( isset( $options[ 'plugin_key' ][ $plug[ 'id' ] ] ) && $options[ 'plugin_key' ][ $plug[ 'id' ] ] != '' ) { $plugin[ $plug_id ][ 'key' ] = $options[ 'plugin_key' ][ $plug[ 'id' ] ]; } elseif ( isset( $plugin[ $plug_id ][ 'key' ] ) && $plugin[ $plug_id ][ 'key' ] != '' ) { $options[ 'plugin_key' ][ $plug[ 'id' ] ] = $plugin[ $plug_id ][ 'key' ]; $update = true; } } self::$plugin_info = $plugin; if ( $update ) { self::set_options( $options ); } add_filter( 'berocket_display_additional_notices', array( __CLASS__, 'berocket_display_additional_notices' ) ); if( ! is_network_admin() ) { add_filter( 'custom_menu_order', array( __CLASS__, 'wp_menu_order' ) ); } //ADMIN NOTICE CHECK add_filter( 'berocket_admin_notice_is_display_notice', array( __CLASS__, 'admin_notice_is_display_notice' ), 10, 3 ); add_filter( 'berocket_admin_notice_is_display_notice_priority', array( __CLASS__, 'admin_notice_is_display_notice' ), 10, 3 ); } public static function error_log() { if ( self::$debug_mode ) { self::$error_log = apply_filters( 'BeRocket_updater_error_log', self::$error_log ); self::$error_log[ 'real_memory_usage' ] = memory_get_peak_usage( true ); self::$error_log[ 'script_memory_usage' ] = memory_get_peak_usage( false ); self::$error_log[ 'memory_limit' ] = ini_get( 'memory_limit' ); self::$error_log[ 'WP_DEBUG' ] = 'WP_DEBUG:' . ( defined( 'WP_DEBUG' ) ? ( WP_DEBUG ? 'true' : 'false' ) : 'false' ) . '; WP_DEBUG_DISPLAY:' . ( defined( 'WP_DEBUG_DISPLAY' ) ? ( WP_DEBUG_DISPLAY ? 'true' : 'false' ) : 'false' ); ?> " . $item[ 0 ] . ""; $new_sub_order[ $compatibility_hack[ str_replace( "edit.php?post_type=", "", $item[ 2 ] ) ] ][] = $item; } else { $new_order_temp[] = $item; $new_order_sort[] = $item[ 0 ]; } } $new_sub_order = apply_filters('BeRocket_updater_menu_order_sub_order', $new_sub_order); array_multisort( $new_order_sort, $new_order_temp ); $new_order = array(); if( $BeRocket_item !== false ) { $new_order[] = $BeRocket_item; } foreach ( $new_order_temp as $item ) { $new_order[] = $item; if ( ! empty( $new_sub_order[ $item[ 2 ] ] ) ) { foreach ( $new_sub_order[ $item[ 2 ] ] as $sub_item ) { $new_order[] = $sub_item; } } } if( $account_keys_item !== false ) { $new_order[] = $account_keys_item; } $submenu[ 'berocket_account' ] = $new_order; return $menu_ord; } public static function add_to_debug( $data, $plugin, $keys = false ) { if ( self::$debug_mode ) { if ( $keys === false ) { self::$error_log[ $plugin ][] = $data; } elseif ( is_array( $keys ) ) { if ( count( $keys ) > 0 ) { $data_set = self::$error_log[ $plugin ]; $last_key = array_pop( $keys ); foreach ( $keys as $key ) { if ( ! is_array( $data_set[ $key ] ) ) { $data_set[ $key ] = array(); } $new_set = &$data_set[ $key ]; unset( $data_set ); $data_set = &$new_set; unset( $new_set ); } if ( empty( $last_key ) ) { $data_set[] = $data; } else { $data_set[ $last_key ] = $data; } } else { self::$error_log[ $plugin ][] = $data; } } else { self::$error_log[ $plugin ][ $keys ] = $data; } } } public static function berocket_display_additional_notices( $notices ) { if ( ! empty( $_GET[ 'page' ] ) && $_GET[ 'page' ] == 'berocket_account' ) { return $notices; } $plugin_count = get_option('berocket_updater_registered_plugins'); update_option('berocket_updater_registered_plugins', count(self::$plugin_info)); if( count(self::$plugin_info) != $plugin_count ) { $not_activated_notices = false; } else { if ( is_network_admin() ) { $not_activated_notices = get_site_transient( 'berocket_not_activated_notices_site' ); } else { $not_activated_notices = get_transient( 'berocket_not_activated_notices' ); } } if ( $not_activated_notices == false ) { $active_plugin = get_option( 'berocket_key_activated_plugins' ); $active_site_plugin = get_site_option( 'berocket_key_activated_plugins' ); if ( ! is_array( $active_plugin ) ) { $active_plugin = array(); } if ( ! is_array( $active_site_plugin ) ) { $active_site_plugin = array(); } $not_activated_notices = array(); foreach ( self::$plugin_info as $plugin ) { if ( empty( $active_plugin[ $plugin[ 'id' ] ] ) && empty( $active_site_plugin[ $plugin[ 'id' ] ] ) ) { if ( version_compare( $plugin[ 'version' ], '2.0', '>=' ) ) { $not_activated_notices[] = array( 'start' => 0, 'end' => 0, 'name' => $plugin[ 'name' ], 'html' => ''.__('Please', 'BeRocket_domain'). ' ' . __('activate plugin', 'BeRocket_domain') . ' ' . $plugin[ 'name' ] . ' ' . __('with help of Plugin/Account Key from', 'BeRocket_domain') . ' ' . __('BeRocket account', 'BeRocket_domain') . '. ' . __('You can activate plugin in', 'BeRocket_domain') . ' ' . __('BeRocket Account settings', 'BeRocket_domain') . ' ', 'righthtml' => '', 'rightwidth' => 0, 'nothankswidth' => 0, 'contentwidth' => 1600, 'subscribe' => false, 'priority' => 10, 'height' => 70, 'repeat' => false, 'repeatcount' => 1, 'image' => array( 'local' => '', 'width' => 0, 'height' => 0, 'scale' => 1, ) ); } } } if ( is_network_admin() ) { set_site_transient( 'berocket_not_activated_notices_site', $not_activated_notices, 7200 ); } else { set_transient( 'berocket_not_activated_notices', $not_activated_notices, 7200 ); } } $notices = array_merge( $notices, $not_activated_notices ); return $notices; } public static function get_plugin_count() { $count = count( self::$plugin_info ); return $count; } public static function allow_berocket_host( $allow, $host, $url ) { if ( $host == 'berocket.com' ) { $allow = true; } return $allow; } public static function test_key() { if ( ! isset( $_POST[ 'key' ] ) || ! isset( $_POST[ 'id' ] ) ) { $data = array( 'key_exist' => 0, 'status' => 'Failed', 'error' => 'Incorrect query for this function(ID and Key must be sended)' ); $out = json_encode( $data ); } else { $key = sanitize_text_field( $_POST[ 'key' ] ); $id = sanitize_text_field( $_POST[ 'id' ] ); $out = get_transient( 'brupdate_' . $id . '_' . $key ); if ( $out == false ) { $site_url = get_site_url(); $plugins = self::$plugin_info; if ( is_array( $plugins ) ) { $plugins = array_keys( $plugins ); $plugins = implode( ',', $plugins ); } else { $plugins = ''; } $response = wp_remote_post( BeRocket_update_path . 'main/account_updater', array( 'body' => array( 'key' => $key, 'id' => $id, 'url' => $site_url, 'plugins' => $plugins ), 'method' => 'POST', 'timeout' => 30, 'redirection' => 5, 'blocking' => true, 'sslverify' => false ) ); if ( ! is_wp_error( $response ) ) { $out = wp_remote_retrieve_body( $response ); $current_plugin = false; $out = json_decode( $out, true ); if ( ! is_array( $out ) ) { $out = array(); } $out[ 'upgrade' ] = array(); $options = self::get_options(); if ( $id != 0 ) { foreach ( self::$plugin_info as $plugin ) { if ( $plugin[ 'id' ] == $id ) { $current_plugin = $plugin; break; } } if ( $current_plugin !== false ) { if ( empty( $out[ 'error' ] ) ) { $options[ 'plugin_key' ][ $id ] = $key; if ( isset( $out[ 'versions' ][ $id ] ) && version_compare( $current_plugin[ 'version' ], $out[ 'versions' ][ $id ], '<' ) ) { $upgrade_button = 'Upgrade plugin'; $out[ 'plugin_table' ] = '
' . $upgrade_button . '
' . $out[ 'plugin_table' ]; $out[ 'upgrade' ][] = array( 'id' => $id, 'upgrade' => $upgrade_button ); } } } } else { foreach ( self::$plugin_info as $plugin ) { if ( isset( $out[ 'versions' ][ $plugin[ 'id' ] ] ) && version_compare( $plugin[ 'version' ], $out[ 'versions' ][ $plugin[ 'id' ] ], '<' ) ) { $upgrade_button = 'Upgrade plugin'; $out[ 'upgrade' ][] = array( 'id' => $plugin[ 'id' ], 'upgrade' => $upgrade_button ); } } $options[ 'account_key' ] = $key; } self::set_options( $options ); delete_site_transient( 'update_plugins' ); $out = json_encode( $out ); set_transient( 'brupdate_' . $id . '_' . $key, $out, 600 ); } else { $data = array( 'key_exist' => 0, 'status' => 'Failed', 'error' => $response->get_error_message() ); $out = json_encode( $data ); } } self::update_check_set(''); } echo $out; wp_die(); } public static function scripts() { ?>DEBUG MODE |
|||
Account key |
'; if ( isset( $plugin[ 'name' ] ) ) { echo $plugin[ 'name' ]; } else { echo $plugin[ 'slug' ]; } echo ' | ';
echo ''; echo ' | '; echo ' | '; echo ''; unset( $plugins_key[ $plugin[ 'id' ] ] ); } foreach ( $plugins_key as $key_id => $key_val ) { echo ''; } ?> |