| @@ -1,1940 +1,489 @@ | ||
| 1 | 1 | <?php |
| 2 | -/** | |
| 3 | - * MainWP Hooks | |
| 4 | - * | |
| 5 | - * @package MainWP/Dashboard | |
| 6 | - */ | |
| 7 | 2 | |
| 8 | -namespace MainWP\Dashboard; | |
| 3 | +class MainWP_Hooks { | |
| 9 | 4 | |
| 10 | -// phpcs:disable Generic.Metrics.CyclomaticComplexity -- complexity. | |
| 5 | + public function __construct() { | |
| 6 | + add_filter( 'mainwp_getspecificdir', array( 'MainWP_Utility', 'getMainWPSpecificDir' ), 10, 1 ); | |
| 7 | + add_filter( 'mainwp_getmainwpdir', array( &$this, 'get_mainwp_dir' ), 10, 3 ); | |
| 8 | + add_filter( 'mainwp_is_multi_user', array( &$this, 'isMultiUser' ) ); | |
| 9 | + add_filter( 'mainwp_qq2fileuploader', array( &$this, 'filter_qq2FileUploader' ), 10, 2 ); | |
| 10 | + add_action( 'mainwp_select_sites_box', array( &$this, 'select_sites_box' ), 10, 8 ); | |
| 11 | + add_action( 'mainwp_prepareinstallplugintheme', array( 'MainWP_Install_Bulk', 'prepareInstall' ) ); | |
| 12 | + add_action( 'mainwp_performinstallplugintheme', array( 'MainWP_Install_Bulk', 'performInstall' ) ); | |
| 13 | + add_filter( 'mainwp_getwpfilesystem', array( 'MainWP_Utility', 'getWPFilesystem' ) ); | |
| 14 | + add_filter( 'mainwp_getspecificurl', array( 'MainWP_Utility', 'getMainWPSpecificUrl' ), 10, 1 ); | |
| 15 | + add_filter( 'mainwp_getdownloadurl', array( 'MainWP_Utility', 'getDownloadUrl' ), 10, 2 ); | |
| 16 | + add_action( 'mainwp_renderToolTip', array( 'MainWP_Utility', 'renderToolTip' ), 10, 4 ); | |
| 17 | + add_action( 'mainwp_renderHeader', array( 'MainWP_UI', 'renderHeader' ), 10, 2 ); | |
| 18 | + add_action( 'mainwp_renderFooter', array( 'MainWP_UI', 'renderFooter' ), 10, 0 ); | |
| 19 | + add_action( 'mainwp_renderImage', array( 'MainWP_UI', 'renderImage' ), 10, 4 ); | |
| 20 | + add_action( 'mainwp_notify_user', array( &$this, 'notifyUser' ), 10, 3 ); | |
| 21 | + add_action( 'mainwp_activePlugin', array( &$this, 'activePlugin' ), 10, 0 ); | |
| 22 | + add_action( 'mainwp_deactivePlugin', array( &$this, 'deactivePlugin' ), 10, 0 ); | |
| 23 | + add_action( 'mainwp_upgradePluginTheme', array( &$this, 'upgradePluginTheme' ), 10, 0 ); | |
| 24 | + add_action( 'mainwp_deletePlugin', array( &$this, 'deletePlugin' ), 10, 0 ); | |
| 25 | + add_action( 'mainwp_deleteTheme', array( &$this, 'deleteTheme' ), 10, 0 ); | |
| 26 | + add_action( 'mainwp_renderBeginModal', array( 'MainWP_UI', 'render_begin_modal' ), 10, 2 ); | |
| 27 | + add_action( 'mainwp_renderEndModal', array( 'MainWP_UI', 'render_end_modal' ), 10, 2 ); | |
| 11 | 28 | |
| 12 | -/** | |
| 13 | - * Class MainWP_Hooks | |
| 14 | - * | |
| 15 | - * @package MainWP\Dashboard | |
| 16 | - */ | |
| 17 | -class MainWP_Hooks { // phpcs:ignore Generic.Classes.OpeningBraceSameLine.ContentAfterBrace -- NOSONAR. | |
| 18 | - /** | |
| 19 | - * MainWP_Hooks constructor. | |
| 20 | - * | |
| 21 | - * Initialize MainWP_Hooks actions/filters upon creation of the object. | |
| 22 | - * | |
| 23 | - * @deprecated 4.0.7. Hook deprecation - Please use filter `mainwp_get_error_message` instead of `mainwp_getErrorMessage`. | |
| 24 | - * | |
| 25 | - * @uses \MainWP\Dashboard\MainWP_System_Utility::get_class_name() | |
| 26 | - * @uses \MainWP\Dashboard\MainWP_UI::get_class_name() | |
| 27 | - * @uses \MainWP\Dashboard\MainWP_Extensions_Handler::get_class_name() | |
| 28 | - * @uses \MainWP\Dashboard\MainWP_Install_Bulk::get_class_name() | |
| 29 | - */ | |
| 30 | - public function __construct() { | |
| 31 | - add_filter( 'mainwp_getspecificdir', array( MainWP_System_Utility::get_class_name(), 'get_mainwp_specific_dir' ), 10, 1 ); | |
| 32 | - add_filter( 'mainwp_getmainwpdir', array( &$this, 'hook_get_mainwp_dir' ), 10, 3 ); | |
| 33 | - add_filter( 'mainwp_is_multi_user', array( &$this, 'is_multi_user' ) ); | |
| 34 | - add_filter( 'mainwp_qq2fileuploader', array( &$this, 'filter_qq2_file_uploader' ), 10, 2 ); | |
| 35 | - add_action( 'mainwp_select_sites_box', array( &$this, 'hook_select_sites_box' ), 10, 12 ); | |
| 36 | - add_action( 'mainwp_add_categories_box', array( &$this, 'hook_add_categories_box' ), 10, 1 ); | |
| 37 | - add_action( 'mainwp_prepareinstallplugintheme', array( MainWP_Install_Bulk::get_class_name(), 'prepare_install' ) ); | |
| 38 | - add_action( 'mainwp_performinstallplugintheme', array( MainWP_Install_Bulk::get_class_name(), 'perform_install' ) ); | |
| 39 | - add_filter( 'mainwp_getwpfilesystem', array( MainWP_System_Utility::get_class_name(), 'get_wp_file_system' ) ); | |
| 40 | - add_filter( 'mainwp_getspecificurl', array( MainWP_System_Utility::get_class_name(), 'get_mainwp_specific_url' ), 10, 1 ); | |
| 41 | - add_filter( 'mainwp_getdownloadurl', array( MainWP_System_Utility::get_class_name(), 'get_download_url' ), 10, 2 ); | |
| 42 | - add_action( 'mainwp_renderHeader', array( MainWP_UI::get_class_name(), 'render_header' ), 10, 2 ); | |
| 43 | - add_action( 'mainwp_renderFooter', array( MainWP_UI::get_class_name(), 'render_footer' ), 10, 0 ); | |
| 29 | + //Internal hook - deprecated | |
| 30 | + add_filter( 'mainwp_getUserExtension', array( &$this, 'getUserExtension' ) ); | |
| 31 | + add_filter( 'mainwp_getwebsitesbyurl', array( &$this, 'getWebsitesByUrl' ) ); | |
| 32 | + add_filter( 'mainwp_getWebsitesByUrl', array( &$this, 'getWebsitesByUrl' ) ); //legacy | |
| 33 | + add_filter( 'mainwp_getErrorMessage', array( &$this, 'getErrorMessage' ), 10, 2 ); | |
| 34 | + add_filter( 'mainwp_getwebsitesbygroupids', array( &$this, 'hookGetWebsitesByGroupIds' ), 10, 2 ); | |
| 44 | 35 | |
| 45 | - add_action( 'mainwp_notify_user', array( &$this, 'hook_notify_user' ), 10, 3 ); | |
| 46 | - add_filter( 'mainwp_is_mainwp_page', array( MainWP_System::class, 'is_mainwp_pages' ) ); | |
| 36 | + //Cache hooks | |
| 37 | + add_filter( 'mainwp_cache_getcontext', array( &$this, 'cache_getcontext' ) ); | |
| 38 | + add_action( 'mainwp_cache_echo_body', array( &$this, 'cache_echo_body' ) ); | |
| 39 | + add_action( 'mainwp_cache_init', array( &$this, 'cache_init' ) ); | |
| 40 | + add_action( 'mainwp_cache_add_context', array( &$this, 'cache_add_context' ), 10, 2 ); | |
| 41 | + add_action( 'mainwp_cache_add_body', array( &$this, 'cache_add_body' ), 10, 2 ); | |
| 47 | 42 | |
| 48 | - /** | |
| 49 | - * The actions has been deprecated. | |
| 50 | - * | |
| 51 | - * @deprecated 4.3 Please use actions: mainwp_action_activeplugin, mainwp_action_deactiveplugin .... | |
| 52 | - */ | |
| 53 | - add_action( 'mainwp_activePlugin', array( &$this, 'active_plugin' ), 10, 0 ); | |
| 54 | - add_action( 'mainwp_deactivePlugin', array( &$this, 'deactive_plugin' ), 10, 0 ); | |
| 55 | - add_action( 'mainwp_upgradePluginTheme', array( &$this, 'upgrade_plugin_theme' ), 10, 0 ); | |
| 56 | - add_action( 'mainwp_deletePlugin', array( &$this, 'delete_plugin' ), 10, 0 ); | |
| 57 | - add_action( 'mainwp_deleteTheme', array( &$this, 'delete_theme' ), 10, 0 ); | |
| 58 | - // End. | |
| 59 | - | |
| 60 | - /** | |
| 61 | - * Plugins/themes/core actions. | |
| 62 | - * | |
| 63 | - * @since 4.3 | |
| 64 | - */ | |
| 65 | - add_action( 'mainwp_action_activeplugin', array( &$this, 'active_plugin' ), 10, 0 ); | |
| 66 | - add_action( 'mainwp_action_deactiveplugin', array( &$this, 'deactive_plugin' ), 10, 0 ); | |
| 67 | - add_action( 'mainwp_action_upgradeplugintheme', array( &$this, 'upgrade_plugin_theme' ), 10, 0 ); | |
| 68 | - add_action( 'mainwp_action_deleteplugin', array( &$this, 'delete_plugin' ), 10, 0 ); | |
| 69 | - add_action( 'mainwp_action_deletetheme', array( &$this, 'delete_theme' ), 10, 0 ); | |
| 70 | - add_action( 'mainwp_upgrade_wp', array( &$this, 'upgrade_wp' ), 10, 0 ); | |
| 71 | - // End. | |
| 72 | - | |
| 73 | - add_filter( 'mainwp_get_user_extension', array( &$this, 'hook_get_user_extension' ), 10, 2 ); | |
| 74 | - add_filter( 'mainwp_update_user_extension', array( &$this, 'update_user_extension' ), 10, 3 ); | |
| 75 | - add_filter( 'mainwp_getwebsitesbyurl', array( &$this, 'get_websites_by_url' ) ); | |
| 76 | - add_filter( 'mainwp_getWebsitesByUrl', array( &$this, 'get_websites_by_url' ) ); | |
| 77 | - add_action( 'mainwp_manage_posts_get_edit', array( &$this, 'hook_posts_get_edit' ), 10, 2 ); | |
| 78 | - add_action( 'mainwp_manage_posts_bulk_posting', array( &$this, 'hook_posts_bulk_posting' ), 10, 2 ); | |
| 79 | - | |
| 80 | - /** | |
| 81 | - * The mainwp_getErrorMessage filter has been deprecated. | |
| 82 | - * | |
| 83 | - * @deprecated 4.0.7. Please use filter mainwp_get_error_message. | |
| 84 | - */ | |
| 85 | - add_filter( 'mainwp_getErrorMessage', array( &$this, 'get_error_message' ), 10, 2 ); | |
| 86 | - add_filter( 'mainwp_get_error_message', array( &$this, 'get_error_message' ), 10, 2 ); | |
| 87 | - | |
| 88 | - add_filter( 'mainwp_getwebsitesbygroupids', array( &$this, 'hook_get_websites_by_group_ids' ), 10, 2 ); | |
| 89 | - | |
| 90 | - add_filter( 'mainwp_cache_getcontext', array( &$this, 'cache_getcontext' ) ); | |
| 91 | - add_action( 'mainwp_cache_echo_body', array( &$this, 'cache_echo_body' ) ); | |
| 92 | - add_action( 'mainwp_cache_init', array( &$this, 'cache_init' ) ); | |
| 93 | - add_action( 'mainwp_cache_add_context', array( &$this, 'cache_add_context' ), 10, 2 ); | |
| 94 | - add_action( 'mainwp_cache_add_body', array( &$this, 'cache_add_body' ), 10, 2 ); | |
| 95 | - | |
| 96 | - add_filter( 'mainwp_get_metaboxes_post', array( &$this, 'get_metaboxes_post' ), 10, 0 ); | |
| 97 | - add_filter( 'mainwp_getnotificationemail', array( &$this, 'hook_notification_email' ), 10, 1 ); | |
| 98 | - add_filter( 'mainwp_getformatemail', array( &$this, 'get_formated_email' ), 10, 3 ); | |
| 99 | - add_filter( 'mainwp-extension-available-check', array( MainWP_Extensions_Handler::get_class_name(), 'is_extension_available' ) ); | |
| 100 | - add_filter( 'mainwp_extension_is_activated', array( &$this, 'is_extension_activated' ), 10, 2 ); | |
| 101 | - add_filter( 'mainwp_extension_is_pro_member', array( &$this, 'is_pro_member' ), 10, 1 ); | |
| 102 | - | |
| 103 | - /** | |
| 104 | - * Logging debug actions. | |
| 105 | - */ | |
| 106 | - add_action( 'mainwp_log_debug', array( &$this, 'mainwp_log_debug' ), 10, 1 ); | |
| 107 | - add_action( 'mainwp_log_info', array( &$this, 'mainwp_log_info' ), 10, 1 ); | |
| 108 | - add_action( 'mainwp_log_warning', array( &$this, 'mainwp_log_warning' ), 10, 1 ); | |
| 109 | - add_action( 'mainwp_log_action', array( &$this, 'mainwp_log_action' ), 10, 4 ); | |
| 110 | - add_action( 'mainwp_log_execution_time', array( &$this, 'mainwp_log_execution_time' ), 10, 1 ); | |
| 111 | - // END. | |
| 112 | - | |
| 113 | - add_filter( 'mainwp_getactivateextensionnotice', array( &$this, 'get_activate_extension_notice' ), 10, 1 ); | |
| 114 | - add_action( 'mainwp_enqueue_meta_boxes_scripts', array( &$this, 'enqueue_meta_boxes_scripts' ), 10, 1 ); | |
| 115 | - add_filter( 'mainwp_addsite', array( &$this, 'mainwp_add_site' ), 10, 1 ); | |
| 116 | - add_filter( 'mainwp_deletesite', array( &$this, 'hook_delete_site' ), 10, 1 ); | |
| 117 | - add_filter( 'mainwp_clonesite', array( &$this, 'filter_clone_site' ), 10, 6 ); | |
| 43 | + add_filter( 'mainwp_getmetaboxes', array( &$this, 'getMetaBoxes' ), 10, 0 ); | |
| 44 | + add_filter( 'mainwp_getnotificationemail', array( 'MainWP_Utility', 'getNotificationEmail' ), 10, 1 ); | |
| 45 | + add_filter( 'mainwp_getformatemail', array( &$this, 'get_format_email' ), 10, 3 ); | |
| 46 | + add_filter( 'mainwp-extension-available-check', array( | |
| 47 | + MainWP_Extensions::getClassName(), | |
| 48 | + 'isExtensionAvailable', | |
| 49 | + ) ); | |
| 50 | + add_filter( 'mainwp-extension-decrypt-string', array( &$this, 'hookDecryptString' ) ); | |
| 51 | + add_action( 'mainp_log_debug', array( &$this, 'mainwp_log_debug' ), 10, 1 ); | |
| 52 | + add_action( 'mainp_log_info', array( &$this, 'mainwp_log_info' ), 10, 1 ); | |
| 53 | + add_action( 'mainp_log_warning', array( &$this, 'mainwp_log_warning' ), 10, 1 ); | |
| 54 | + add_filter( 'mainwp_getactivateextensionnotice', array( &$this, 'get_activate_extension_notice' ), 10, 1 ); | |
| 55 | + add_action( 'mainwp_enqueue_meta_boxes_scripts', array( &$this, 'enqueue_meta_boxes_scripts' ), 10, 1 ); | |
| 56 | + add_action( 'mainwp_do_meta_boxes', array( &$this, 'mainwp_do_meta_boxes' ), 10, 1 ); | |
| 57 | + add_filter( 'mainwp_addsite', array( &$this, 'mainwp_add_site' ), 10, 1 ); | |
| 58 | + add_filter( 'mainwp_deletesite', array( &$this, 'hook_delete_site' ), 10, 1 ); | |
| 59 | + add_filter( 'mainwp_clonesite', array( &$this, 'filter_clone_site' ), 10, 6 ); | |
| 118 | 60 | add_filter( 'mainwp_delete_clonesite', array( &$this, 'filter_delete_clone_site' ), 10, 4 ); |
| 119 | - add_filter( 'mainwp_editsite', array( &$this, 'mainwp_edit_site' ), 10, 1 ); | |
| 120 | - add_action( 'mainwp_add_sub_leftmenu', array( &$this, 'hook_add_sub_left_menu' ), 10, 6 ); | |
| 121 | - add_filter( 'mainwp_getwebsiteoptions', array( &$this, 'hook_get_site_options' ), 10, 3 ); | |
| 122 | - add_filter( 'mainwp_updatewebsiteoptions', array( &$this, 'hook_update_site_options' ), 10, 4 ); | |
| 61 | + add_filter( 'mainwp_editsite', array( &$this, 'mainwp_edit_site' ), 10, 1 ); | |
| 62 | + add_action( 'mainwp_add_sub_leftmenu', array( &$this, 'hookAddSubLeftMenu' ), 10, 6 ); | |
| 63 | + add_filter( 'mainwp_getwebsiteoptions', array( &$this, 'getWebsiteOptions' ), 10, 3 ); | |
| 64 | + add_filter( 'mainwp_addgroup', array( 'MainWP_Extensions', 'hookAddGroup' ), 10, 3 ); | |
| 65 | + add_filter( 'mainwp_getallposts', array( &$this, 'hookGetAllPosts' ), 10, 2 ); | |
| 66 | + } | |
| 123 | 67 | |
| 124 | - add_filter( 'mainwp_getwebsitesbyuserid', array( &$this, 'hook_get_websites_by_user_id' ), 10, 5 ); | |
| 125 | - add_filter( 'mainwp_getwebsite_by_id', array( &$this, 'hook_get_website_by_id' ), 10, 4 ); | |
| 68 | + public function mainwp_log_debug( $pText ) { | |
| 69 | + MainWP_Logger::Instance()->debug( $pText ); | |
| 70 | + } | |
| 126 | 71 | |
| 127 | - add_filter( 'mainwp_addgroup', array( MainWP_Extensions_Handler::get_class_name(), 'hook_add_group' ), 10, 3 ); | |
| 128 | - add_filter( 'mainwp_getallposts', array( &$this, 'hook_get_all_posts' ), 10, 2 ); | |
| 129 | - add_filter( 'mainwp_check_current_user_can', array( &$this, 'hook_current_user_can' ), 10, 3 ); | |
| 130 | - add_filter( 'mainwp_escape_response_data', array( &$this, 'hook_escape_response' ), 10, 3 ); | |
| 131 | - add_filter( 'mainwp_escape_content', array( &$this, 'hook_escape_content' ), 10, 3 ); | |
| 72 | + public function mainwp_log_info( $pText ) { | |
| 73 | + MainWP_Logger::Instance()->info( $pText ); | |
| 74 | + } | |
| 132 | 75 | |
| 133 | - add_filter( 'mainwp_db_query', array( &$this, 'hook_db_query' ), 10, 2 ); | |
| 134 | - add_filter( 'mainwp_db_fetch_object', array( &$this, 'db_fetch_object' ), 10, 2 ); | |
| 135 | - add_filter( 'mainwp_db_fetch_array', array( &$this, 'db_fetch_array' ), 10, 2 ); | |
| 136 | - add_action( 'mainwp_db_data_seek', array( &$this, 'hook_db_data_seek' ), 10, 2 ); | |
| 137 | - add_filter( 'mainwp_db_free_result', array( &$this, 'db_free_result' ), 10, 2 ); | |
| 138 | - add_filter( 'mainwp_db_num_rows', array( &$this, 'db_num_rows' ), 10, 2 ); | |
| 139 | - add_filter( 'mainwp_db_get_websites_for_current_user', array( &$this, 'db_get_websites_for_current_user' ), 10, 2 ); | |
| 76 | + public function mainwp_log_warning( $pText ) { | |
| 77 | + MainWP_Logger::Instance()->warning( $pText ); | |
| 78 | + } | |
| 140 | 79 | |
| 141 | - // Sync website. | |
| 142 | - add_filter( 'mainwp_sync_website', array( &$this, 'hook_sync_website' ), 10, 3 ); | |
| 80 | + public function enqueue_meta_boxes_scripts() { | |
| 81 | + MainWP_System::enqueue_postbox_scripts(); | |
| 82 | + } | |
| 143 | 83 | |
| 144 | - add_action( 'mainwp_secure_request', array( &$this, 'hook_secure_request' ), 10, 2 ); | |
| 145 | - add_filter( 'mainwp_check_security_request', array( &$this, 'hook_check_security_request' ), 10, 3 ); | |
| 146 | - add_filter( 'mainwp_notification_get_settings', array( &$this, 'get_notification_settings' ), 10, 2 ); | |
| 84 | + // going to retired | |
| 85 | + public function mainwp_do_meta_boxes( $postpage ) { | |
| 86 | + MainWP_System::do_mainwp_meta_boxes( $postpage ); | |
| 87 | + } | |
| 147 | 88 | |
| 148 | - add_filter( 'mainwp_send_wp_mail', array( &$this, 'hook_send_wp_mail' ), 10, 5 ); | |
| 149 | - add_filter( 'mainwp_notification_get_template_content', array( &$this, 'hook_get_template_html' ), 10, 3 ); | |
| 150 | - add_filter( 'mainwp_sitestable_getcolumns', array( $this, 'hook_atarim_default_sitestable_column' ), 10, 1 ); | |
| 151 | - add_filter( 'mainwp_sitestable_item', array( $this, 'hook_atarim_manage_sites_default_item' ), 10, 1 ); | |
| 152 | - add_filter( 'mainwp_monitoring_sitestable_getcolumns', array( $this, 'hook_atarim_default_sitestable_column' ), 10, 1 ); | |
| 153 | - add_filter( 'mainwp_monitoring_sitestable_item', array( $this, 'hook_atarim_manage_sites_default_item' ), 10, 1 ); | |
| 154 | - add_filter( 'mainwp_clients_get_website_client_tokens', array( &$this, 'hook_get_website_client_tokens' ), 10, 2 ); | |
| 155 | - add_filter( 'mainwp_secure_get_download_sig', array( &$this, 'hook_get_download_sig' ), 10, 2 ); | |
| 156 | - add_action( 'mainwp_secure_download', array( &$this, 'hook_secure_download' ), 10, 3 ); | |
| 157 | - add_action( 'mainwp_ajax_add_action', array( &$this, 'hook_ajax_add_action' ), 10, 2 ); | |
| 158 | - add_filter( 'mainwp_get_plugin_icon', array( &$this, 'hook_get_plugin_icon' ), 10, 2 ); | |
| 159 | - add_filter( 'mainwp_get_theme_icon', array( &$this, 'hook_get_theme_icon' ), 10, 2 ); | |
| 160 | - add_filter( 'mainwp_get_dir_slug', array( &$this, 'hook_get_dir_slug' ), 10, 2 ); | |
| 161 | - add_action( 'mainwp_do_widget_boxes', array( &$this, 'hook_do_widget_boxes' ), 10, 3 ); | |
| 162 | - add_action( 'mainwp_add_widget_box', array( &$this, 'hook_add_widget_box' ), 10, 6 ); | |
| 163 | - add_action( 'mainwp_render_modal_upload_icon', array( &$this, 'hook_render_modal_upload_icon' ), 10, 2 ); | |
| 164 | - add_action( 'mainwp_render_plugin_details_modal', array( &$this, 'hook_render_plugin_details_modal' ), 10, 2 ); | |
| 165 | - add_action( 'mainwp_render_updates', array( &$this, 'hook_render_updates' ), 10, 2 ); | |
| 166 | - add_filter( 'mainwp_get_wp_client_by', array( &$this, 'hook_get_wp_client_by' ), 10, 4 ); | |
| 89 | + /** | |
| 90 | + * Hook to add site | |
| 91 | + * | |
| 92 | + * @since 3.2.2 | |
| 93 | + * @param array $params site data fields: url, name, wpadmin, unique_id, groupids, ssl_verify, ssl_version, http_user, http_pass, websiteid - if edit site | |
| 94 | + * | |
| 95 | + * @return array | |
| 96 | + * | |
| 97 | + */ | |
| 98 | + public function mainwp_add_site( $params ) { | |
| 99 | + $ret = array(); | |
| 167 | 100 | |
| 168 | - /** | |
| 169 | - * Filter: mainwp_get_tokens_values | |
| 170 | - * | |
| 171 | - * Get tokens values for reports. | |
| 172 | - * | |
| 173 | - * @since 4.3. | |
| 174 | - */ | |
| 175 | - add_filter( 'mainwp_get_reports_group_values_website', array( MainWP_Reports_Helper::get_instance(), 'hook_get_reports_group_values' ), 10, 6 ); | |
| 101 | + if ( is_array( $params ) ) { | |
| 102 | + if ( isset( $params[ 'websiteid' ] ) && MainWP_Utility::ctype_digit( $websiteid = $params[ 'websiteid' ] ) ) { | |
| 103 | + $ret[ 'siteid' ] = MainWP_Hooks::updateWPSite( $params ); | |
| 104 | + return $ret; | |
| 105 | + } else if ( isset( $params[ 'url' ] ) && isset( $params[ 'wpadmin' ] ) ) { | |
| 106 | + //Check if already in DB | |
| 107 | + $website = MainWP_DB::Instance()->getWebsitesByUrl( $params[ 'url' ] ); | |
| 108 | + list( $message, $error, $site_id ) = MainWP_Manage_Sites_View::addWPSite( $website, $params ); | |
| 176 | 109 | |
| 177 | - /** | |
| 178 | - * MainWP API hooks. | |
| 179 | - * | |
| 180 | - * @since 4.5. | |
| 181 | - */ | |
| 182 | - add_filter( 'mainwp_extension_get_activation_info', array( &$this, 'hook_get_activation_info' ), 10, 2 ); | |
| 183 | - add_filter( 'mainwp_get_api_url', array( &$this, 'hook_get_api_url' ), 10, 1 ); | |
| 184 | - add_filter( 'mainwp_hook_run_dashboard_action', array( &$this, 'hook_run_dashboard_action' ), 10, 2 ); | |
| 110 | + if ( $error != '' ) { | |
| 111 | + return array( 'error' => $error ); | |
| 112 | + } | |
| 113 | + $ret[ 'response' ] = $message; | |
| 114 | + $ret[ 'siteid' ] = $site_id; | |
| 115 | + } | |
| 116 | + } | |
| 185 | 117 | |
| 186 | - /** | |
| 187 | - * Key encrypt hooks. | |
| 188 | - * | |
| 189 | - * @since 4.5. | |
| 190 | - */ | |
| 191 | - add_filter( 'mainwp_get_key_value', array( &$this, 'hook_get_key_value' ), 10, 3 ); | |
| 192 | - add_filter( 'mainwp_update_key_value', array( &$this, 'hook_update_key_value' ), 10, 4 ); | |
| 193 | - add_action( 'mainwp_delete_key_value', array( &$this, 'hook_delete_key_value' ), 10, 1 ); | |
| 194 | - | |
| 195 | - add_filter( 'mainwp_encrypt_key_value', array( &$this, 'hook_encrypt_key_value' ), 10, 4 ); | |
| 196 | - add_filter( 'mainwp_decrypt_key_value', array( &$this, 'hook_decrypt_key_value' ), 10, 3 ); | |
| 197 | - add_action( 'mainwp_delete_key_file', array( &$this, 'hook_delete_key_file' ), 10, 1 ); | |
| 198 | - add_filter( 'mainwp_verify_ping_nonce', array( MainWP_Utility::class, 'hook_verify_ping_nonce' ), 10, 3 ); | |
| 199 | - add_action( 'mainwp_fetch_url_authed', array( MainWP_Actions_Handler::instance(), 'hook_mainwp_fetch_url_authed' ), 10, 5 ); | |
| 200 | - | |
| 201 | - add_filter( 'mainwp_get_lookup_items', array( &$this, 'hook_get_lookup_items' ), 10, 4 ); | |
| 202 | - add_filter( 'mainwp_insert_lookup_item', array( &$this, 'hook_insert_lookup_item' ), 10, 5 ); | |
| 203 | - add_filter( 'mainwp_delete_lookup_items', array( &$this, 'hook_delete_lookup_items' ), 10, 3 ); | |
| 204 | - add_filter( 'mainwp_get_indicator', array( &$this, 'hook_get_indicator' ), 10, 4 ); | |
| 205 | - } | |
| 206 | - | |
| 207 | - /** | |
| 208 | - * Method get_instance(). | |
| 209 | - */ | |
| 210 | - public static function get_instance() { | |
| 211 | - return new self(); | |
| 212 | - } | |
| 213 | - | |
| 214 | - /** | |
| 215 | - * Method mainwp_log_debug() | |
| 216 | - * | |
| 217 | - * MainWP debug log. | |
| 218 | - * | |
| 219 | - * @param string $text Debug text. | |
| 220 | - * | |
| 221 | - * @uses \MainWP\Dashboard\MainWP_Logger::debug() | |
| 222 | - */ | |
| 223 | - public function mainwp_log_debug( $text ) { | |
| 224 | - MainWP_Logger::instance()->debug( $text ); | |
| 225 | - } | |
| 226 | - | |
| 227 | - /** | |
| 228 | - * Method mainwp_log_info() | |
| 229 | - * | |
| 230 | - * MainWP log info. | |
| 231 | - * | |
| 232 | - * @param string $text Info Text. | |
| 233 | - * | |
| 234 | - * @uses \MainWP\Dashboard\MainWP_Logger::info() | |
| 235 | - */ | |
| 236 | - public function mainwp_log_info( $text ) { | |
| 237 | - MainWP_Logger::instance()->info( $text ); | |
| 238 | - } | |
| 239 | - | |
| 240 | - /** | |
| 241 | - * Method mainwp_log_warning() | |
| 242 | - * | |
| 243 | - * MainWP log warning. | |
| 244 | - * | |
| 245 | - * @param string $text Warning text. | |
| 246 | - * | |
| 247 | - * @uses \MainWP\Dashboard\MainWP_Logger::warning() | |
| 248 | - */ | |
| 249 | - public function mainwp_log_warning( $text ) { | |
| 250 | - MainWP_Logger::instance()->warning( $text ); | |
| 251 | - } | |
| 252 | - | |
| 253 | - /** | |
| 254 | - * Method mainwp_log_action() | |
| 255 | - * | |
| 256 | - * MainWP log action. | |
| 257 | - * | |
| 258 | - * @param string $text Debug text. | |
| 259 | - * @param int $priority priority: -1 disabled, 0 - log, 1 - warning, 2 - info, 3 - debug. | |
| 260 | - * @param int $log_color Set color: 0 - LOG, 1 - WARNING, 2 - INFO, 3- DEBUG. | |
| 261 | - * @param bool $forced forced logging. | |
| 262 | - * | |
| 263 | - * @uses \MainWP\Dashboard\MainWP_Logger::debug() | |
| 264 | - */ | |
| 265 | - public function mainwp_log_action( $text, $priority = 0, $log_color = 0, $forced = false ) { | |
| 266 | - if ( ! empty( $priority ) ) { | |
| 267 | - MainWP_Logger::instance()->log_action( $text, $priority, $log_color, $forced ); | |
| 268 | - } | |
| 269 | - } | |
| 270 | - | |
| 271 | - /** | |
| 272 | - * Method mainwp_log_execution_time() | |
| 273 | - * | |
| 274 | - * MainWP log execution time. | |
| 275 | - * | |
| 276 | - * @param string $text Debug text. | |
| 277 | - * | |
| 278 | - * @uses \MainWP\Dashboard\MainWP_Logger::debug() | |
| 279 | - */ | |
| 280 | - public function mainwp_log_execution_time( $text = '' ) { | |
| 281 | - MainWP_Logger::instance()->log_execution_time( $text ); | |
| 282 | - } | |
| 283 | - | |
| 284 | - /** | |
| 285 | - * Method enqueue_meta_boxes_scripts() | |
| 286 | - * | |
| 287 | - * Enqueue Scripts for all Meta boxes. | |
| 288 | - * | |
| 289 | - * @uses \MainWP\Dashboard\MainWP_System::enqueue_postbox_scripts() | |
| 290 | - */ | |
| 291 | - public function enqueue_meta_boxes_scripts() { | |
| 292 | - MainWP_System::enqueue_postbox_scripts(); | |
| 293 | - } | |
| 294 | - | |
| 295 | - /** | |
| 296 | - * Method mainwp_add_site() | |
| 297 | - * | |
| 298 | - * Hook to add Child Site. | |
| 299 | - * | |
| 300 | - * @param array $params site data fields: url, name, wpadmin, unique_id, groupids, ssl_verify, ssl_version, | |
| 301 | - * http_user, http_pass, websiteid - if edit site. | |
| 302 | - * | |
| 303 | - * @return array $ret data fields: response, siteid. | |
| 304 | - * | |
| 305 | - * @throws \MainWP_Exception Exception message. | |
| 306 | - * | |
| 307 | - * @since 3.2.2 | |
| 308 | - * | |
| 309 | - * @uses \MainWP\Dashboard\MainWP_Manage_Sites_View::update_wp_site() | |
| 310 | - * @uses \MainWP\Dashboard\MainWP_Manage_Sites_View::add_wp_site() | |
| 311 | - * @uses \MainWP\Dashboard\MainWP_Utility::ctype_digit() | |
| 312 | - */ | |
| 313 | - public function mainwp_add_site( $params ) { | |
| 314 | - $ret = array(); | |
| 315 | - | |
| 316 | - if ( is_array( $params ) ) { | |
| 317 | - if ( isset( $params['websiteid'] ) && MainWP_Utility::ctype_digit( $params['websiteid'] ) ) { | |
| 318 | - $ret['siteid'] = MainWP_Manage_Sites_View::update_wp_site( $params ); | |
| 319 | - return $ret; | |
| 320 | - } elseif ( isset( $params['url'] ) && isset( $params['wpadmin'] ) ) { | |
| 321 | - $website = MainWP_DB::instance()->get_websites_by_url( $params['url'] ); | |
| 322 | - list( $message, $error, $site_id ) = MainWP_Manage_Sites_View::add_wp_site( $website, $params ); | |
| 323 | - | |
| 324 | - if ( '' !== $error ) { | |
| 325 | - return array( 'error' => $error ); | |
| 326 | - } | |
| 327 | - $ret['response'] = $message; | |
| 328 | - $ret['siteid'] = $site_id; | |
| 329 | - } | |
| 330 | - } | |
| 331 | - | |
| 332 | - return $ret; | |
| 333 | - } | |
| 334 | - | |
| 335 | - /** | |
| 336 | - * Method is_pro_member() | |
| 337 | - * | |
| 338 | - * Check for inactive MainWP Extensions. | |
| 339 | - * | |
| 340 | - * @param mixed $input Input value. | |
| 341 | - * | |
| 342 | - * @return bool Activation notice. | |
| 343 | - */ | |
| 344 | - public static function is_pro_member( $input = false ) { | |
| 345 | - $info = get_option( 'mainwp_extensions_plan_info' ); | |
| 346 | - if ( ! empty( $info ) ) { | |
| 347 | - $info = json_decode( $info, true ); | |
| 348 | - if ( is_array( $info ) && isset( $info['plan_purchased'] ) && isset( $info['plan_status'] ) && 'active' === $info['plan_status'] && in_array( $info['plan_purchased'], array( 'monthly', 'yearly', 'lifetime' ) ) ) { | |
| 349 | - return true; | |
| 350 | - } | |
| 351 | - } | |
| 352 | - return $input; | |
| 353 | - } | |
| 354 | - | |
| 355 | - | |
| 356 | - /** | |
| 357 | - * Method hook_delete_site() | |
| 358 | - * | |
| 359 | - * Hook to delete Child Site. | |
| 360 | - * | |
| 361 | - * @param bool $site_id Child site ID. | |
| 362 | - * | |
| 363 | - * @return bool|array Return false if empty and return array error - Site not found | result - SUCCESS. | |
| 364 | - * | |
| 365 | - * @uses \MainWP\Dashboard\MainWP_System_Utility::get_wp_file_system() | |
| 366 | - * @uses \MainWP\Dashboard\MainWP_System_Utility::get_icons_dir() | |
| 367 | - */ | |
| 368 | - public function hook_delete_site( $site_id = false ) { | |
| 369 | - | |
| 370 | - if ( empty( $site_id ) ) { | |
| 118 | + return $ret; | |
| 119 | + } | |
| 120 | + | |
| 121 | + public function hook_delete_site( $site_id = false ) { | |
| 122 | + | |
| 123 | + if ( empty( $site_id ) ) | |
| 371 | 124 | return false; |
| 372 | - } | |
| 373 | 125 | |
| 374 | - $sql = MainWP_DB::instance()->get_sql_website_by_id( $site_id ); | |
| 375 | - $websites = MainWP_DB::instance()->query( $sql ); | |
| 376 | - $site = MainWP_DB::fetch_object( $websites ); | |
| 126 | + $sql = MainWP_DB::Instance()->getSQLWebsiteById( $site_id ); | |
| 127 | + $websites = MainWP_DB::Instance()->query( $sql ); | |
| 128 | + $site = @MainWP_DB::fetch_object( $websites ); | |
| 377 | 129 | |
| 378 | - if ( empty( $site ) ) { | |
| 379 | - return array( 'error' => esc_html__( 'Not found the website', 'mainwp' ) ); | |
| 130 | + if ( empty( $site )) { | |
| 131 | + return array('error' => __('Not found the website', 'mainwp')); | |
| 380 | 132 | } |
| 381 | - $hasWPFileSystem = MainWP_System_Utility::get_wp_file_system(); | |
| 382 | 133 | |
| 383 | - /** | |
| 384 | - * WordPress files system object. | |
| 385 | - * | |
| 386 | - * @global object | |
| 387 | - */ | |
| 388 | - global $wp_filesystem; | |
| 134 | + // delete icon file | |
| 135 | + $favi = MainWP_DB::Instance()->getWebsiteOption( $site, 'favi_icon', '' ); | |
| 136 | + if ( !empty( $favi ) && ( false !== strpos( $favi, 'favi-' . $site->id . '-' ) ) ) { | |
| 137 | + $dirs = MainWP_Utility::getIconsDir(); | |
| 138 | + if ( file_exists( $dirs[0] . $favi ) ) { | |
| 139 | + unlink( $dirs[0] . $favi ); | |
| 140 | + } | |
| 141 | + } | |
| 142 | + | |
| 143 | + //Remove from DB | |
| 144 | + MainWP_DB::Instance()->removeWebsite( $site->id ); | |
| 145 | + do_action( 'mainwp_delete_site', $site ); | |
| 146 | + return array( 'result' => 'SUCCESS'); | |
| 147 | + } | |
| 389 | 148 | |
| 390 | - if ( $hasWPFileSystem ) { | |
| 391 | - $favi = MainWP_DB::instance()->get_website_option( $site, 'favi_icon', '' ); | |
| 392 | - if ( ! empty( $favi ) && ( false !== strpos( $favi, 'favi-' . $site->id . '-' ) ) ) { | |
| 393 | - $dirs = MainWP_System_Utility::get_icons_dir(); | |
| 394 | - if ( $wp_filesystem->exists( $dirs[0] . $favi ) ) { | |
| 395 | - $wp_filesystem->delete( $dirs[0] . $favi ); | |
| 396 | - } | |
| 397 | - } | |
| 398 | - } | |
| 149 | + /** | |
| 150 | + * Hook to clone site | |
| 151 | + * | |
| 152 | + * @since 3.4.4 | |
| 153 | + * @param $pluginFile, $key, $websiteid, $cloneid | |
| 154 | + * | |
| 155 | + * @return array | |
| 156 | + * | |
| 157 | + */ | |
| 158 | + public function filter_clone_site( $pluginFile, $key, $websiteid, $cloneid, $clone_url, $force_update = false ) { | |
| 159 | + return MainWP_Extensions::hookCloneSite( $pluginFile, $key, $websiteid, $cloneid, $clone_url, $force_update ); | |
| 160 | + } | |
| 399 | 161 | |
| 400 | - MainWP_DB::instance()->remove_website( $site->id ); | |
| 401 | 162 | |
| 402 | - /** This action is documented in pages\page-mainwp-manage-sites-handler.php */ | |
| 403 | - do_action( 'mainwp_delete_site', $site ); | |
| 404 | - return array( 'result' => 'SUCCESS' ); | |
| 405 | - } | |
| 163 | + public function filter_delete_clone_site( $pluginFile, $key, $clone_url = '', $clone_site_id = false) { | |
| 164 | + return MainWP_Extensions::hookDeleteCloneSite($pluginFile, $key, $clone_url, $clone_site_id ); | |
| 165 | + } | |
| 406 | 166 | |
| 407 | - /** | |
| 408 | - * Method filter_clone_site() | |
| 409 | - * | |
| 410 | - * Hook to clone site. | |
| 411 | - * | |
| 412 | - * @since 3.4.4 | |
| 413 | - * @param mixed $pluginFile Plugin file. | |
| 414 | - * @param mixed $key Key. | |
| 415 | - * @param mixed $websiteid Child site ID. | |
| 416 | - * @param mixed $cloneid Clone site ID. | |
| 417 | - * @param mixed $clone_url Clone site URL. | |
| 418 | - * @param bool $force_update Force the update, true|false, Default: false. | |
| 419 | - * | |
| 420 | - * @return array Site array to clone. | |
| 421 | - * | |
| 422 | - * @uses \MainWP\Dashboard\MainWP_Extensions_Handler::hook_clone_site() | |
| 423 | - */ | |
| 424 | - public function filter_clone_site( $pluginFile, $key, $websiteid, $cloneid, $clone_url, $force_update = false ) { | |
| 425 | - return MainWP_Extensions_Handler::hook_clone_site( $pluginFile, $key, $websiteid, $cloneid, $clone_url, $force_update ); | |
| 426 | - } | |
| 167 | + /** | |
| 168 | + * Hook to edit site | |
| 169 | + * | |
| 170 | + * @since 3.2.2 | |
| 171 | + * @param array $params site data fields: websiteid, name, wpadmin, unique_id | |
| 172 | + * | |
| 173 | + * @return array | |
| 174 | + * | |
| 175 | + */ | |
| 176 | + public function mainwp_edit_site( $params ) { | |
| 177 | + $ret = array(); | |
| 178 | + if ( is_array( $params ) ) { | |
| 179 | + if ( isset( $params[ 'websiteid' ] ) && MainWP_Utility::ctype_digit( $websiteid = $params[ 'websiteid' ] ) ) { | |
| 180 | + $ret[ 'siteid' ] = MainWP_Hooks::updateWPSite( $params ); | |
| 181 | + return $ret; | |
| 182 | + } | |
| 183 | + } | |
| 184 | + return $ret; | |
| 185 | + } | |
| 427 | 186 | |
| 428 | - /** | |
| 429 | - * Method filter_delete_clone_site() | |
| 430 | - * | |
| 431 | - * Hook to delete cloaned Child Site. | |
| 432 | - * | |
| 433 | - * @param mixed $pluginFile Plugin file. | |
| 434 | - * @param mixed $key Key. | |
| 435 | - * @param string $clone_url Clone site URL. | |
| 436 | - * @param bool $clone_site_id Clone site ID. | |
| 437 | - * | |
| 438 | - * @return array Site array to delete. | |
| 439 | - * | |
| 440 | - * @uses \MainWP\Dashboard\MainWP_Extensions_Handler::hook_delete_clone_site() | |
| 441 | - */ | |
| 442 | - public function filter_delete_clone_site( $pluginFile, $key, $clone_url = '', $clone_site_id = false ) { | |
| 443 | - return MainWP_Extensions_Handler::hook_delete_clone_site( $pluginFile, $key, $clone_url, $clone_site_id ); | |
| 444 | - } | |
| 187 | + public function hookAddSubLeftMenu( $title, $slug, $href, $level = 1, $parent_key = 'mainwp_tab' ) { | |
| 188 | + $item = array( | |
| 189 | + 'title' => $title, | |
| 190 | + 'parent_key' => $parent_key, | |
| 191 | + 'slug' => $slug, | |
| 192 | + 'href' => $href | |
| 193 | + ); | |
| 194 | + MainWP_Menu::add_left_menu( $item, $level ); | |
| 195 | + } | |
| 445 | 196 | |
| 446 | - /** | |
| 447 | - * Method mainwp_edit_site() | |
| 448 | - * | |
| 449 | - * Hook to edit Child Site. | |
| 450 | - * | |
| 451 | - * @param array $params site data fields: websiteid, name, wpadmin, unique_id. | |
| 452 | - * | |
| 453 | - * @return array $ret Child site ID. | |
| 454 | - * | |
| 455 | - * @throws \MainWP_Exception Exception message. | |
| 456 | - * | |
| 457 | - * @since 3.2.2 | |
| 458 | - * | |
| 459 | - * @uses \MainWP\Dashboard\MainWP_Manage_Sites_View::update_wp_site() | |
| 460 | - * @uses \MainWP\Dashboard\MainWP_Utility::ctype_digit() | |
| 461 | - */ | |
| 462 | - public function mainwp_edit_site( $params ) { | |
| 463 | - $ret = array(); | |
| 464 | - if ( is_array( $params ) && isset( $params['websiteid'] ) && MainWP_Utility::ctype_digit( $params['websiteid'] ) ) { | |
| 465 | - $ret['siteid'] = MainWP_Manage_Sites_View::update_wp_site( $params ); | |
| 466 | - return $ret; | |
| 467 | - } | |
| 468 | - return $ret; | |
| 469 | - } | |
| 197 | + public static function updateWPSite( $params ) { | |
| 198 | + if ( !isset( $params[ 'websiteid' ] ) || !MainWP_Utility::ctype_digit( $params[ 'websiteid' ] ) ) { | |
| 199 | + return 0; | |
| 200 | + } | |
| 470 | 201 | |
| 471 | - /** | |
| 472 | - * Method hook_add_sub_left_menu() | |
| 473 | - * | |
| 474 | - * Hook to add MainWP Left Menu item. | |
| 475 | - * | |
| 476 | - * @param string $title Menu title. | |
| 477 | - * @param string $slug Menu slug. | |
| 478 | - * @param string $href Menu link. | |
| 479 | - * @param integer $level Menu level. | |
| 480 | - * @param string $parent_key Parent menu. | |
| 481 | - * | |
| 482 | - * @uses \MainWP\Dashboard\MainWP_Menu::add_left_menu() | |
| 483 | - */ | |
| 484 | - public function hook_add_sub_left_menu( $title, $slug, $href, $level = 1, $parent_key = 'mainwp_tab' ) { | |
| 485 | - $item = array( | |
| 486 | - 'title' => $title, | |
| 487 | - 'parent_key' => $parent_key, | |
| 488 | - 'slug' => $slug, | |
| 489 | - 'href' => $href, | |
| 490 | - ); | |
| 491 | - MainWP_Menu::add_left_menu( $item, $level ); | |
| 492 | - } | |
| 493 | 202 | |
| 494 | - /** | |
| 495 | - * Method is_extension_activated() | |
| 496 | - * | |
| 497 | - * Check for inactive MainWP Extensions. | |
| 498 | - * | |
| 499 | - * @param mixed $input Input value. | |
| 500 | - * @param mixed $slug MainWP Extension to check. | |
| 501 | - * | |
| 502 | - * @return bool Activation notice. | |
| 503 | - */ | |
| 504 | - public function is_extension_activated( $input, $slug ) { | |
| 505 | - unset( $input ); | |
| 506 | - return MainWP_Extensions_Handler::is_extension_activated( $slug ); | |
| 507 | - } | |
| 203 | + if ( isset( $params['is_staging'] ) ) { | |
| 204 | + unset($params['is_staging']); // do not allow change this value | |
| 205 | + } | |
| 508 | 206 | |
| 207 | + $website = MainWP_DB::Instance()->getWebsiteById( $params[ 'websiteid' ] ); | |
| 208 | + if ( $website == null ) { | |
| 209 | + return 0; | |
| 210 | + } | |
| 509 | 211 | |
| 510 | - /** | |
| 511 | - * Method get_activate_extension_notice() | |
| 512 | - * | |
| 513 | - * Check for inactive MainWP Extensions & | |
| 514 | - * return an activation warning message. | |
| 515 | - * | |
| 516 | - * @param mixed $pluginFile MainWP Extension to check. | |
| 517 | - * | |
| 518 | - * @return string Activation notice. | |
| 519 | - * | |
| 520 | - * @uses \MainWP\Dashboard\MainWP_Extensions_Handler::is_extension_activated() | |
| 521 | - */ | |
| 522 | - public function get_activate_extension_notice( $pluginFile ) { | |
| 523 | - $active = MainWP_Extensions_Handler::is_extension_activated( $pluginFile ); | |
| 524 | - if ( $active ) { | |
| 525 | - return false; | |
| 526 | - } | |
| 212 | + if ( !MainWP_Utility::can_edit_website( $website ) ) { | |
| 213 | + return 0; | |
| 214 | + } | |
| 527 | 215 | |
| 528 | - $activate_notices = get_user_option( 'mainwp_hide_activate_notices' ); | |
| 529 | - if ( is_array( $activate_notices ) ) { | |
| 530 | - $slug = basename( $pluginFile, '.php' ); | |
| 531 | - if ( isset( $activate_notices[ $slug ] ) ) { | |
| 532 | - return false; | |
| 533 | - } | |
| 534 | - } | |
| 216 | + $data = array(); | |
| 535 | 217 | |
| 536 | - return sprintf( esc_html__( 'You have a MainWP extension that does not have an active API entered. This means you will not receive updates or support. Please visit the %1$sExtensions%2$s page and enter your API key.', 'mainwp' ), '<a href="admin.php?page=Extensions">', '</a>' ); | |
| 537 | - } | |
| 218 | + $uniqueId = null; | |
| 538 | 219 | |
| 539 | - /** | |
| 540 | - * Method cache_getcontext() | |
| 541 | - * | |
| 542 | - * Get cached search context for given page. | |
| 543 | - * | |
| 544 | - * @param string $page Current MainWP Page. | |
| 545 | - * | |
| 546 | - * @return array Cached Search Array. | |
| 547 | - */ | |
| 548 | - public function cache_getcontext( $page ) { | |
| 549 | - return MainWP_Cache::get_cached_context( $page ); | |
| 550 | - } | |
| 220 | + if ( isset( $params[ 'name' ] ) && !empty( $params[ 'name' ] ) ) { | |
| 221 | + $data[ 'name' ] = htmlentities( $params[ 'name' ] ); | |
| 222 | + } | |
| 551 | 223 | |
| 552 | - /** | |
| 553 | - * Method cache_echo_body() | |
| 554 | - * | |
| 555 | - * Echo Cached Search Body. | |
| 556 | - * | |
| 557 | - * @param string $page Current MainWP Page. | |
| 558 | - */ | |
| 559 | - public function cache_echo_body( $page ) { | |
| 560 | - MainWP_Cache::echo_body( $page ); | |
| 561 | - } | |
| 224 | + if ( isset( $params[ 'wpadmin' ] ) && !empty( $params[ 'wpadmin' ] ) ) { | |
| 225 | + $data[ 'adminname' ] = $params[ 'wpadmin' ]; | |
| 226 | + } | |
| 562 | 227 | |
| 563 | - /** | |
| 564 | - * Method cache_init() | |
| 565 | - * | |
| 566 | - * Initiate search session variables for the current page. | |
| 567 | - * | |
| 568 | - * @param string $page Current MainWP Page. | |
| 569 | - */ | |
| 570 | - public function cache_init( $page ) { | |
| 571 | - MainWP_Cache::init_cache( $page ); | |
| 572 | - } | |
| 228 | + if ( isset( $params[ 'unique_id' ] ) ) { | |
| 229 | + $data[ 'uniqueId' ] = $uniqueId = $params[ 'unique_id' ]; | |
| 230 | + } | |
| 573 | 231 | |
| 574 | - /** | |
| 575 | - * Method cache_add_context() | |
| 576 | - * | |
| 577 | - * Hook to add time & Search Context session variable. | |
| 578 | - * | |
| 579 | - * @param string $page Current MainWP Page. | |
| 580 | - * @param mixed $context Time of search. | |
| 581 | - */ | |
| 582 | - public function cache_add_context( $page, $context ) { | |
| 583 | - MainWP_Cache::add_context( $page, $context ); | |
| 584 | - } | |
| 232 | + if ( empty( $data ) ) { | |
| 233 | + return 0; | |
| 234 | + } | |
| 585 | 235 | |
| 586 | - /** | |
| 587 | - * Method cache_add_body() | |
| 588 | - * | |
| 589 | - * Hook to add Search Body Session variable. | |
| 590 | - * | |
| 591 | - * @param string $page Current MainWP Page. | |
| 592 | - * @param mixed $body Search body. | |
| 593 | - */ | |
| 594 | - public function cache_add_body( $page, $body ) { | |
| 595 | - MainWP_Cache::add_body( $page, $body ); | |
| 596 | - } | |
| 236 | + MainWP_DB::Instance()->updateWebsiteValues( $website->id, $data ); | |
| 237 | + if ( null !== $uniqueId ) { | |
| 238 | + try { | |
| 239 | + $information = MainWP_Utility::fetchUrlAuthed( $website, 'update_values', array( 'uniqueId' => $uniqueId ) ); | |
| 240 | + } catch ( MainWP_Exception $e ) { | |
| 241 | + $error = $e->getMessage(); | |
| 242 | + } | |
| 243 | + } | |
| 244 | + do_action('mainwp_updated_site', $website->id, $data); | |
| 245 | + return $website->id; | |
| 246 | + } | |
| 597 | 247 | |
| 598 | - /** | |
| 599 | - * Method hook_select_sites_box() | |
| 600 | - * | |
| 601 | - * Hook to select sites box. | |
| 602 | - * | |
| 603 | - * @param string $title Input title. | |
| 604 | - * @param string $type Input type, radio. | |
| 605 | - * @param bool $show_group Whether or not to show group, Default: true. | |
| 606 | - * @param bool $show_select_all Whether to show select all. | |
| 607 | - * @param string $class_style Default = ''. | |
| 608 | - * @param string $style Default = ''. | |
| 609 | - * @param array $selected_websites Selected Child Sites. | |
| 610 | - * @param array $selected_groups Selected Groups. | |
| 611 | - * @param bool $show_client Show Clients. | |
| 612 | - * @param array $selected_clients Selected Clients. | |
| 613 | - * @param mixed $post_id post ID. | |
| 614 | - * @param bool $show_create_tag Show create tag button. | |
| 615 | - */ | |
| 616 | - public function hook_select_sites_box( $title = '', $type = 'checkbox', $show_group = true, $show_select_all = true, $class_style = '', $style = '', $selected_websites = array(), $selected_groups = array(), $show_client = false, $selected_clients = array(), $post_id = false, $show_create_tag = true ) { //phpcs:ignore -- NOSONAR - compatible. | |
| 617 | - unset( $title ); | |
| 618 | - $sel_params = array( | |
| 619 | - 'type' => $type, | |
| 620 | - 'show_group' => $show_group, | |
| 621 | - 'show_select_all' => $show_select_all, | |
| 622 | - 'class' => $class_style, | |
| 623 | - 'style' => $style, | |
| 624 | - 'selected_sites' => $selected_websites, | |
| 625 | - 'selected_groups' => $selected_groups, | |
| 626 | - 'show_client' => $show_client, | |
| 627 | - 'selected_clients' => $selected_clients, | |
| 628 | - 'post_id' => $post_id, | |
| 629 | - 'show_create_tag' => $show_create_tag, | |
| 630 | - ); | |
| 631 | - MainWP_UI_Select_Sites::select_sites_box( $sel_params ); | |
| 632 | - } | |
| 248 | + public function get_activate_extension_notice( $pluginFile ) { | |
| 249 | + $active = MainWP_Extensions::isExtensionActivated( $pluginFile ); | |
| 250 | + if ( $active ) | |
| 251 | + return false; | |
| 633 | 252 | |
| 634 | - /** | |
| 635 | - * Method hook_add_categories_box() | |
| 636 | - * | |
| 637 | - * General categories box. | |
| 638 | - * | |
| 639 | - * @param int $post_id Post ID. | |
| 640 | - */ | |
| 641 | - public function hook_add_categories_box( $post_id = false ) { | |
| 642 | - MainWP_System::instance()->metaboxes->add_categories( $post_id ); | |
| 643 | - } | |
| 644 | 253 | |
| 645 | - /** | |
| 646 | - * Method hook_notify_user() | |
| 647 | - * | |
| 648 | - * Hook to send user a notification. | |
| 649 | - * | |
| 650 | - * @param int $userId User ID. | |
| 651 | - * @param string $subject Email Subject. | |
| 652 | - * @param string $content Email Content. | |
| 653 | - * | |
| 654 | - * @uses \MainWP\Dashboard\MainWP_Notification::send_notify_user() | |
| 655 | - */ | |
| 656 | - public function hook_notify_user( $userId, $subject, $content ) { | |
| 657 | - MainWP_Notification::send_notify_user( $userId, $subject, $content ); | |
| 658 | - } | |
| 254 | + $activate_notices = get_user_option( 'mainwp_hide_activate_notices' ); | |
| 255 | + if ( is_array( $activate_notices ) ) { | |
| 256 | + $slug = basename( $pluginFile, ".php" ); | |
| 257 | + if ( isset( $activate_notices[ $slug ] ) ) { | |
| 258 | + return false; // hide it | |
| 259 | + } | |
| 260 | + } | |
| 659 | 261 | |
| 660 | - /** | |
| 661 | - * Method get_error_message() | |
| 662 | - * | |
| 663 | - * Hook to get error message. | |
| 664 | - * | |
| 665 | - * @param object $msg Error message. | |
| 666 | - * @param object $extra HTTP error message. | |
| 667 | - * | |
| 668 | - * @return string Error message. | |
| 669 | - * | |
| 670 | - * @uses \MainWP\Dashboard\MainWP_Error_Helper::get_error_message() | |
| 671 | - */ | |
| 672 | - public function get_error_message( $msg, $extra ) { | |
| 673 | - return MainWP_Error_Helper::get_error_message( new MainWP_Exception( $msg, $extra ) ); | |
| 674 | - } | |
| 262 | + return sprintf( __( "You have a MainWP extension that does not have an active API entered. This means you will not receive updates or support. Please visit the %sExtensions%s page and enter your API key.", 'mainwp' ), '<a href="admin.php?page=Extensions">', '</a>' ); | |
| 263 | + } | |
| 675 | 264 | |
| 676 | - /** | |
| 677 | - * Method hook_get_user_extension() | |
| 678 | - * | |
| 679 | - * Hook to get user extension. | |
| 680 | - * | |
| 681 | - * @return object $row User extension. | |
| 682 | - */ | |
| 683 | - public function hook_get_user_extension() { | |
| 684 | - return MainWP_DB_Common::instance()->get_user_extension(); | |
| 685 | - } | |
| 265 | + public function cache_getcontext( $page ) { | |
| 266 | + return MainWP_Cache::getCachedContext( $page ); | |
| 267 | + } | |
| 686 | 268 | |
| 687 | - /** | |
| 688 | - * Method update_user_extension() | |
| 689 | - * | |
| 690 | - * Hook to update user extension. | |
| 691 | - * | |
| 692 | - * @param bool $input_value input filter value. | |
| 693 | - * @param string $option_name option name. | |
| 694 | - * @param mixed $option_value option value. | |
| 695 | - * | |
| 696 | - * @return bool true. | |
| 697 | - */ | |
| 698 | - public function update_user_extension( $input_value, $option_name, $option_value ) { | |
| 699 | - unset( $input_value ); | |
| 700 | - $userExtension = MainWP_DB_Common::instance()->get_user_extension(); | |
| 701 | - $userExtension->{$option_name} = wp_json_encode( $option_value ); | |
| 702 | - MainWP_DB_Common::instance()->update_user_extension( $userExtension ); | |
| 703 | - return true; | |
| 704 | - } | |
| 269 | + public function cache_echo_body( $page ) { | |
| 270 | + MainWP_Cache::echoBody( $page ); | |
| 271 | + } | |
| 705 | 272 | |
| 706 | - /** | |
| 707 | - * Method hook_get_site_options() | |
| 708 | - * | |
| 709 | - * Hook to get Child site options. | |
| 710 | - * | |
| 711 | - * @param mixed $boolean Boolean check. | |
| 712 | - * @param object $website Child site object. | |
| 713 | - * @param string|array $options Option table name. | |
| 714 | - * | |
| 715 | - * @return string|null Database query result (as string), or null on failure | |
| 716 | - */ | |
| 717 | - public function hook_get_site_options( $boolean, $website, $options = '' ) { | |
| 273 | + public function cache_init( $page ) { | |
| 274 | + MainWP_Cache::initCache( $page ); | |
| 275 | + } | |
| 718 | 276 | |
| 719 | - if ( empty( $options ) ) { | |
| 720 | - return $boolean; | |
| 721 | - } | |
| 277 | + public function cache_add_context( $page, $context ) { | |
| 278 | + MainWP_Cache::addContext( $page, $context ); | |
| 279 | + } | |
| 722 | 280 | |
| 723 | - if ( is_string( $options ) ) { | |
| 724 | - return MainWP_DB::instance()->get_website_option( $website, $options ); | |
| 725 | - } elseif ( is_array( $options ) ) { | |
| 726 | - return MainWP_DB::instance()->get_website_options_array( $website, $options ); | |
| 727 | - } | |
| 728 | - return $boolean; | |
| 729 | - } | |
| 281 | + public function cache_add_body( $page, $body ) { | |
| 282 | + MainWP_Cache::addBody( $page, $body ); | |
| 283 | + } | |
| 730 | 284 | |
| 731 | - /** | |
| 732 | - * Method hook_update_site_options() | |
| 733 | - * | |
| 734 | - * Hook to get Child site options. | |
| 735 | - * | |
| 736 | - * @param mixed $boolean Boolean check. | |
| 737 | - * @param object $website Child site object. | |
| 738 | - * @param string $option Option name. | |
| 739 | - * @param string $value Option value. | |
| 740 | - * | |
| 741 | - * @return string|null Database query result (as string), or null on failure | |
| 742 | - */ | |
| 743 | - public function hook_update_site_options( $boolean, $website, $option, $value ) { | |
| 744 | - unset( $boolean ); | |
| 285 | + public function select_sites_box( $title = '', $type = 'checkbox', $show_group = true, $show_select_all = true, | |
| 286 | + $class = '', $style = '', $selected_websites = array(), $selected_groups = array() ) { | |
| 287 | + MainWP_UI::select_sites_box( $type, $show_group, $show_select_all, $class, $style, $selected_websites, $selected_groups ); | |
| 288 | + } | |
| 745 | 289 | |
| 746 | - if ( is_numeric( $website ) ) { | |
| 747 | - $obj = new \stdClass(); | |
| 748 | - $obj->id = intval( $website ); | |
| 749 | - $website = $obj; | |
| 750 | - } elseif ( ! is_object( $website ) || ! property_exists( $website, 'id' ) ) { | |
| 751 | - return false; | |
| 752 | - } | |
| 753 | - return MainWP_DB::instance()->update_website_option( $website, $option, $value ); | |
| 754 | - } | |
| 290 | + public function notifyUser( $userId, $subject, $content ) { | |
| 291 | + wp_mail( MainWP_DB::Instance()->getUserNotificationEmail( $userId ), $subject, $content, array( | |
| 292 | + 'From: "' . get_option( 'admin_email' ) . '" <' . get_option( 'admin_email' ) . '>', | |
| 293 | + 'content-type: text/html', | |
| 294 | + ) ); | |
| 295 | + } | |
| 755 | 296 | |
| 756 | - /** | |
| 757 | - * Get sites by user ID. | |
| 758 | - * | |
| 759 | - * @param mixed $boolean Boolean check. | |
| 760 | - * @param int $userid User ID. | |
| 761 | - * @param bool $selectgroups Selected groups. | |
| 762 | - * @param null $search_site Site search field value. | |
| 763 | - * @param string $orderBy Order list by. Default: URL. | |
| 764 | - * | |
| 765 | - * @return object|null Database query results or null on failure. | |
| 766 | - */ | |
| 767 | - public function hook_get_websites_by_user_id( $boolean, $userid, $selectgroups = false, $search_site = null, $orderBy = 'wp.url' ) { | |
| 768 | - unset( $boolean ); | |
| 769 | - return MainWP_DB::instance()->get_websites_by_user_id( $userid, $selectgroups, $search_site, $orderBy ); | |
| 770 | - } | |
| 297 | + public function getErrorMessage( $msg, $extra ) { | |
| 298 | + return MainWP_Error_Helper::getErrorMessage( new MainWP_Exception( $msg, $extra ) ); | |
| 299 | + } | |
| 771 | 300 | |
| 772 | - /** | |
| 773 | - * Get sites by website ID. | |
| 774 | - * | |
| 775 | - * @param mixed $boolean Boolean check. | |
| 776 | - * @param int $website_id User ID. | |
| 777 | - * @param bool $selectGroups Select groups. | |
| 778 | - * @param array $extra_view get extra option fields. | |
| 779 | - * | |
| 780 | - * @return object|null Database query results or null on failure. | |
| 781 | - */ | |
| 782 | - public function hook_get_website_by_id( $boolean, $website_id, $selectGroups = false, $extra_view = array() ) { | |
| 783 | - unset( $boolean ); | |
| 784 | - if ( empty( $website_id ) ) { | |
| 785 | - return false; | |
| 786 | - } | |
| 301 | + public function getUserExtension() { | |
| 302 | + return MainWP_DB::Instance()->getUserExtension(); | |
| 303 | + } | |
| 787 | 304 | |
| 788 | - $website = MainWP_DB::instance()->get_website_by_id( $website_id, $selectGroups, $extra_view ); | |
| 305 | + public function getWebsiteOptions( $boolean, $website, $name = '' ) { | |
| 789 | 306 | |
| 790 | - if ( ! empty( $website ) && property_exists( $website, 'privkey' ) ) { | |
| 791 | - unset( $website->privkey ); | |
| 792 | - } | |
| 307 | + if ( empty( $name ) ) | |
| 308 | + return $boolean; | |
| 793 | 309 | |
| 794 | - return $website; | |
| 795 | - } | |
| 310 | + if ( is_numeric( $website ) ) { | |
| 311 | + $obj = new stdClass(); | |
| 312 | + $obj->id = $website; | |
| 313 | + $website = $obj; | |
| 314 | + } | |
| 796 | 315 | |
| 316 | + return MainWP_DB::Instance()->getWebsiteOption( $website, $name ); | |
| 317 | + } | |
| 797 | 318 | |
| 798 | - /** | |
| 799 | - * Method get_websites_by_url() | |
| 800 | - * | |
| 801 | - * Hook to get Child Site by URL. | |
| 802 | - * | |
| 803 | - * @param string $url Child Site URL. | |
| 804 | - * | |
| 805 | - * @return array|object|null Database query results. | |
| 806 | - */ | |
| 807 | - public function get_websites_by_url( $url ) { | |
| 808 | - return MainWP_DB::instance()->get_websites_by_url( $url ); | |
| 809 | - } | |
| 319 | + public function getWebsitesByUrl( $url ) { | |
| 320 | + return MainWP_DB::Instance()->getWebsitesByUrl( $url ); | |
| 321 | + } | |
| 810 | 322 | |
| 811 | - /** | |
| 812 | - * Method hook_get_all_posts() | |
| 813 | - * Hook to get posts from sites. | |
| 814 | - * | |
| 815 | - * @param object $sites Child Sites object. | |
| 816 | - * @param array $post_data with values: keyword, dtsstart, dtsstop, status, maxRecords, post_type. | |
| 817 | - * | |
| 818 | - * @return \stdClass $output All posts data array. | |
| 819 | - * | |
| 820 | - * @since 3.4.4 | |
| 821 | - * | |
| 822 | - * @uses \MainWP\Dashboard\MainWP_Post::get_class_name() | |
| 823 | - * @uses \MainWP\Dashboard\MainWP_Utility::ctype_digit() | |
| 824 | - * @uses \MainWP\Dashboard\MainWP_Utility::map_site() | |
| 825 | - */ | |
| 826 | - public function hook_get_all_posts( $sites, $post_data = array() ) { | |
| 323 | + /** | |
| 324 | + * Hook to get posts from sites | |
| 325 | + * | |
| 326 | + * @since 3.4.4 | |
| 327 | + * @param $pluginFile, $key, $sites, $post_data | |
| 328 | + * @param array $post_data with values: keyword, dtsstart, dtsstop, status, maxRecords, post_type | |
| 329 | + * @return array | |
| 330 | + * | |
| 331 | + */ | |
| 332 | + public function hookGetAllPosts( $sites, $post_data = array() ) { | |
| 827 | 333 | |
| 828 | - $dbwebsites = array(); | |
| 334 | + $dbwebsites = array(); | |
| 335 | + $data = array( 'id', 'url', 'name', 'adminname', 'nossl', 'privkey', 'nosslkey', 'verify_certificate', 'ssl_version', 'http_user', 'http_pass' ); | |
| 829 | 336 | |
| 830 | - $data = MainWP_System_Utility::get_default_map_site_fields(); | |
| 831 | - $data[] = 'verify_certificate'; | |
| 337 | + if ( $sites != '' ) { | |
| 338 | + foreach ( $sites as $k => $v ) { | |
| 339 | + if ( MainWP_Utility::ctype_digit( $v ) ) { | |
| 340 | + $website = MainWP_DB::Instance()->getWebsiteById( $v ); | |
| 341 | + $dbwebsites[ $website->id ] = MainWP_Utility::mapSite( $website, $data ); | |
| 342 | + } | |
| 343 | + } | |
| 344 | + } | |
| 832 | 345 | |
| 833 | - if ( '' !== $sites ) { | |
| 834 | - foreach ( $sites as $v ) { | |
| 835 | - if ( MainWP_Utility::ctype_digit( $v ) ) { | |
| 836 | - $website = MainWP_DB::instance()->get_website_by_id( $v ); | |
| 837 | - if ( empty( $website->sync_errors ) && ! MainWP_System_Utility::is_suspended_site( $website ) ) { | |
| 838 | - $dbwebsites[ $website->id ] = MainWP_Utility::map_site( $website, $data ); | |
| 839 | - } | |
| 840 | - } | |
| 841 | - } | |
| 842 | - } | |
| 346 | + $default_data = array( | |
| 347 | + 'post_type' => 'post', | |
| 348 | + 'status' => 'publish', | |
| 349 | + 'maxRecords' => 10 | |
| 350 | + ); | |
| 843 | 351 | |
| 844 | - $default_data = array( | |
| 845 | - 'post_type' => 'post', | |
| 846 | - 'status' => 'publish', | |
| 847 | - 'maxRecords' => 10, | |
| 848 | - ); | |
| 352 | + $post_data = array_merge( $default_data, $post_data ); | |
| 849 | 353 | |
| 850 | - $post_data = array_merge( $default_data, $post_data ); | |
| 354 | + $output = new stdClass(); | |
| 355 | + $output->results = array(); | |
| 356 | + if ( $dbwebsites ) { | |
| 357 | + MainWP_Utility::fetchUrlsAuthed( $dbwebsites, 'get_all_posts', $post_data, array( | |
| 358 | + MainWP_Post::getClassName(), | |
| 359 | + 'hookPostsSearch_handler', | |
| 360 | + ), $output ); | |
| 361 | + } | |
| 362 | + return $output; | |
| 363 | + } | |
| 851 | 364 | |
| 852 | - $output = new \stdClass(); | |
| 853 | - $output->results = array(); | |
| 854 | - if ( $dbwebsites ) { | |
| 855 | - MainWP_Connect::fetch_urls_authed( | |
| 856 | - $dbwebsites, | |
| 857 | - 'get_all_posts', | |
| 858 | - $post_data, | |
| 859 | - array( | |
| 860 | - MainWP_Post::get_class_name(), | |
| 861 | - 'hook_posts_search_handler', | |
| 862 | - ), | |
| 863 | - $output | |
| 864 | - ); | |
| 865 | - } | |
| 866 | - return $output; | |
| 867 | - } | |
| 868 | 365 | |
| 869 | - /** | |
| 870 | - * Method mainwp_current_user_have_right() | |
| 871 | - * | |
| 872 | - * Check permission level by hook mainwp_currentusercan of Team Control extension | |
| 873 | - * | |
| 874 | - * @param mixed $input Return value holder. | |
| 875 | - * @param string $can_type group or type of capabilities. | |
| 876 | - * @param string $which Which function to perform. | |
| 877 | - * | |
| 878 | - * @return bool $input Return true if the user can and false if they can not. | |
| 879 | - */ | |
| 880 | - public function hook_current_user_can( $input, $can_type, $which ) { | |
| 366 | + public function get_mainwp_dir( $false = false, $dir = null, $direct_access = false) { | |
| 881 | 367 | |
| 882 | - if ( function_exists( 'mainwp_current_user_have_right' ) ) { | |
| 883 | - return mainwp_current_user_have_right( $can_type, $which ); | |
| 884 | - } | |
| 368 | + $dirs = MainWP_Utility::getMainWPDir(); | |
| 885 | 369 | |
| 886 | - return $input; | |
| 887 | - } | |
| 370 | + $newdir = $dirs[0] . ( $dir != null ? $dir . DIRECTORY_SEPARATOR : '' ); | |
| 371 | + $url = $dirs[1] . '/' . $dir . '/'; | |
| 888 | 372 | |
| 889 | - /** | |
| 890 | - * Method hook_escape_response() | |
| 891 | - * | |
| 892 | - * To escape response data. | |
| 893 | - * | |
| 894 | - * @param mixed $response response data. | |
| 895 | - * @param bool $fields fields of response data - option. | |
| 896 | - * @param array $more_allowed input allowed tags - option. | |
| 897 | - * | |
| 898 | - * @return mixed $response valid response data. | |
| 899 | - * @throws \MainWP_Exception Exception message. | |
| 900 | - * | |
| 901 | - * @uses \MainWP\Dashboard\MainWP_Utility::esc_content() | |
| 902 | - * @uses \MainWP\Dashboard\MainWP_Utility::esc_mixed_content() | |
| 903 | - */ | |
| 904 | - public function hook_escape_response( $response, $fields = false, $more_allowed = array() ) { | |
| 905 | - | |
| 906 | - if ( false === $fields || is_string( $response ) ) { | |
| 907 | - return MainWP_Utility::esc_content( $response ); | |
| 908 | - } | |
| 909 | - | |
| 910 | - if ( ! is_array( $fields ) ) { | |
| 911 | - return $response; | |
| 912 | - } | |
| 913 | - | |
| 914 | - if ( ! in_array( 'error', $fields ) ) { | |
| 915 | - $fields[] = 'error'; // to sure to valid 'error' field, if that existed. | |
| 916 | - } | |
| 917 | - | |
| 918 | - if ( ! in_array( 'message', $fields ) ) { | |
| 919 | - $fields[] = 'message'; // to sure to valid 'message' field, if that existed. | |
| 920 | - } | |
| 921 | - | |
| 922 | - $depth = 10; | |
| 923 | - | |
| 924 | - foreach ( $fields as $field ) { | |
| 925 | - if ( isset( $response[ $field ] ) ) { | |
| 926 | - $response[ $field ] = MainWP_Utility::esc_mixed_content( $response[ $field ], $depth, $more_allowed ); | |
| 373 | + if ($dir != null) { | |
| 374 | + if ( ! file_exists( $newdir ) ) { | |
| 375 | + @mkdir( $newdir, 0777, true ); | |
| 927 | 376 | } |
| 928 | - } | |
| 929 | - return $response; | |
| 930 | - } | |
| 931 | - | |
| 932 | - /** | |
| 933 | - * Method hook_escape_content() | |
| 934 | - * | |
| 935 | - * To escape content. | |
| 936 | - * | |
| 937 | - * @param mixed $content response data. | |
| 938 | - * @param string $type content type for escape. | |
| 939 | - * @param array $more_allowed input allowed tags - option. | |
| 940 | - * | |
| 941 | - * @return mixed $response valid response data. | |
| 942 | - * @throws \MainWP_Exception Exception message. | |
| 943 | - * | |
| 944 | - * @uses \MainWP\Dashboard\MainWP_Utility::esc_content() | |
| 945 | - */ | |
| 946 | - public function hook_escape_content( $content, $type = 'note', $more_allowed = array() ) { | |
| 947 | - return MainWP_Utility::esc_content( $content, $type, $more_allowed ); | |
| 948 | - } | |
| 949 | - | |
| 950 | - | |
| 951 | - /** | |
| 952 | - * Method db_free_result() | |
| 953 | - * | |
| 954 | - * To escape response data. | |
| 955 | - * | |
| 956 | - * @param mixed $input_value input value. | |
| 957 | - * @param mixed $result result data. | |
| 958 | - * | |
| 959 | - * @return bool true. | |
| 960 | - */ | |
| 961 | - public function db_free_result( $input_value, $result ) { | |
| 962 | - unset( $input_value ); | |
| 963 | - MainWP_DB::free_result( $result ); | |
| 964 | - return true; | |
| 965 | - } | |
| 966 | - | |
| 967 | - /** | |
| 968 | - * Method db_num_rows() | |
| 969 | - * | |
| 970 | - * To escape response data. | |
| 971 | - * | |
| 972 | - * @param mixed $input_value input value. | |
| 973 | - * @param mixed $result result data. | |
| 974 | - * | |
| 975 | - * @return bool true. | |
| 976 | - */ | |
| 977 | - public function db_num_rows( $input_value, $result ) { | |
| 978 | - unset( $input_value ); | |
| 979 | - return MainWP_DB::num_rows( $result ); | |
| 980 | - } | |
| 981 | - | |
| 982 | - | |
| 983 | - /** | |
| 984 | - * Method db_get_websites_for_current_user() | |
| 985 | - * | |
| 986 | - * To escape response data. | |
| 987 | - * | |
| 988 | - * @param mixed $input_value input value. | |
| 989 | - * @param array $params params data. | |
| 990 | - * | |
| 991 | - * @return mixed websites. | |
| 992 | - */ | |
| 993 | - public function db_get_websites_for_current_user( $input_value = false, $params = array() ) { | |
| 994 | - unset( $input_value ); | |
| 995 | - if ( ! is_array( $params ) ) { | |
| 996 | - $params = array(); | |
| 997 | - } | |
| 998 | - | |
| 999 | - $orderBy = isset( $params['orderby'] ) ? MainWP_DB::instance()->escape( $params['orderby'] ) : 'wp.url'; | |
| 1000 | - $extra_view = isset( $params['extra_view'] ) ? $params['extra_view'] : array( 'favi_icon' ); | |
| 1001 | - | |
| 1002 | - if ( ! is_array( $extra_view ) ) { | |
| 1003 | - $extra_view = array( 'favi_icon' ); | |
| 1004 | - } | |
| 1005 | - return MainWP_DB::instance()->query( MainWP_DB::instance()->get_sql_websites_for_current_user( false, null, $orderBy, false, false, null, false, $extra_view ) ); | |
| 1006 | - } | |
| 1007 | - | |
| 1008 | - | |
| 1009 | - /** | |
| 1010 | - * Method hook_sync_website() | |
| 1011 | - * | |
| 1012 | - * To escape response data. | |
| 1013 | - * | |
| 1014 | - * @param mixed $input_value input value. | |
| 1015 | - * @param int $website_id Website ID. | |
| 1016 | - * @param bool $fire_end_session to run the ending session or not. | |
| 1017 | - * | |
| 1018 | - * @return mixed websites. | |
| 1019 | - */ | |
| 1020 | - public function hook_sync_website( $input_value, $website_id, $fire_end_session = true ) { | |
| 1021 | - if ( empty( $website_id ) ) { | |
| 1022 | - return $input_value; | |
| 1023 | - } | |
| 1024 | - $website = MainWP_DB::instance()->get_website_by_id( $website_id ); | |
| 1025 | - if ( empty( $website ) ) { | |
| 1026 | - return $input_value; | |
| 1027 | - } | |
| 1028 | - return MainWP_Sync::sync_website( $website, $fire_end_session ); | |
| 1029 | - } | |
| 1030 | - | |
| 1031 | - | |
| 1032 | - /** | |
| 1033 | - * Method hook_db_data_seek() | |
| 1034 | - * | |
| 1035 | - * To escape response data. | |
| 1036 | - * | |
| 1037 | - * @param mixed $result result data. | |
| 1038 | - * @param int $offset offset of data. | |
| 1039 | - */ | |
| 1040 | - public function hook_db_data_seek( $result, $offset = 0 ) { | |
| 1041 | - MainWP_DB::data_seek( $result, $offset ); | |
| 1042 | - } | |
| 1043 | - | |
| 1044 | - | |
| 1045 | - /** | |
| 1046 | - * Method hook_db_query() | |
| 1047 | - * | |
| 1048 | - * To query db. | |
| 1049 | - * | |
| 1050 | - * @param mixed $input_value filter input value. | |
| 1051 | - * @param string $sql result data. | |
| 1052 | - * | |
| 1053 | - * @return bool true. | |
| 1054 | - */ | |
| 1055 | - public function hook_db_query( $input_value, $sql ) { | |
| 1056 | - unset( $input_value ); | |
| 1057 | - return MainWP_DB::instance()->query( $sql ); | |
| 1058 | - } | |
| 1059 | - | |
| 1060 | - /** | |
| 1061 | - * Method db_fetch_object() | |
| 1062 | - * | |
| 1063 | - * To escape response data. | |
| 1064 | - * | |
| 1065 | - * @param mixed $input_value input value. | |
| 1066 | - * @param mixed $result result data. | |
| 1067 | - * | |
| 1068 | - * @return bool true. | |
| 1069 | - */ | |
| 1070 | - public function db_fetch_object( $input_value, $result ) { | |
| 1071 | - unset( $input_value ); | |
| 1072 | - return MainWP_DB::fetch_object( $result ); | |
| 1073 | - } | |
| 1074 | - | |
| 1075 | - | |
| 1076 | - /** | |
| 1077 | - * Method db_fetch_array() | |
| 1078 | - * | |
| 1079 | - * To escape response data. | |
| 1080 | - * | |
| 1081 | - * @param mixed $input_value input value. | |
| 1082 | - * @param mixed $result result data. | |
| 1083 | - * | |
| 1084 | - * @return bool true. | |
| 1085 | - */ | |
| 1086 | - public function db_fetch_array( $input_value, $result ) { | |
| 1087 | - unset( $input_value ); | |
| 1088 | - return MainWP_DB::fetch_array( $result ); | |
| 1089 | - } | |
| 1090 | - | |
| 1091 | - | |
| 1092 | - /** | |
| 1093 | - * Get notification email settings. | |
| 1094 | - * | |
| 1095 | - * @param string $settings hook settings input value. | |
| 1096 | - * @param string $type Notification type. | |
| 1097 | - * | |
| 1098 | - * @return array $gen_email_settings email settings. | |
| 1099 | - */ | |
| 1100 | - public function get_notification_settings( $settings, $type ) { | |
| 1101 | - unset( $settings ); | |
| 1102 | - return MainWP_Notification_Settings::get_general_email_settings( $type ); | |
| 1103 | - } | |
| 1104 | - | |
| 1105 | - /** | |
| 1106 | - * Hook send_wp_mail(). | |
| 1107 | - * | |
| 1108 | - * Send email via wp_mail(). | |
| 1109 | - * | |
| 1110 | - * @param string $input hook input value. | |
| 1111 | - * @param string $email send to email. | |
| 1112 | - * @param string $subject email content. | |
| 1113 | - * @param bool $formated_content email content. | |
| 1114 | - * @param string $content_type Text format. | |
| 1115 | - */ | |
| 1116 | - public function hook_send_wp_mail( $input, $email, $subject, $formated_content, $content_type = '' ) { | |
| 1117 | - unset( $input ); | |
| 1118 | - return MainWP_Notification::send_wp_mail( | |
| 1119 | - $email, | |
| 1120 | - $subject, | |
| 1121 | - $formated_content, | |
| 1122 | - $content_type | |
| 1123 | - ); | |
| 1124 | - } | |
| 1125 | - | |
| 1126 | - /** | |
| 1127 | - * Hook get template HTML content. | |
| 1128 | - * | |
| 1129 | - * @param string $input hooks input value. | |
| 1130 | - * @param string $template_name Template name. | |
| 1131 | - * @param array $args Arguments. (default: array). | |
| 1132 | - * | |
| 1133 | - * @return string | |
| 1134 | - */ | |
| 1135 | - public function hook_get_template_html( $input, $template_name, $args = array() ) { | |
| 1136 | - unset( $input ); | |
| 1137 | - return MainWP_Notification_Template::instance()->get_template_html( | |
| 1138 | - $template_name, | |
| 1139 | - $args | |
| 1140 | - ); | |
| 1141 | - } | |
| 1142 | - | |
| 1143 | - /** | |
| 1144 | - * Method hook_secure_request() | |
| 1145 | - * | |
| 1146 | - * Security check to request parameter | |
| 1147 | - * | |
| 1148 | - * @param string $action Action to perform. | |
| 1149 | - * @param string $query_arg Query argument. | |
| 1150 | - * | |
| 1151 | - * @uses \MainWP\Dashboard\MainWP_Post_Handler::secure_request() | |
| 1152 | - */ | |
| 1153 | - public function hook_secure_request( $action = '', $query_arg = 'security' ) { | |
| 1154 | - MainWP_Post_Handler::instance()->secure_request( $action, $query_arg ); | |
| 1155 | - } | |
| 1156 | - | |
| 1157 | - /** | |
| 1158 | - * Method hook_check_security_request() | |
| 1159 | - * | |
| 1160 | - * Security check to request parameter | |
| 1161 | - * | |
| 1162 | - * @param bool $input_value Input value. | |
| 1163 | - * @param string $action Action to perform. | |
| 1164 | - * @param string $query_arg Query argument. | |
| 1165 | - */ | |
| 1166 | - public function hook_check_security_request( $input_value, $action = '', $query_arg = '' ) { | |
| 1167 | - unset( $input_value ); | |
| 1168 | - if ( empty( $query_arg ) ) { | |
| 1169 | - //phpcs:ignore Squiz.PHP.CommentedOutCode.Found | |
| 1170 | - // to do, $query_arg = 'security'. | |
| 1171 | - $query_arg = $action; // to check wp_verify_nonce - sanitize_key( $_REQUEST[ $query_arg ] ) - $action. | |
| 1172 | - } | |
| 1173 | - return MainWP_Post_Handler::instance()->check_security( $action, $query_arg, false ); | |
| 1174 | - } | |
| 1175 | - | |
| 1176 | - /** | |
| 1177 | - * Method hook_get_mainwp_dir() | |
| 1178 | - * | |
| 1179 | - * Hook to get MainWP Directory. | |
| 1180 | - * | |
| 1181 | - * @param bool $input_value False. | |
| 1182 | - * @param null $dir WP files system diectories. | |
| 1183 | - * @param bool $direct_access Return true if Direct access file system. Default: false. | |
| 1184 | - * | |
| 1185 | - * @return array $newdir, $url. | |
| 1186 | - * | |
| 1187 | - * @uses \MainWP\Dashboard\MainWP_System_Utility::get_mainwp_dir() | |
| 1188 | - */ | |
| 1189 | - public function hook_get_mainwp_dir( $input_value = false, $dir = null, $direct_access = false ) { | |
| 1190 | - unset( $input_value ); | |
| 1191 | - return MainWP_System_Utility::get_mainwp_dir( $dir, $direct_access ); | |
| 1192 | - } | |
| 1193 | - | |
| 1194 | - | |
| 1195 | - /** | |
| 1196 | - * Method is_multi_user() | |
| 1197 | - * | |
| 1198 | - * Hook to check if multi user. | |
| 1199 | - * | |
| 1200 | - * @return bool true|false. | |
| 1201 | - * | |
| 1202 | - * @uses \MainWP\Dashboard\MainWP_System::is_multi_user() | |
| 1203 | - */ | |
| 1204 | - public function is_multi_user() { | |
| 1205 | - return MainWP_System::instance()->is_multi_user(); | |
| 1206 | - } | |
| 1207 | - | |
| 1208 | - /** | |
| 1209 | - * Method filter_qq2_file_uploader() | |
| 1210 | - * | |
| 1211 | - * Hook to create new MainWP_QQ2_File_Uploader() class. | |
| 1212 | - * | |
| 1213 | - * @param mixed $allowedExtensions Allowed files extentions. | |
| 1214 | - * @param mixed $sizeLimit Maximum file size allowed to be uploaded. | |
| 1215 | - * | |
| 1216 | - * @return MainWP_QQ2_File_Uploader Return instance of MainWP_QQ2_File_Uploader | |
| 1217 | - * | |
| 1218 | - * @uses \MainWP\Dashboard\MainWP_QQ2_File_Uploader | |
| 1219 | - */ | |
| 1220 | - public function filter_qq2_file_uploader( $allowedExtensions, $sizeLimit ) { | |
| 1221 | - return new MainWP_QQ2_File_Uploader( $allowedExtensions, $sizeLimit ); | |
| 1222 | - } | |
| 1223 | - | |
| 1224 | - /** | |
| 1225 | - * Method get_metaboxes_post() | |
| 1226 | - * | |
| 1227 | - * Hook to get meta boxes. | |
| 1228 | - * | |
| 1229 | - * @return string|bool Return error or true. | |
| 1230 | - * | |
| 1231 | - * @uses \MainWP\Dashboard\MainWP_System::$metaboxes | |
| 1232 | - */ | |
| 1233 | - public function get_metaboxes_post() { | |
| 1234 | - return MainWP_System::instance()->metaboxes; | |
| 1235 | - } | |
| 1236 | - | |
| 1237 | - /** | |
| 1238 | - * Method hook_notification_email() | |
| 1239 | - * | |
| 1240 | - * Hook to get notification email. | |
| 1241 | - * | |
| 1242 | - * @return string Return email. | |
| 1243 | - */ | |
| 1244 | - public function hook_notification_email() { | |
| 1245 | - return MainWP_Notification_Settings::get_general_email(); | |
| 1246 | - } | |
| 1247 | - | |
| 1248 | - /** | |
| 1249 | - * Method get_formated_email() | |
| 1250 | - * | |
| 1251 | - * Hook to format email. | |
| 1252 | - * | |
| 1253 | - * @param mixed $body Email body. | |
| 1254 | - * @param mixed $email Email address. | |
| 1255 | - * @param string $title Email title. | |
| 1256 | - * | |
| 1257 | - * @return string|bool Return error or true. | |
| 1258 | - * | |
| 1259 | - * @uses \MainWP\Dashboard\MainWP_Format::format_email() | |
| 1260 | - */ | |
| 1261 | - public function get_formated_email( $body, $email, $title = '' ) { | |
| 1262 | - return MainWP_Format::format_email( $email, $body, $title ); | |
| 1263 | - } | |
| 1264 | - | |
| 1265 | - /** | |
| 1266 | - * Method active_plugin() | |
| 1267 | - * | |
| 1268 | - * Hook to activate plugins. | |
| 1269 | - * | |
| 1270 | - * @uses \MainWP\Dashboard\MainWP_Plugins_Handler::activate_plugins() | |
| 1271 | - */ | |
| 1272 | - public function active_plugin() { | |
| 1273 | - MainWP_Plugins_Handler::activate_plugins(); | |
| 1274 | - die(); | |
| 1275 | - } | |
| 1276 | - | |
| 1277 | - /** | |
| 1278 | - * Method deactive_plugin() | |
| 1279 | - * | |
| 1280 | - * Hook to deactivate plugins. | |
| 1281 | - * | |
| 1282 | - * @uses \MainWP\Dashboard\MainWP_Plugins_Handler::deactivate_plugins() | |
| 1283 | - */ | |
| 1284 | - public function deactive_plugin() { | |
| 1285 | - MainWP_Plugins_Handler::deactivate_plugins(); | |
| 1286 | - die(); | |
| 1287 | - } | |
| 1288 | - | |
| 1289 | - /** | |
| 1290 | - * Method delete_plugin() | |
| 1291 | - * | |
| 1292 | - * Hook to delete plugins. | |
| 1293 | - * | |
| 1294 | - * @uses \MainWP\Dashboard\MainWP_Plugins_Handler::delete_plugins() | |
| 1295 | - */ | |
| 1296 | - public function delete_plugin() { | |
| 1297 | - MainWP_Plugins_Handler::delete_plugins(); | |
| 1298 | - die(); | |
| 1299 | - } | |
| 1300 | - | |
| 1301 | - /** | |
| 1302 | - * Method delete_theme() | |
| 1303 | - * | |
| 1304 | - * Hook to delete theme() | |
| 1305 | - * | |
| 1306 | - * @uses \MainWP\Dashboard\MainWP_Themes_Handler::delete_themes() | |
| 1307 | - */ | |
| 1308 | - public function delete_theme() { | |
| 1309 | - MainWP_Themes_Handler::delete_themes(); | |
| 1310 | - die(); | |
| 1311 | - } | |
| 1312 | - | |
| 1313 | - /** | |
| 1314 | - * Method upgrade_wp() | |
| 1315 | - * | |
| 1316 | - * Hook to upgrade WP. | |
| 1317 | - */ | |
| 1318 | - public function upgrade_wp() { | |
| 1319 | - | |
| 1320 | - if ( ! mainwp_current_user_have_right( 'dashboard', 'update_wordpress' ) ) { | |
| 1321 | - die( wp_json_encode( array( 'error' => mainwp_do_not_have_permissions( esc_html__( 'update WordPress', 'mainwp' ), false ) ) ) ); | |
| 1322 | - } | |
| 1323 | - | |
| 1324 | - try { | |
| 1325 | - $id = isset( $_POST['id'] ) ? intval( $_POST['id'] ) : false; // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 1326 | - die( wp_json_encode( array( 'result' => MainWP_Updates_Handler::upgrade_site( $id ) ) ) ); // ok. | |
| 1327 | - } catch ( MainWP_Exception $e ) { | |
| 1328 | - die( | |
| 1329 | - wp_json_encode( | |
| 1330 | - array( | |
| 1331 | - 'error' => array( | |
| 1332 | - 'message' => $e->getMessage(), | |
| 1333 | - 'extra' => $e->get_message_extra(), | |
| 1334 | - ), | |
| 1335 | - ) | |
| 1336 | - ) | |
| 1337 | - ); | |
| 1338 | - } | |
| 1339 | - | |
| 1340 | - die(); | |
| 1341 | - } | |
| 1342 | - | |
| 1343 | - /** | |
| 1344 | - * Method upgrade_plugin_theme() | |
| 1345 | - * | |
| 1346 | - * Hook to update theme. | |
| 1347 | - * | |
| 1348 | - * @uses \MainWP\Dashboard\MainWP_Error_Helper::get_error_message() | |
| 1349 | - * @uses \MainWP\Dashboard\MainWP_System_Utility::can_edit_website() | |
| 1350 | - * @uses \MainWP\Dashboard\MainWP_Utility::ctype_digit() | |
| 1351 | - */ | |
| 1352 | - public function upgrade_plugin_theme() { // phpcs:ignore -- NOSONAR - complex. | |
| 1353 | - try { | |
| 1354 | - // phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 1355 | - $websiteId = isset( $_POST['websiteId'] ) ? intval( $_POST['websiteId'] ) : null; | |
| 1356 | - $type = isset( $_POST['type'] ) ? sanitize_text_field( wp_unslash( $_POST['type'] ) ) : null; | |
| 1357 | - $slugs = isset( $_POST['slugs'] ) && is_array( $_POST['slugs'] ) ? wp_unslash( $_POST['slugs'] ) : array(); | |
| 1358 | - $error = ''; | |
| 1359 | - $erCode = ''; | |
| 1360 | - // phpcs:enable | |
| 1361 | - | |
| 1362 | - if ( 'plugin' === $type && ! mainwp_current_user_have_right( 'dashboard', 'update_plugins' ) ) { | |
| 1363 | - $error = mainwp_do_not_have_permissions( esc_html__( 'update plugins', 'mainwp' ), false ); | |
| 1364 | - } elseif ( 'theme' === $type && ! mainwp_current_user_have_right( 'dashboard', 'update_themes' ) ) { | |
| 1365 | - $error = mainwp_do_not_have_permissions( esc_html__( 'update themes', 'mainwp' ), false ); | |
| 1366 | - } | |
| 1367 | - | |
| 1368 | - $website = MainWP_DB::instance()->get_website_by_id( $websiteId ); | |
| 1369 | - | |
| 1370 | - if ( MainWP_System_Utility::is_suspended_site( $website ) ) { | |
| 1371 | - $error = esc_html__( 'Suspended site.', 'mainwp' ); | |
| 1372 | - $erCode = 'SUSPENDED_SITE'; | |
| 1373 | - } | |
| 1374 | - | |
| 1375 | - if ( ! empty( $error ) ) { | |
| 1376 | - wp_send_json( | |
| 1377 | - array( | |
| 1378 | - 'error' => $error, | |
| 1379 | - 'errorCode' => $erCode, | |
| 1380 | - ) | |
| 1381 | - ); | |
| 1382 | - } | |
| 1383 | - | |
| 1384 | - if ( MainWP_Utility::ctype_digit( $websiteId ) && MainWP_System_Utility::can_edit_website( $website ) ) { | |
| 1385 | - /** | |
| 1386 | - * Action: mainwp_before_plugin_theme_translation_update | |
| 1387 | - * | |
| 1388 | - * Fires before plugin/theme/translation update actions. | |
| 1389 | - * | |
| 1390 | - * @since 4.1 | |
| 1391 | - */ | |
| 1392 | - do_action( 'mainwp_before_plugin_theme_translation_update', $type, implode( ',', $slugs ), $website ); | |
| 1393 | - | |
| 1394 | - $information = MainWP_Connect::fetch_url_authed( | |
| 1395 | - $website, | |
| 1396 | - 'upgradeplugintheme', | |
| 1397 | - array( | |
| 1398 | - 'type' => $type, | |
| 1399 | - 'list' => urldecode( implode( ',', $slugs ) ), | |
| 1400 | - ) | |
| 1401 | - ); | |
| 1402 | - | |
| 1403 | - /** | |
| 1404 | - * Action: mainwp_after_plugin_theme_translation_update | |
| 1405 | - * | |
| 1406 | - * Fires before plugin/theme/translation update actions. | |
| 1407 | - * | |
| 1408 | - * @since 4.1 | |
| 1409 | - */ | |
| 1410 | - do_action( 'mainwp_after_plugin_theme_translation_update', $information, $type, implode( ',', $slugs ), $website ); | |
| 1411 | - | |
| 1412 | - if ( isset( $information['sync'] ) ) { | |
| 1413 | - unset( $information['sync'] ); | |
| 377 | + if ( $direct_access ) { | |
| 378 | + if (!file_exists(trailingslashit( $newdir ) . 'index.php')) { | |
| 379 | + @touch(trailingslashit( $newdir ) . 'index.php'); | |
| 1414 | 380 | } |
| 1415 | - wp_send_json( $information ); | |
| 381 | + if ( file_exists( trailingslashit( $newdir ) . '.htaccess' ) ) { | |
| 382 | + @unlink( trailingslashit( $newdir ) . '.htaccess' ); | |
| 383 | + } | |
| 384 | + } else { | |
| 385 | + if ( ! file_exists( trailingslashit( $newdir ) . '.htaccess' ) ) { | |
| 386 | + $file = @fopen( trailingslashit( $newdir ) . '.htaccess', 'w+' ); | |
| 387 | + @fwrite( $file, 'deny from all' ); | |
| 388 | + @fclose( $file ); | |
| 389 | + } | |
| 1416 | 390 | } |
| 1417 | - } catch ( MainWP_Exception $e ) { | |
| 1418 | - die( wp_json_encode( array( 'error' => MainWP_Error_Helper::get_error_message( $e ) ) ) ); | |
| 1419 | 391 | } |
| 1420 | 392 | |
| 1421 | - die(); | |
| 1422 | - } | |
| 393 | + return array( $newdir, $url ); | |
| 394 | + } | |
| 1423 | 395 | |
| 1424 | - /** | |
| 1425 | - * Method hook_get_websites_by_group_ids() | |
| 1426 | - * | |
| 1427 | - * Hook to get Child Sites by group ID. | |
| 1428 | - * | |
| 1429 | - * @param mixed $ids Group IDs. | |
| 1430 | - * @param null $userId Current user ID. | |
| 1431 | - * | |
| 1432 | - * @return (object|null) Database query result for get Child Sites by group ID or null on failure. | |
| 1433 | - */ | |
| 1434 | - public function hook_get_websites_by_group_ids( $ids, $userId = null ) { | |
| 1435 | - return MainWP_DB::instance()->get_websites_by_group_ids( $ids, $userId ); | |
| 1436 | - } | |
| 1437 | 396 | |
| 1438 | - /** | |
| 1439 | - * Method hook_posts_get_edit() | |
| 1440 | - * | |
| 1441 | - * Get and create post to edit. | |
| 1442 | - * | |
| 1443 | - * @uses \MainWP\Dashboard\MainWP_Post_Page_Handler::get_post() | |
| 1444 | - */ | |
| 1445 | - public function hook_posts_get_edit() { | |
| 1446 | - MainWP_Post_Page_Handler::get_post(); | |
| 1447 | - die(); | |
| 1448 | - } | |
| 397 | + public function isMultiUser() { | |
| 398 | + return MainWP_System::Instance()->isMultiUser(); | |
| 399 | + } | |
| 1449 | 400 | |
| 1450 | - /** | |
| 1451 | - * Method hook_posts_bulk_posting() | |
| 1452 | - * | |
| 1453 | - * Post Bulk posting. | |
| 1454 | - * | |
| 1455 | - * @uses \MainWP\Dashboard\MainWP_Post_Page_Handler::get_post() | |
| 1456 | - */ | |
| 1457 | - public function hook_posts_bulk_posting() { | |
| 1458 | - // phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 1459 | - $post_id = isset( $_POST['post_id'] ) && ! empty( $_POST['post_id'] ) ? intval( wp_unslash( $_POST['post_id'] ) ) : false; | |
| 1460 | - if ( $post_id ) { | |
| 1461 | - MainWP_Post_Page_Handler::posting_posts( $post_id, 'ajax_posting' ); | |
| 1462 | - } | |
| 1463 | - // phpcs:enable | |
| 1464 | - die(); | |
| 1465 | - } | |
| 401 | + function filter_qq2FileUploader( $allowedExtensions, $sizeLimit ) { | |
| 402 | + return new qq2FileUploader( $allowedExtensions, $sizeLimit ); | |
| 403 | + } | |
| 1466 | 404 | |
| 1467 | - /** | |
| 1468 | - * Method hook_atarim_default_sitestable_column() | |
| 1469 | - * | |
| 1470 | - * @param mixed $columns columns data. | |
| 1471 | - * | |
| 1472 | - * Hook Atarim default column. | |
| 1473 | - */ | |
| 1474 | - public function hook_atarim_default_sitestable_column( $columns ) { | |
| 1475 | - if ( ! is_plugin_active( 'mainwp-atarim-extension/mainwp-atarim-extension.php' ) ) { | |
| 1476 | - $columns['atarim_tasks'] = esc_html__( 'Atarim', 'mainwp-atarim-extension' ); | |
| 1477 | - } | |
| 1478 | - return $columns; | |
| 1479 | - } | |
| 405 | + function getMetaBoxes() { | |
| 406 | + return MainWP_System::Instance()->metaboxes; | |
| 407 | + } | |
| 1480 | 408 | |
| 1481 | - /** | |
| 1482 | - * Method hook_atarim_manage_sites_default_item() | |
| 1483 | - * | |
| 1484 | - * @param mixed $item item row data. | |
| 1485 | - * | |
| 1486 | - * Hook Atarim manage sites default item. | |
| 1487 | - */ | |
| 1488 | - public function hook_atarim_manage_sites_default_item( $item ) { | |
| 1489 | - if ( ! is_plugin_active( 'mainwp-atarim-extension/mainwp-atarim-extension.php' ) && is_array( $item ) && isset( $item['url'] ) ) { | |
| 1490 | - $collaborate_link = 'https://app.atarim.io/fetching/?_from=mainwp&url=' . $item['url']; | |
| 1491 | - $item['atarim_tasks'] = '<a href="' . $collaborate_link . '" target="_balnk" data-tooltip="Collaborate on this website." data-inverted="" data-position="left center"><span class="ui blue icon label"><i class="comments icon"></i></span></a>'; | |
| 1492 | - } | |
| 1493 | - return $item; | |
| 1494 | - } | |
| 409 | + function get_format_email( $body, $email, $title = '' ) { | |
| 410 | + return MainWP_Utility::formatEmail( $email, $body, $title ); | |
| 411 | + } | |
| 1495 | 412 | |
| 1496 | - /** | |
| 1497 | - * Method hook_get_website_client_tokens() | |
| 1498 | - * | |
| 1499 | - * Hook get client tokens. | |
| 1500 | - * | |
| 1501 | - * @param mixed $input_value input filter value. | |
| 1502 | - * @param int $websiteid Website ID. | |
| 1503 | - * | |
| 1504 | - * @return mixed $result Result of tokens. | |
| 1505 | - */ | |
| 1506 | - public function hook_get_website_client_tokens( $input_value, $websiteid = false ) { | |
| 1507 | - $client_tokens = MainWP_Client_Handler::instance()->get_website_client_tokens_data( $websiteid ); | |
| 413 | + function activePlugin() { | |
| 414 | + MainWP_Plugins::activatePlugins(); | |
| 415 | + die(); | |
| 416 | + } | |
| 1508 | 417 | |
| 1509 | - if ( false === $client_tokens ) { | |
| 1510 | - return $input_value; | |
| 1511 | - } | |
| 418 | + function deactivePlugin() { | |
| 419 | + MainWP_Plugins::deactivatePlugins(); | |
| 420 | + die(); | |
| 421 | + } | |
| 1512 | 422 | |
| 1513 | - return $client_tokens; | |
| 1514 | - } | |
| 423 | + function deletePlugin() { | |
| 424 | + MainWP_Plugins::deletePlugins(); | |
| 425 | + die(); | |
| 426 | + } | |
| 1515 | 427 | |
| 1516 | - /** | |
| 1517 | - * Method hook_get_download_sig() | |
| 1518 | - * | |
| 1519 | - * Hook get download sig. | |
| 1520 | - * | |
| 1521 | - * @param string $input_value Input value. | |
| 1522 | - * @param string $fullfile Full file path. | |
| 1523 | - * | |
| 1524 | - * @return string | |
| 1525 | - */ | |
| 1526 | - public function hook_get_download_sig( $input_value, $fullfile ) { | |
| 1527 | - unset( $input_value ); | |
| 1528 | - return MainWP_System_Utility::get_download_sig( $fullfile ); | |
| 1529 | - } | |
| 428 | + function deleteTheme() { | |
| 429 | + MainWP_Themes::deleteThemes(); | |
| 430 | + die(); | |
| 431 | + } | |
| 1530 | 432 | |
| 1531 | - /** | |
| 1532 | - * Method hook_download_valid_sig(). | |
| 1533 | - * | |
| 1534 | - * Hook get download sig. | |
| 1535 | - * | |
| 1536 | - * @param string $false_value false value. | |
| 1537 | - * @param string $fullfile Full file path. | |
| 1538 | - * @param string $sig sig value. | |
| 1539 | - */ | |
| 1540 | - public function hook_secure_download( $false_value, $fullfile, $sig ) { | |
| 1541 | - unset( $false_value ); | |
| 1542 | - return MainWP_System_Utility::valid_download_sig( $fullfile, $sig ); | |
| 1543 | - } | |
| 433 | + function upgradePluginTheme() { | |
| 434 | + try { | |
| 435 | + $websiteId = $type = null; | |
| 436 | + $slugs = array(); | |
| 437 | + if ( isset( $_POST[ 'websiteId' ] ) ) { | |
| 438 | + $websiteId = $_POST[ 'websiteId' ]; | |
| 439 | + } | |
| 440 | + if ( isset( $_POST[ 'slugs' ] ) ) { | |
| 441 | + $slugs = $_POST[ 'slugs' ]; | |
| 442 | + } | |
| 1544 | 443 | |
| 1545 | - /** | |
| 1546 | - * Method hook_ajax_add_action(). | |
| 1547 | - * | |
| 1548 | - * Hook add ajax action. | |
| 1549 | - * | |
| 1550 | - * @param string $action action name. | |
| 1551 | - * @param string $callback callback function. | |
| 1552 | - * @param int $priority priority action. | |
| 1553 | - * @param int $accepted number args. | |
| 1554 | - */ | |
| 1555 | - public function hook_ajax_add_action( $action, $callback, $priority = 10, $accepted = 2 ) { | |
| 1556 | - MainWP_Post_Handler::instance()->add_action( $action, $callback, $priority, $accepted ); | |
| 1557 | - } | |
| 444 | + if ( isset( $_POST[ 'type' ] ) ) { | |
| 445 | + $type = $_POST[ 'type' ]; | |
| 446 | + } | |
| 1558 | 447 | |
| 1559 | - /** | |
| 1560 | - * Method hook_get_plugin_icon(). | |
| 1561 | - * | |
| 1562 | - * Hook get plugin icon. | |
| 1563 | - * | |
| 1564 | - * @param mixed $icon input icon. | |
| 1565 | - * @param string $slug Plugin slug. | |
| 1566 | - */ | |
| 1567 | - public function hook_get_plugin_icon( $icon, $slug ) { | |
| 1568 | - unset( $icon ); | |
| 1569 | - return MainWP_System_Utility::get_plugin_icon( $slug ); | |
| 1570 | - } | |
| 448 | + $error = ''; | |
| 449 | + if ( $type == 'plugin' && !mainwp_current_user_can( 'dashboard', 'update_plugins' ) ) { | |
| 450 | + $error = mainwp_do_not_have_permissions( __( 'update plugins', 'mainwp' ), false ); | |
| 451 | + } else if ( $type == 'theme' && !mainwp_current_user_can( 'dashboard', 'update_themes' ) ) { | |
| 452 | + $error = mainwp_do_not_have_permissions( __( 'update themes', 'mainwp' ), false ); | |
| 453 | + } | |
| 1571 | 454 | |
| 1572 | - /** | |
| 1573 | - * Method hook_get_theme_icon(). | |
| 1574 | - * | |
| 1575 | - * Hook get theme icon. | |
| 1576 | - * | |
| 1577 | - * @param mixed $icon input icon. | |
| 1578 | - * @param string $slug Theme slug. | |
| 1579 | - */ | |
| 1580 | - public function hook_get_theme_icon( $icon, $slug ) { | |
| 1581 | - unset( $icon ); | |
| 1582 | - return MainWP_System_Utility::get_theme_icon( $slug ); | |
| 1583 | - } | |
| 1584 | - /** | |
| 1585 | - * Method hook_get_dir_slug(). | |
| 1586 | - * | |
| 1587 | - * Hook get dir slug of plugin/theme. | |
| 1588 | - * | |
| 1589 | - * @param mixed $input input value. | |
| 1590 | - * @param string $slug Plugin/Theme slug. | |
| 1591 | - */ | |
| 1592 | - public function hook_get_dir_slug( $input, $slug ) { | |
| 1593 | - unset( $input ); | |
| 1594 | - return MainWP_Utility::get_dir_slug( $slug ); | |
| 1595 | - } | |
| 455 | + if ( !empty( $error ) ) { | |
| 456 | + //die( json_encode( array( 'error' => $error ) ) ); | |
| 457 | + wp_send_json( array( 'error' => $error ) ); | |
| 458 | + } | |
| 1596 | 459 | |
| 1597 | - /** | |
| 1598 | - * Method hook_do_widget_boxes() | |
| 1599 | - * | |
| 1600 | - * Customize WordPress do_meta_boxes() function. | |
| 1601 | - * | |
| 1602 | - * @param mixed $screen_id Current page ID. | |
| 1603 | - * @param string|null $context right|null. If 3 columns then = 'middle'. | |
| 1604 | - * @param string $input_obj Empty string. | |
| 1605 | - * | |
| 1606 | - * @return void Renders widget container box. | |
| 1607 | - */ | |
| 1608 | - public function hook_do_widget_boxes( $screen_id, $context = null, $input_obj = '' ) { | |
| 1609 | - MainWP_UI::do_widget_boxes( $screen_id, $context, $input_obj ); | |
| 1610 | - } | |
| 460 | + if ( MainWP_Utility::ctype_digit( $websiteId ) ) { | |
| 461 | + $website = MainWP_DB::Instance()->getWebsiteById( $websiteId ); | |
| 462 | + if ( MainWP_Utility::can_edit_website( $website ) ) { | |
| 463 | + $information = MainWP_Utility::fetchUrlAuthed( $website, 'upgradeplugintheme', array( | |
| 464 | + 'type' => $type, | |
| 465 | + 'list' => urldecode( implode( ',', $slugs ) ), | |
| 466 | + ) ); | |
| 467 | + if (isset($information['sync'])) | |
| 468 | + unset($information['sync']); | |
| 1611 | 469 | |
| 470 | + //die( json_encode( $information ) ); | |
| 471 | + wp_send_json( $information ); | |
| 472 | + } | |
| 473 | + } | |
| 474 | + } catch ( MainWP_Exception $e ) { | |
| 475 | + die( json_encode( array( 'error' => MainWP_Error_Helper::getErrorMessage( $e ) ) ) ); | |
| 476 | + } | |
| 1612 | 477 | |
| 1613 | - /** | |
| 1614 | - * Method hook_add_widget_box() | |
| 1615 | - * | |
| 1616 | - * Hook add MainWP meta box. | |
| 1617 | - * | |
| 1618 | - * @param mixed $id Widget ID parameter. | |
| 1619 | - * @param mixed $callback Callback function. | |
| 1620 | - * @param null $screen Current page. | |
| 1621 | - * @param string|null $layout widget's layout . | |
| 1622 | - * | |
| 1623 | - * @return void Sets Global $mainwp_widget_boxes[ $page ][ $context ][ $priority ][ $id ]. | |
| 1624 | - */ | |
| 1625 | - public function hook_add_widget_box( $id, $callback, $screen = null, $layout = null ) { | |
| 1626 | - if ( ! is_array( $layout ) ) { | |
| 1627 | - $layout = array(); | |
| 1628 | - } | |
| 1629 | - MainWP_UI::add_widget_box( $id, $callback, $screen, $layout ); | |
| 1630 | - } | |
| 478 | + die(); | |
| 479 | + } | |
| 1631 | 480 | |
| 1632 | - /** | |
| 1633 | - * Method hook_render_modal_upload_icon() | |
| 1634 | - * | |
| 1635 | - * Render modal window for upload plugins & themes icon. | |
| 1636 | - */ | |
| 1637 | - public function hook_render_modal_upload_icon() { | |
| 1638 | - MainWP_UI::render_modal_upload_icon(); | |
| 1639 | - } | |
| 481 | + public function hookGetWebsitesByGroupIds( $ids, $userId = null ) { | |
| 482 | + return MainWP_DB::Instance()->getWebsitesByGroupIds( $ids, $userId ); | |
| 483 | + } | |
| 1640 | 484 | |
| 1641 | - /** | |
| 1642 | - * Method hook_render_plugin_details_modal() | |
| 1643 | - * | |
| 1644 | - * Render modal window plugin details. | |
| 1645 | - */ | |
| 1646 | - public function hook_render_plugin_details_modal() { | |
| 1647 | - MainWP_Updates::render_plugin_details_modal(); | |
| 1648 | - } | |
| 485 | + public function hookDecryptString( $enscrypt ) { | |
| 486 | + return MainWP_Api_Manager_Password_Management::decrypt_string( $enscrypt ); | |
| 487 | + } | |
| 1649 | 488 | |
| 1650 | - /** | |
| 1651 | - * Method hook_render_updates() | |
| 1652 | - * | |
| 1653 | - * Render modal window updates details. | |
| 1654 | - */ | |
| 1655 | - public function hook_render_updates() { | |
| 1656 | - MainWP_Updates::render(); | |
| 1657 | - } | |
| 1658 | - | |
| 1659 | - /** | |
| 1660 | - * Method hook_get_wp_client_by() | |
| 1661 | - * | |
| 1662 | - * Handle get wp client by. | |
| 1663 | - * | |
| 1664 | - * @param string $by by. | |
| 1665 | - * @param mixed $value by value. | |
| 1666 | - * @param mixed $obj Format data. | |
| 1667 | - * @param bool $params Others params. | |
| 1668 | - * | |
| 1669 | - * @return mixed $result results. | |
| 1670 | - */ | |
| 1671 | - public function hook_get_wp_client_by( $by = 'client_id', $value = null, $obj = OBJECT, $params = array() ) { | |
| 1672 | - return MainWP_DB_Client::instance()->get_wp_client_by( $by, $value, $obj, $params ); | |
| 1673 | - } | |
| 1674 | - | |
| 1675 | - /** | |
| 1676 | - * Method hook_get_activation_info() | |
| 1677 | - * | |
| 1678 | - * Get extension activation info. | |
| 1679 | - * | |
| 1680 | - * @param bool $boolean Input bool value. | |
| 1681 | - * @param string $ext_slug extension api slug. | |
| 1682 | - */ | |
| 1683 | - public function hook_get_activation_info( $boolean, $ext_slug ) { | |
| 1684 | - unset( $boolean ); | |
| 1685 | - $data = MainWP_Api_Manager::instance()->get_activation_info( $ext_slug ); | |
| 1686 | - | |
| 1687 | - $info = array(); | |
| 1688 | - | |
| 1689 | - if ( is_array( $data ) && ! empty( $data['api_key'] ) ) { | |
| 1690 | - $info['api_key'] = $data['api_key']; | |
| 1691 | - $info['product_id'] = isset( $data['product_id'] ) ? $data['product_id'] : ''; | |
| 1692 | - $info['instance'] = isset( $data['instance_id'] ) ? $data['instance_id'] : ''; | |
| 1693 | - $info['software_version'] = isset( $data['software_version'] ) ? $data['software_version'] : ''; | |
| 1694 | - $info['object'] = MainWP_Api_Manager::instance()->get_domain(); | |
| 1695 | - if ( isset( $data['product_item_id'] ) ) { | |
| 1696 | - $info['product_item_id'] = $data['product_item_id']; | |
| 1697 | - } | |
| 1698 | - } else { | |
| 1699 | - $info['activated_key'] = 'Deactivated'; | |
| 1700 | - } | |
| 1701 | - | |
| 1702 | - return $info; | |
| 1703 | - } | |
| 1704 | - | |
| 1705 | - /** | |
| 1706 | - * Method hook_get_api_url() | |
| 1707 | - * | |
| 1708 | - * Get MainWP API Url. | |
| 1709 | - */ | |
| 1710 | - public function hook_get_api_url() { | |
| 1711 | - return MainWP_Api_Manager::instance()->get_upgrade_url(); | |
| 1712 | - } | |
| 1713 | - | |
| 1714 | - /** | |
| 1715 | - * Method hook_run_dashboard_action(). | |
| 1716 | - * | |
| 1717 | - * Handle run dashboard action. | |
| 1718 | - * | |
| 1719 | - * @param bool $boolean Input bool value. | |
| 1720 | - * @param string $action The action to run. | |
| 1721 | - * @param bool $out_die The function die or return. | |
| 1722 | - * | |
| 1723 | - * @return mixed $return result. | |
| 1724 | - */ | |
| 1725 | - public function hook_run_dashboard_action( $boolean, $action, $out_die = false ) { | |
| 1726 | - unset( $boolean ); | |
| 1727 | - if ( ! isset( $action ) ) { | |
| 1728 | - return false; | |
| 1729 | - } | |
| 1730 | - | |
| 1731 | - if ( 'master_api_key_check' === $action ) { | |
| 1732 | - $return = $this->hook_master_api_key_check(); | |
| 1733 | - } else { | |
| 1734 | - return false; | |
| 1735 | - } | |
| 1736 | - | |
| 1737 | - if ( $out_die ) { | |
| 1738 | - wp_send_json( $return ); | |
| 1739 | - } | |
| 1740 | - | |
| 1741 | - return $return; | |
| 1742 | - } | |
| 1743 | - | |
| 1744 | - | |
| 1745 | - | |
| 1746 | - /** | |
| 1747 | - * Method hook_master_api_key_check(). | |
| 1748 | - * | |
| 1749 | - * Handle to valid MainWP API key. | |
| 1750 | - * | |
| 1751 | - * @return array $return Data. | |
| 1752 | - */ | |
| 1753 | - public function hook_master_api_key_check() { | |
| 1754 | - $api_key = MainWP_Api_Manager_Key::instance()->get_decrypt_master_api_key(); | |
| 1755 | - $return = array(); | |
| 1756 | - $error = ''; | |
| 1757 | - if ( ! empty( $api_key ) ) { | |
| 1758 | - $result = array(); | |
| 1759 | - try { | |
| 1760 | - $test = MainWP_Api_Manager::instance()->verify_mainwp_api( $api_key ); | |
| 1761 | - $result = json_decode( $test, true ); | |
| 1762 | - if ( is_array( $result ) ) { | |
| 1763 | - if ( isset( $result['success'] ) && $result['success'] ) { | |
| 1764 | - $return['success'] = true; | |
| 1765 | - } elseif ( isset( $result['error'] ) ) { | |
| 1766 | - $error = $result['error']; | |
| 1767 | - } | |
| 1768 | - } | |
| 1769 | - } catch ( \Exception $e ) { | |
| 1770 | - $error = $e->getMessage(); | |
| 1771 | - } | |
| 1772 | - } else { | |
| 1773 | - $error = esc_html__( 'MainWP API key are required.', 'mainwp' ); | |
| 1774 | - } | |
| 1775 | - | |
| 1776 | - if ( ! empty( $error ) ) { | |
| 1777 | - $return['error'] = $error; | |
| 1778 | - } | |
| 1779 | - | |
| 1780 | - if ( ! isset( $return['success'] ) ) { | |
| 1781 | - $return['success'] = false; | |
| 1782 | - } | |
| 1783 | - | |
| 1784 | - return $return; | |
| 1785 | - } | |
| 1786 | - | |
| 1787 | - /** | |
| 1788 | - * Method hook_get_key_value(). | |
| 1789 | - * | |
| 1790 | - * Handle get key value. | |
| 1791 | - * | |
| 1792 | - * @param bool $input_value Boolean value, it should always be FALSE. | |
| 1793 | - * @param string $name Key option name. | |
| 1794 | - * @param mixed $default_value default value. | |
| 1795 | - * | |
| 1796 | - * @return array $return Decrypted Key value. | |
| 1797 | - */ | |
| 1798 | - public function hook_get_key_value( $input_value, $name, $default_value = false ) { | |
| 1799 | - unset( $input_value ); | |
| 1800 | - return MainWP_Keys_Manager::instance()->get_keys_value( $name, $default_value ); | |
| 1801 | - } | |
| 1802 | - | |
| 1803 | - /** | |
| 1804 | - * Method hook_update_key_value(). | |
| 1805 | - * | |
| 1806 | - * Handle update key value. | |
| 1807 | - * | |
| 1808 | - * @param bool $input_value Boolean value, it should always be FALSE. | |
| 1809 | - * @param string $name Key option name. | |
| 1810 | - * @param mixed $value Key value. | |
| 1811 | - * @param string $prefix prefix of key file name. | |
| 1812 | - * | |
| 1813 | - * @return array $return Decrypted Key value. | |
| 1814 | - */ | |
| 1815 | - public function hook_update_key_value( $input_value, $name, $value = false, $prefix = 'ext_' ) { | |
| 1816 | - unset( $input_value ); | |
| 1817 | - return MainWP_Keys_Manager::instance()->update_key_value( $name, $value, $prefix ); | |
| 1818 | - } | |
| 1819 | - | |
| 1820 | - | |
| 1821 | - /** | |
| 1822 | - * Method hook_delete_key_value(). | |
| 1823 | - * | |
| 1824 | - * Handle delete key value. | |
| 1825 | - * | |
| 1826 | - * @param string $name Key option name. | |
| 1827 | - * | |
| 1828 | - * @return mixed Return Result. | |
| 1829 | - */ | |
| 1830 | - public function hook_delete_key_value( $name ) { | |
| 1831 | - return MainWP_Keys_Manager::instance()->update_key_value( $name, false ); // false: to delete. | |
| 1832 | - } | |
| 1833 | - | |
| 1834 | - /** | |
| 1835 | - * Method hook_encrypt_key_value(). | |
| 1836 | - * | |
| 1837 | - * Handle get key value. | |
| 1838 | - * | |
| 1839 | - * @param bool $input_value Boolean value, it should always be FALSE. | |
| 1840 | - * @param array $data Encrypted data. | |
| 1841 | - * @param mixed $prefix prefix value. | |
| 1842 | - * @param mixed $key_file Key file value. | |
| 1843 | - * | |
| 1844 | - * @return array $return Decrypted Key value. | |
| 1845 | - */ | |
| 1846 | - public function hook_encrypt_key_value( $input_value, $data, $prefix = 'ext_', $key_file = false ) { | |
| 1847 | - unset( $input_value ); | |
| 1848 | - return MainWP_Keys_Manager::instance()->encrypt_keys_data( $data, $prefix, $key_file ); | |
| 1849 | - } | |
| 1850 | - | |
| 1851 | - /** | |
| 1852 | - * Method hook_decrypt_key_value(). | |
| 1853 | - * | |
| 1854 | - * Handle get key value. | |
| 1855 | - * | |
| 1856 | - * @param bool $input_value Boolean value, it should always be FALSE. | |
| 1857 | - * @param array $encrypted_data Encrypted data. | |
| 1858 | - * @param mixed $default_value default value. | |
| 1859 | - * | |
| 1860 | - * @return array $return Decrypted Key value. | |
| 1861 | - */ | |
| 1862 | - public function hook_decrypt_key_value( $input_value, $encrypted_data, $default_value = false ) { | |
| 1863 | - unset( $input_value ); | |
| 1864 | - return MainWP_Keys_Manager::instance()->decrypt_keys_data( $encrypted_data, $default_value ); | |
| 1865 | - } | |
| 1866 | - | |
| 1867 | - | |
| 1868 | - /** | |
| 1869 | - * Method hook_delete_key_file(). | |
| 1870 | - * | |
| 1871 | - * Handle delete key value. | |
| 1872 | - * | |
| 1873 | - * @param string $key_file Key file name. | |
| 1874 | - * | |
| 1875 | - * @return array $return Decrypted Key value. | |
| 1876 | - */ | |
| 1877 | - public function hook_delete_key_file( $key_file ) { | |
| 1878 | - return MainWP_Keys_Manager::instance()->delete_key_file( $key_file ); | |
| 1879 | - } | |
| 1880 | - | |
| 1881 | - /** | |
| 1882 | - * Method hook_get_lookup_items(). | |
| 1883 | - * | |
| 1884 | - * @param bool $false_val false value. | |
| 1885 | - * @param string $item_name item name. | |
| 1886 | - * @param int $item_id item id. | |
| 1887 | - * @param string $obj_name object name. | |
| 1888 | - * | |
| 1889 | - * @return array Lookup items. | |
| 1890 | - */ | |
| 1891 | - public function hook_get_lookup_items( $false_val, $item_name, $item_id, $obj_name ) { | |
| 1892 | - unset( $false_val ); | |
| 1893 | - return MainWP_DB::instance()->get_lookup_items( $item_name, $item_id, $obj_name ); | |
| 1894 | - } | |
| 1895 | - | |
| 1896 | - /** | |
| 1897 | - * Method hook_insert_lookup_item(). | |
| 1898 | - * | |
| 1899 | - * @param bool $false_val false value. | |
| 1900 | - * @param string $item_name item name. | |
| 1901 | - * @param int $item_id item id. | |
| 1902 | - * @param string $obj_name object name. | |
| 1903 | - * @param int $obj_id object id. | |
| 1904 | - * | |
| 1905 | - * @return array Lookup items. | |
| 1906 | - */ | |
| 1907 | - public function hook_insert_lookup_item( $false_val, $item_name, $item_id, $obj_name, $obj_id ) { | |
| 1908 | - unset( $false_val ); | |
| 1909 | - return MainWP_DB::instance()->insert_lookup_item( $item_name, $item_id, $obj_name, $obj_id ); | |
| 1910 | - } | |
| 1911 | - | |
| 1912 | - /** | |
| 1913 | - * Method hook_delete_lookup_items(). | |
| 1914 | - * | |
| 1915 | - * @param bool $false_val false value. | |
| 1916 | - * @param string $by Delete by. | |
| 1917 | - * @param array $params params. | |
| 1918 | - * | |
| 1919 | - * @return mixed results. | |
| 1920 | - */ | |
| 1921 | - public function hook_delete_lookup_items( $false_val, $by = 'lookup_id', $params = array() ) { | |
| 1922 | - unset( $false_val ); | |
| 1923 | - return MainWP_DB::instance()->delete_lookup_items( $by, $params ); | |
| 1924 | - } | |
| 1925 | - | |
| 1926 | - /** | |
| 1927 | - * Method hook_get_indicator(). | |
| 1928 | - * | |
| 1929 | - * @param bool $def_value default input value. | |
| 1930 | - * @param bool $indi_type Indicator type. | |
| 1931 | - * @param bool $wrapper_cls field wrapper class. | |
| 1932 | - * @param bool $visible Current indicator status. | |
| 1933 | - * | |
| 1934 | - * @return mixed indicator results. | |
| 1935 | - */ | |
| 1936 | - public function hook_get_indicator( $def_value, $indi_type = 'field', $wrapper_cls = '', $visible = true ) { | |
| 1937 | - unset( $def_value ); | |
| 1938 | - return MainWP_Settings_Indicator::get_indicator( $indi_type, $wrapper_cls, $visible ); | |
| 1939 | - } | |
| 1940 | 489 | } |