| @@ -1,5 +1,6 @@ | ||
| 1 | 1 | <?php |
| 2 | + | |
| 2 | 3 | /** |
| 3 | 4 | * The file that defines the core plugin class |
| 4 | 5 | * |
| 5 | 6 | * A class definition that includes attributes and functions used across both the |
| @@ -7,646 +8,961 @@ | ||
| 7 | 8 | * |
| 8 | 9 | * @since 1.0.0 |
| 9 | 10 | * @author GeoDirectory Team <info@wpgeodirectory.com> |
| 10 | 11 | */ |
| 11 | -class UsersWP { | |
| 12 | +final class UsersWP { | |
| 12 | 13 | |
| 13 | - /** | |
| 14 | - * The current version of the plugin. | |
| 15 | - * | |
| 16 | - * @since 1.0.0 | |
| 17 | - * @access protected | |
| 18 | - * @var string $version The current version of the plugin. | |
| 19 | - */ | |
| 20 | - protected $version; | |
| 21 | - | |
| 22 | - protected $profile; | |
| 23 | - public $forms; | |
| 24 | - protected $i18n; | |
| 25 | - protected $notices; | |
| 26 | - protected $templates; | |
| 27 | - protected $meta; | |
| 28 | - protected $pages; | |
| 29 | - protected $files; | |
| 30 | - protected $shortcodes; | |
| 31 | - protected $assets; | |
| 32 | - protected $admin; | |
| 33 | - protected $admin_settings; | |
| 34 | - protected $menus; | |
| 35 | - protected $form_builder; | |
| 36 | - protected $ajax; | |
| 37 | - protected $tools; | |
| 38 | - protected $tables; | |
| 14 | + public $profile; | |
| 15 | + public $forms; | |
| 16 | + public $notices; | |
| 17 | + /** | |
| 18 | + * The current version of the plugin. | |
| 19 | + * | |
| 20 | + * @since 1.0.0 | |
| 21 | + * @access protected | |
| 22 | + * @var string $version The current version of the plugin. | |
| 23 | + */ | |
| 24 | + protected $plugin_name; | |
| 25 | + protected $version; | |
| 26 | + protected $i18n; | |
| 27 | + protected $templates; | |
| 28 | + protected $meta; | |
| 29 | + protected $pages; | |
| 30 | + protected $files; | |
| 31 | + protected $shortcodes; | |
| 32 | + protected $assets; | |
| 33 | + protected $admin; | |
| 34 | + protected $menus; | |
| 35 | + protected $admin_menus; | |
| 36 | + protected $form_builder; | |
| 37 | + protected $ajax; | |
| 38 | + protected $tools; | |
| 39 | + protected $tables; | |
| 40 | + protected $notifications; | |
| 39 | 41 | |
| 40 | - /** | |
| 41 | - * Define the core functionality of the plugin. | |
| 42 | - * | |
| 43 | - * Set the plugin name and the plugin version that can be used throughout the plugin. | |
| 44 | - * Load the dependencies, define the locale, and set the hooks for the admin area and | |
| 45 | - * the public-facing side of the site. | |
| 46 | - * | |
| 47 | - * @since 1.0.0 | |
| 48 | - */ | |
| 49 | - public function __construct() { | |
| 42 | + /** | |
| 43 | + * Define the core functionality of the plugin. | |
| 44 | + * | |
| 45 | + * Set the plugin name and the plugin version that can be used throughout the plugin. | |
| 46 | + * Load the dependencies, define the locale, and set the hooks for the admin area and | |
| 47 | + * the public-facing side of the site. | |
| 48 | + * | |
| 49 | + * @since 1.0.0 | |
| 50 | + */ | |
| 51 | + public function __construct() { | |
| 52 | + $this->plugin_name = USERSWP_NAME; | |
| 53 | + $this->version = USERSWP_VERSION; | |
| 50 | 54 | |
| 51 | - $this->plugin_name = USERSWP_NAME; | |
| 52 | - $this->version = USERSWP_VERSION; | |
| 53 | 55 | |
| 56 | + $this->load_dependencies(); | |
| 57 | + $this->init_hooks(); | |
| 54 | 58 | |
| 55 | - $this->load_dependencies(); | |
| 56 | - $this->init_hooks(); | |
| 59 | + $this->meta = new UsersWP_Meta(); | |
| 60 | + $this->pages = new UsersWP_Pages(); | |
| 61 | + $this->profile = new UsersWP_Profile(); | |
| 62 | + $this->forms = new UsersWP_Forms(); | |
| 63 | + $this->templates = new UsersWP_Templates(); | |
| 64 | + $this->notices = new UsersWP_Notices(); | |
| 65 | + $this->assets = new UsersWP_Public(); | |
| 66 | + $this->form_builder = new UsersWP_Form_Builder(); | |
| 67 | + $this->menus = new UsersWP_Menus(); | |
| 68 | + $this->tools = new UsersWP_Tools(); | |
| 69 | + $this->tables = new UsersWP_Tables(); | |
| 70 | + $this->admin = new UsersWP_Admin(); | |
| 71 | + $this->admin_menus = new UsersWP_Admin_Menus(); | |
| 72 | + $this->ajax = new UsersWP_Ajax(); | |
| 73 | + $this->files = new UsersWP_Files(); | |
| 74 | + $this->notifications = new UsersWP_Notifications(); | |
| 57 | 75 | |
| 58 | - $this->meta = new UsersWP_Meta(); | |
| 59 | - $this->pages = new UsersWP_Pages(); | |
| 60 | - $this->profile = new UsersWP_Profile(); | |
| 61 | - $this->forms = new UsersWP_Forms(); | |
| 62 | - $this->templates = new UsersWP_Templates(); | |
| 63 | - $this->i18n = new UsersWP_i18n(); | |
| 64 | - $this->notices = new UsersWP_Notices(); | |
| 65 | - $this->assets = new UsersWP_Public(); | |
| 66 | - $this->form_builder = new UsersWP_Form_Builder(); | |
| 67 | - $this->menus = new UsersWP_Menus(); | |
| 68 | - $this->tools = new UsersWP_Tools(); | |
| 69 | - $this->tables = new UsersWP_Tables(); | |
| 76 | + // actions and filters | |
| 77 | + $this->load_assets_actions_and_filters( $this->assets ); | |
| 78 | + $this->load_meta_actions_and_filters( $this->meta ); | |
| 79 | + $this->load_files_actions_and_filters( $this->files ); | |
| 80 | + $this->load_forms_actions_and_filters( $this->forms ); | |
| 81 | + $this->load_notices_actions_and_filters( $this->notices ); | |
| 82 | + $this->load_pages_actions_and_filters( $this->pages ); | |
| 83 | + $this->load_profile_actions_and_filters( $this->profile ); | |
| 84 | + $this->load_tables_actions_and_filters( $this->tables ); | |
| 85 | + $this->load_templates_actions_and_filters( $this->templates ); | |
| 86 | + $this->load_tools_actions_and_filters( $this->tools ); | |
| 87 | + $this->load_notifications_actions_and_filters( $this->notifications ); | |
| 70 | 88 | |
| 71 | - $this->shortcodes = new UsersWP_Shortcodes($this->templates); | |
| 72 | - $this->admin_settings = new UsersWP_Admin_Settings($this->form_builder); | |
| 73 | - $this->admin = new UsersWP_Admin($this->admin_settings); | |
| 74 | - $this->ajax = new UsersWP_Ajax($this->form_builder); | |
| 75 | - $this->files = new UsersWP_Files(); | |
| 76 | - $this->notifications = new UsersWP_Notifications(); | |
| 77 | - $this->status = new UsersWP_Status(); | |
| 89 | + //admin | |
| 90 | + $this->load_form_builder_actions_and_filters( $this->form_builder ); | |
| 91 | + $this->load_menus_actions_and_filters( $this->menus ); | |
| 92 | + } | |
| 78 | 93 | |
| 79 | - | |
| 80 | - // actions and filters | |
| 81 | - $this->load_assets_actions_and_filters($this->assets); | |
| 82 | - $this->load_meta_actions_and_filters($this->meta); | |
| 83 | - $this->load_ajax_actions_and_filters($this->ajax); | |
| 84 | - $this->load_files_actions_and_filters($this->files); | |
| 85 | - $this->load_forms_actions_and_filters($this->forms); | |
| 86 | - $this->load_i18n_actions_and_filters($this->i18n); | |
| 87 | - $this->load_notices_actions_and_filters($this->notices); | |
| 88 | - $this->load_pages_actions_and_filters($this->pages); | |
| 89 | - $this->load_profile_actions_and_filters($this->profile); | |
| 90 | - $this->load_shortcodes_actions_and_filters($this->shortcodes); | |
| 91 | - $this->load_tables_actions_and_filters($this->tables); | |
| 92 | - $this->load_templates_actions_and_filters($this->templates); | |
| 93 | - $this->load_tools_actions_and_filters($this->tools); | |
| 94 | - $this->load_notifications_actions_and_filters($this->notifications); | |
| 95 | - $this->load_status_actions_and_filters($this->status); | |
| 94 | + /** | |
| 95 | + * Load the required dependencies for this plugin. | |
| 96 | + * | |
| 97 | + * @since 1.0.0 | |
| 98 | + * @access private | |
| 99 | + */ | |
| 100 | + private function load_dependencies() { | |
| 101 | + global $uwp_options; | |
| 96 | 102 | |
| 97 | - //admin | |
| 98 | - $this->load_form_builder_actions_and_filters($this->form_builder); | |
| 99 | - $this->load_menus_actions_and_filters($this->menus); | |
| 100 | - $this->load_admin_actions_and_filters($this->admin); | |
| 101 | - $this->load_admin_settings_actions_and_filters($this->admin_settings); | |
| 102 | - | |
| 103 | - } | |
| 103 | + if ( ! function_exists( 'is_plugin_active' ) ) { | |
| 104 | + /** | |
| 105 | + * Load all plugin functions from WordPress. | |
| 106 | + */ | |
| 107 | + require_once( ABSPATH . '/wp-admin/includes/plugin.php' ); | |
| 108 | + } | |
| 104 | 109 | |
| 105 | - /** | |
| 106 | - * Hook into actions and filters. | |
| 107 | - */ | |
| 108 | - private function init_hooks() { | |
| 109 | - register_activation_hook( USERSWP_PLUGIN_FILE, array( 'UsersWP_Activator', 'activate' ) ); | |
| 110 | - register_deactivation_hook( USERSWP_PLUGIN_FILE, array( 'UsersWP_Deactivator', 'deactivate' ) ); | |
| 111 | - add_action( 'admin_init', array('UsersWP_Activator', 'uwp_automatic_upgrade') ); | |
| 112 | - add_action( 'init', array( 'UsersWP_Activator', 'init_background_updater' ), 5 ); | |
| 113 | - add_action( 'widgets_init', array( $this, 'uwp_register_widgets' ) ); | |
| 114 | - } | |
| 110 | + require_once dirname( dirname( __FILE__ ) ) . '/admin/settings/functions.php'; | |
| 115 | 111 | |
| 112 | + $uwp_options = uwp_get_settings(); | |
| 116 | 113 | |
| 117 | - public function load_assets_actions_and_filters($instance) { | |
| 118 | - add_action( 'wp_enqueue_scripts', array($instance, 'enqueue_styles') ); | |
| 119 | - add_action( 'wp_enqueue_scripts', array($instance, 'enqueue_scripts') ); | |
| 120 | - } | |
| 114 | + require_once dirname( dirname( __FILE__ ) ) . '/admin/settings/class-uwp-font-awesome-settings.php'; | |
| 121 | 115 | |
| 122 | - public function load_meta_actions_and_filters($instance) { | |
| 123 | - add_action('user_register', array($instance, 'sync_usermeta'), 10, 1); | |
| 124 | - add_action('delete_user', array($instance, 'delete_usermeta_for_user'), 10, 1); | |
| 125 | - add_action('remove_user_from_blog', array($instance, 'remove_user_from_blog'), 10, 2); | |
| 126 | - add_action('wp_login', array($instance, 'save_user_ip_on_login') ,10,2); | |
| 127 | - add_filter('uwp_before_extra_fields_save', array($instance, 'save_user_ip_on_register'), 10, 3); | |
| 128 | - add_filter('uwp_update_usermeta', array($instance, 'modify_datepicker_value_on_update'), 10, 3); | |
| 129 | - add_filter('uwp_get_usermeta', array($instance, 'modify_datepicker_value_on_get'), 10, 4); | |
| 130 | - add_filter('user_row_actions', array($instance, 'uwp_user_row_actions'), 10, 2); | |
| 131 | - add_action('bulk_actions-users', array($instance, 'uwp_users_bulk_actions')); | |
| 132 | - add_action('handle_bulk_actions-users', array($instance, 'uwp_handle_users_bulk_actions'), 10, 3); | |
| 133 | - add_filter('init', array($instance, 'uwp_process_user_actions')); | |
| 134 | - add_action('admin_notices', array($instance, 'uwp_show_update_messages')); | |
| 135 | - } | |
| 136 | - | |
| 137 | - public function load_ajax_actions_and_filters($instance) { | |
| 138 | - add_action('wp_ajax_uwp_ajax_action', array($instance, 'handler')); | |
| 139 | - } | |
| 116 | + require_once( dirname( dirname( __FILE__ ) ) . '/upgrade.php' ); | |
| 140 | 117 | |
| 141 | - public function load_files_actions_and_filters($instance) { | |
| 142 | - if($instance->uwp_doing_upload()){ | |
| 143 | - add_filter( 'wp_handle_upload_prefilter', array($instance, 'uwp_wp_media_restrict_file_types') ); | |
| 144 | - } | |
| 145 | - add_filter('uwp_get_max_upload_size', array($instance, 'uwp_modify_get_max_upload_size'), 10, 2); | |
| 146 | - } | |
| 118 | + /** | |
| 119 | + * The class responsible for activation functionality | |
| 120 | + * of the plugin. | |
| 121 | + */ | |
| 122 | + require_once dirname( dirname( __FILE__ ) ) . '/includes/class-activator.php'; | |
| 147 | 123 | |
| 148 | - public function load_forms_actions_and_filters($instance) { | |
| 149 | - // general | |
| 150 | - add_action('init', array($instance, 'init_notices'), 1); | |
| 151 | - add_action('uwp_loaded', array($instance, 'handler')); | |
| 152 | - add_action('init', array($instance, 'uwp_privacy_submit_handler')); | |
| 153 | - add_action('uwp_template_display_notices', array($instance, 'display_notices'), 10, 1); | |
| 154 | - add_action('wp_ajax_uwp_upload_file_remove', array($instance, 'uwp_upload_file_remove')); | |
| 155 | - //User search form | |
| 156 | - add_action('uwp_users_page_search_form_inner', array($instance, 'uwp_users_search_form_text_field'), 10, 1); | |
| 157 | - add_action('uwp_users_page_search_form_inner', array($instance, 'uwp_users_search_form_submit'), 50, 1); | |
| 158 | - add_action('personal_options_update', array($instance, 'update_profile_extra_admin_edit'), 10, 1); | |
| 159 | - add_action('edit_user_profile_update', array($instance, 'update_profile_extra_admin_edit'), 10, 1); | |
| 160 | - add_action('user_edit_form_tag', array($instance, 'add_multipart_to_admin_edit_form')); | |
| 161 | - add_action('uwp_template_form_title_after', array($instance, 'uwp_display_username_in_account'), 10, 1); | |
| 124 | + /** | |
| 125 | + * The libraries required. | |
| 126 | + */ | |
| 127 | + require_once dirname( dirname( __FILE__ ) ) . '/vendor/autoload.php'; | |
| 162 | 128 | |
| 129 | + /** | |
| 130 | + * Contains functions for templates. | |
| 131 | + */ | |
| 132 | + require_once( dirname( dirname( __FILE__ ) ) . '/includes/template-functions.php' ); | |
| 163 | 133 | |
| 164 | - // Forms | |
| 165 | - add_filter('uwp_form_input_html_datepicker', array($instance, 'uwp_form_input_datepicker'), 10, 4); | |
| 166 | - add_filter('uwp_form_input_html_time', array($instance, 'uwp_form_input_time'), 10, 4); | |
| 167 | - add_filter('uwp_form_input_html_select', array($instance, 'uwp_form_input_select'), 10, 4); | |
| 168 | - add_filter('uwp_form_input_html_multiselect', array($instance, 'uwp_form_input_multiselect'), 10, 4); | |
| 169 | - add_filter('uwp_form_input_html_text', array($instance, 'uwp_form_input_text'), 10, 4); | |
| 170 | - add_filter('uwp_form_input_html_textarea', array($instance, 'uwp_form_input_textarea'), 10, 4); | |
| 171 | - add_filter('uwp_form_input_html_fieldset', array($instance, 'uwp_form_input_fieldset'), 10, 4); | |
| 172 | - add_filter('uwp_form_input_html_file', array($instance, 'uwp_form_input_file'), 10, 4); | |
| 173 | - add_filter('uwp_form_input_html_checkbox', array($instance, 'uwp_form_input_checkbox'), 10, 4); | |
| 174 | - add_filter('uwp_form_input_html_radio', array($instance, 'uwp_form_input_radio'), 10, 4); | |
| 175 | - add_filter('uwp_form_input_html_url', array($instance, 'uwp_form_input_url'), 10, 4); | |
| 176 | - add_filter('uwp_form_input_html_email', array($instance, 'uwp_form_input_email'), 10, 4); | |
| 177 | - add_filter('uwp_form_input_html_password', array($instance, 'uwp_form_input_password'), 10, 4); | |
| 178 | - // Country select | |
| 179 | - add_filter('uwp_form_input_html_select_country', array($instance, 'uwp_form_input_select_country'), 10, 4); | |
| 180 | - add_filter('uwp_forms_check_for_send_mail_errors', array($instance, 'uwp_forms_check_for_send_mail_errors'), 10, 3); | |
| 181 | - add_filter('uwp_form_input_email_uwp_account_email_after', array($instance, 'uwp_register_confirm_email_field'), 10, 4); | |
| 182 | - add_filter('uwp_form_input_password_uwp_account_password_after', array($instance, 'uwp_register_confirm_password_field'), 10, 4); | |
| 183 | - | |
| 184 | - // Emails | |
| 185 | - add_filter('uwp_send_mail_extras', array($instance, 'init_mail_extras'), 10, 3); | |
| 186 | - add_filter('uwp_send_admin_mail_extras', array($instance, 'init_admin_mail_extras'), 10, 3); | |
| 187 | - | |
| 188 | - } | |
| 134 | + /** | |
| 135 | + * The class responsible for sending emails | |
| 136 | + * of the plugin. | |
| 137 | + */ | |
| 138 | + require_once dirname( dirname( __FILE__ ) ) . '/includes/class-emails.php'; | |
| 189 | 139 | |
| 190 | - public function load_i18n_actions_and_filters($instance) { | |
| 191 | - add_action( 'init', array($instance, 'load_plugin_textdomain')); | |
| 192 | - } | |
| 140 | + /** | |
| 141 | + * The class responsible for reading and updating meta | |
| 142 | + * of the plugin. | |
| 143 | + */ | |
| 144 | + require_once dirname( dirname( __FILE__ ) ) . '/includes/class-meta.php'; | |
| 193 | 145 | |
| 194 | - public function load_notices_actions_and_filters($instance) { | |
| 195 | - add_action('uwp_template_display_notices', array($instance, 'display_registration_disabled_notice')); | |
| 196 | - add_action('uwp_template_display_notices', array($instance, 'form_notice_by_key')); | |
| 197 | - add_action( 'admin_notices', array( $instance, 'show_admin_notices' ) ); | |
| 198 | - add_action( 'admin_notices', array($instance, 'uwp_admin_notices') ); | |
| 199 | - } | |
| 146 | + /** | |
| 147 | + * The class responsible for userswp dates | |
| 148 | + * of the plugin. | |
| 149 | + */ | |
| 150 | + require_once dirname( dirname( __FILE__ ) ) . '/includes/class-date.php'; | |
| 200 | 151 | |
| 201 | - public function load_pages_actions_and_filters($instance) { | |
| 202 | - add_action( 'wpmu_new_blog', array($instance, 'wpmu_generate_default_pages_on_new_site'), 10, 6 ); | |
| 203 | - } | |
| 152 | + /** | |
| 153 | + * The class responsible for userswp pages | |
| 154 | + * of the plugin. | |
| 155 | + */ | |
| 156 | + require_once dirname( dirname( __FILE__ ) ) . '/includes/class-pages.php'; | |
| 204 | 157 | |
| 205 | - public function load_profile_actions_and_filters($instance) { | |
| 206 | - add_action( 'template_redirect', array($instance, 'uwp_redirect_author_page') , 10 , 2 ); | |
| 207 | - //profile page | |
| 208 | - add_filter('query_vars', array($instance, 'profile_query_vars'), 10, 1 ); | |
| 209 | - add_action('init', array($instance, 'rewrite_profile_link') , 10, 1 ); | |
| 210 | - add_filter( 'uwp_profile_link', array($instance, 'get_profile_link'), 10, 2 ); | |
| 211 | - add_filter( 'edit_profile_url', array($instance, 'uwp_modify_admin_bar_edit_profile_url'), 10, 3); | |
| 212 | - add_filter( 'the_title', array($instance, 'modify_profile_page_title'), 10, 2 ); | |
| 213 | - add_filter( 'get_comment_author_link', array($instance, 'uwp_get_comment_author_link') , 10 , 2 ); | |
| 214 | - add_action( 'uwp_profile_header', array($instance, 'get_profile_header'), 10, 1 ); | |
| 215 | - add_action( 'uwp_users_profile_header', array($instance, 'get_profile_header'), 10, 1 ); | |
| 216 | - add_action( 'uwp_profile_title', array($instance, 'get_profile_title'), 10, 1 ); | |
| 217 | - add_action( 'uwp_profile_social', array($instance, 'get_profile_social'), 10, 1 ); | |
| 158 | + /** | |
| 159 | + * The class responsible for uploading files | |
| 160 | + * of the plugin. | |
| 161 | + */ | |
| 162 | + require_once dirname( dirname( __FILE__ ) ) . '/includes/class-files.php'; | |
| 218 | 163 | |
| 219 | - //Fields as tabs | |
| 220 | - add_action( 'uwp_available_tab_items', array($instance, 'uwp_extra_fields_available_tab_items'), 10, 1 ); | |
| 221 | - add_action( 'uwp_profile_tabs', array($instance, 'uwp_extra_fields_as_tabs'), 10, 3 ); | |
| 164 | + /** | |
| 165 | + * The class responsible for defining form handler functionality | |
| 166 | + * of the plugin. | |
| 167 | + */ | |
| 168 | + require_once dirname( dirname( __FILE__ ) ) . '/includes/class-forms.php'; | |
| 222 | 169 | |
| 223 | - // Popup and crop functions | |
| 224 | - add_filter( 'ajax_query_attachments_args', array($instance, 'uwp_restrict_attachment_display') ); | |
| 170 | + /** | |
| 171 | + * The class responsible for form validation | |
| 172 | + * of the plugin. | |
| 173 | + */ | |
| 174 | + require_once dirname( dirname( __FILE__ ) ) . '/includes/class-validation.php'; | |
| 225 | 175 | |
| 226 | - add_action( 'uwp_handle_file_upload_error_checks', array($instance, 'uwp_handle_file_upload_error_checks'), 10, 4 ); | |
| 227 | - add_action( 'wp_ajax_uwp_avatar_banner_upload', array($instance, 'uwp_ajax_avatar_banner_upload') ); | |
| 228 | - //add_action( 'wp_ajax_uwp_ajax_image_crop_popup', array($instance, 'uwp_ajax_image_crop_popup') ); | |
| 229 | - add_action( 'wp_ajax_uwp_ajax_image_crop_popup_form', array($instance, 'uwp_ajax_image_crop_popup_form') ); | |
| 230 | - add_action( 'wp_head', array($instance, 'uwp_define_ajaxurl') ); | |
| 231 | - add_action( 'uwp_profile_header', array($instance, 'uwp_image_crop_init'), 10, 1 ); | |
| 232 | - add_action( 'uwp_admin_profile_edit', array($instance, 'uwp_image_crop_init'), 10, 1 ); | |
| 176 | + /** | |
| 177 | + * Country helpers | |
| 178 | + */ | |
| 179 | + require_once dirname( dirname( __FILE__ ) ) . '/includes/class-countries.php'; | |
| 233 | 180 | |
| 234 | - // Profile Tabs | |
| 235 | - add_action( 'uwp_profile_content', array($instance, 'get_profile_tabs_content'), 10, 1 ); | |
| 236 | - add_action( 'uwp_profile_more_info_tab_content', array($instance, 'get_profile_more_info'), 10, 1); | |
| 237 | - add_action( 'uwp_profile_posts_tab_content', array($instance, 'get_profile_posts'), 10, 1); | |
| 238 | - add_action( 'uwp_profile_comments_tab_content', array($instance, 'get_profile_comments'), 10, 1); | |
| 239 | - add_action( 'uwp_profile_tab_content', array($instance, 'uwp_extra_fields_as_tab_values'), 10, 2 ); | |
| 181 | + /** | |
| 182 | + * The class responsible for defining ajax handler functionality | |
| 183 | + * of the plugin. | |
| 184 | + */ | |
| 185 | + require_once dirname( dirname( __FILE__ ) ) . '/includes/class-ajax.php'; | |
| 240 | 186 | |
| 241 | - // Profile Pagination | |
| 242 | - add_action( 'uwp_profile_pagination', array($instance, 'get_profile_pagination')); | |
| 187 | + /** | |
| 188 | + * The class responsible for defining all shortcodes | |
| 189 | + */ | |
| 190 | + require_once dirname( dirname( __FILE__ ) ) . '/includes/class-templates.php'; | |
| 243 | 191 | |
| 244 | - // Users | |
| 245 | - add_action( 'uwp_users_search', array($instance, 'uwp_users_search')); | |
| 246 | - add_action( 'uwp_users_list', array($instance, 'uwp_users_list')); | |
| 247 | - add_action( 'uwp_users_extra', array($instance, 'get_users_extra')); | |
| 248 | - add_action( 'uwp_profile_bio', array($instance, 'get_profile_side_extra')); | |
| 249 | - add_action( 'wpdiscuz_profile_url', array($instance, 'uwp_wpdiscuz_profile_url'), 10, 2); | |
| 192 | + /** | |
| 193 | + * The class responsible for defining profile content | |
| 194 | + */ | |
| 195 | + require_once dirname( dirname( __FILE__ ) ) . '/includes/class-profile.php'; | |
| 250 | 196 | |
| 251 | - // User, allow subscribers to upload profile and banner pictures | |
| 252 | - add_filter( 'plupload_default_params', array($instance, 'add_uwp_plupload_param'), 10, 1 ); | |
| 253 | - add_filter( 'user_has_cap', array($instance, 'allow_all_users_profile_uploads'), 10, 4 ); | |
| 254 | - } | |
| 197 | + /** | |
| 198 | + * The class responsible for defining all menus items. | |
| 199 | + */ | |
| 200 | + require_once dirname( dirname( __FILE__ ) ) . '/admin/menus/class-checklist.php'; | |
| 255 | 201 | |
| 256 | - public function load_shortcodes_actions_and_filters($instance) { | |
| 257 | - add_shortcode( 'uwp_profile', array($instance, 'profile')); | |
| 258 | - } | |
| 202 | + /** | |
| 203 | + * The class responsible for defining all menus in the admin area. | |
| 204 | + */ | |
| 205 | + require_once dirname( dirname( __FILE__ ) ) . '/admin/menus/class-menus.php'; | |
| 259 | 206 | |
| 260 | - public function load_tables_actions_and_filters($instance) { | |
| 261 | - add_filter( 'wpmu_drop_tables', array($instance, 'drop_tables_on_delete_blog')); | |
| 262 | - } | |
| 263 | - | |
| 264 | - public function load_templates_actions_and_filters($instance) { | |
| 207 | + /** | |
| 208 | + * The class responsible for defining all actions that occur in the admin area. | |
| 209 | + */ | |
| 210 | + require_once dirname( dirname( __FILE__ ) ) . '/admin/class-admin.php'; | |
| 265 | 211 | |
| 266 | - add_action( 'template_redirect', array($instance, 'change_default_password_redirect') ); | |
| 267 | - add_action( 'uwp_template_fields', array($instance, 'uwp_template_fields'), 10, 1 ); | |
| 268 | - add_action( 'uwp_template_fields', array($instance, 'uwp_template_extra_fields'), 10, 1 ); | |
| 269 | - add_action( 'uwp_account_form_display', array($instance, 'uwp_account_edit_form_display'), 10, 1 ); | |
| 270 | - add_action( 'wp_logout', array($instance, 'logout_redirect')); | |
| 271 | - add_action( 'init', array($instance, 'wp_login_redirect')); | |
| 272 | - add_action( 'admin_init', array($instance, 'uwp_activation_redirect')); | |
| 273 | - // Redirect functions | |
| 274 | - add_action( 'template_redirect', array($instance, 'profile_redirect'), 10); | |
| 275 | - add_action( 'template_redirect', array($instance, 'access_checks'), 20); | |
| 276 | - // Admin user edit page | |
| 277 | - add_action( 'edit_user_profile', array($instance, 'get_profile_extra_admin_edit'), 10, 1 ); | |
| 278 | - add_action( 'show_user_profile', array($instance, 'get_profile_extra_admin_edit'), 10, 1 ); | |
| 212 | + /** | |
| 213 | + * The class responsible for defining all actions that occur for setup wizard. | |
| 214 | + */ | |
| 215 | + if ( isset( $_GET['page'] ) && 'uwp-setup' == $_GET['page'] ) { | |
| 216 | + require_once dirname( dirname( __FILE__ ) ) . '/admin/class-admin-setup-wizard.php'; | |
| 217 | + } | |
| 279 | 218 | |
| 219 | + /** | |
| 220 | + * The class responsible for defining all actions help screen. | |
| 221 | + */ | |
| 222 | + require_once dirname( dirname( __FILE__ ) ) . '/admin/class-uwp-admin-help.php'; | |
| 280 | 223 | |
| 281 | - add_filter( 'wp_setup_nav_menu_item', array($instance, 'uwp_setup_nav_menu_item'), 10, 1 ); | |
| 282 | - add_filter( 'the_content', array($instance, 'uwp_author_page_content'), 10, 1 ); | |
| 283 | - add_filter( 'body_class', array($instance, 'uwp_add_body_class'), 10, 1 ); | |
| 224 | + /** | |
| 225 | + * The class responsible for defining all menus in the admin area. | |
| 226 | + */ | |
| 227 | + require_once dirname( dirname( __FILE__ ) ) . '/admin/class-uwp-admin-menus.php'; | |
| 284 | 228 | |
| 285 | - // filter the login and register url | |
| 286 | - add_filter( 'login_url', array($instance, 'wp_login_url'), 10, 3 ); | |
| 287 | - add_filter( 'register_url', array($instance, 'wp_register_url'), 10, 1 ); | |
| 288 | - } | |
| 289 | - | |
| 290 | - public function load_tools_actions_and_filters($instance) { | |
| 291 | - add_action('uwp_admin_sub_menus', array($instance, 'uwp_add_admin_tools_sub_menu'), 100, 1); | |
| 292 | - add_action('uwp_tools_settings_main_tab_content', array($instance, 'uwp_tools_main_tab_content')); | |
| 293 | - add_action('wp_ajax_uwp_process_diagnosis', array($instance, 'uwp_process_diagnosis_ajax')); | |
| 294 | - } | |
| 229 | + /** | |
| 230 | + * The class responsible for defining all admin area settings. | |
| 231 | + */ | |
| 232 | + require_once dirname( dirname( __FILE__ ) ) . '/admin/settings/class-settings.php'; | |
| 295 | 233 | |
| 296 | - public function load_notifications_actions_and_filters($instance){ | |
| 297 | - add_action('uwp_account_form_display', array($instance, 'uwp_user_notifications_form_front'), 10, 1); | |
| 298 | - add_action('init', array($instance, 'uwp_notification_submit_handler')); | |
| 299 | - } | |
| 234 | + /** | |
| 235 | + * The class responsible for default content. | |
| 236 | + */ | |
| 237 | + require_once dirname( dirname( __FILE__ ) ) . '/includes/class-uwp-defaults.php'; | |
| 300 | 238 | |
| 301 | - public function load_status_actions_and_filters($instance){ | |
| 302 | - add_action('uwp_admin_sub_menus', array($instance, 'uwp_add_admin_status_sub_menu'), 100, 1); | |
| 303 | - add_action('uwp_status_settings_main_tab_content', array($instance, 'uwp_status_main_tab_content')); | |
| 304 | - } | |
| 239 | + /** | |
| 240 | + * The class responsible for defining all actions that occur in the public-facing | |
| 241 | + * side of the site. | |
| 242 | + */ | |
| 243 | + require_once dirname( dirname( __FILE__ ) ) . '/public/class-public.php'; | |
| 305 | 244 | |
| 306 | - public function load_form_builder_actions_and_filters($instance) { | |
| 307 | - // Actions | |
| 308 | - add_action('admin_init', array($instance, 'uwp_form_builder_dummy_fields')); | |
| 309 | - add_action('uwp_manage_available_fields_predefined', array($instance, 'uwp_manage_available_fields_predefined')); | |
| 310 | - add_action('uwp_manage_available_fields_custom', array($instance, 'uwp_manage_available_fields_custom')); | |
| 311 | - add_action('uwp_manage_available_fields', array($instance, 'uwp_manage_available_fields')); | |
| 312 | - add_action('uwp_manage_selected_fields', array($instance, 'uwp_manage_selected_fields')); | |
| 313 | - add_action('uwp_admin_extra_custom_fields', array($instance, 'uwp_advance_admin_custom_fields'), 10, 2); | |
| 314 | - add_action('uwp_manage_available_fields', array($instance, 'uwp_manage_register_available_fields'), 10, 1); | |
| 315 | - add_action('uwp_manage_selected_fields', array($instance, 'uwp_manage_register_selected_fields'), 10, 1); | |
| 316 | - add_action('wp_ajax_uwp_ajax_register_action', array($instance, 'uwp_register_ajax_handler')); | |
| 245 | + /** | |
| 246 | + * The class responsible for table functions | |
| 247 | + */ | |
| 248 | + require_once dirname( dirname( __FILE__ ) ) . '/includes/class-tables.php'; | |
| 317 | 249 | |
| 250 | + /** | |
| 251 | + * The class responsible for admin settings functions | |
| 252 | + */ | |
| 253 | + include_once dirname( dirname( __FILE__ ) ) . '/admin/settings/class-uwp-settings-page.php'; | |
| 318 | 254 | |
| 319 | - // Filters | |
| 320 | - add_filter('uwp_builder_extra_fields_multiselect', array($instance, 'uwp_builder_extra_fields_smr'), 10, 4); | |
| 321 | - add_filter('uwp_builder_extra_fields_select', array($instance, 'uwp_builder_extra_fields_smr'), 10, 4); | |
| 322 | - add_filter('uwp_builder_extra_fields_radio', array($instance, 'uwp_builder_extra_fields_smr'), 10, 4); | |
| 323 | - add_filter('uwp_builder_extra_fields_datepicker', array($instance, 'uwp_builder_extra_fields_datepicker'), 10, 4); | |
| 324 | - add_filter('uwp_builder_extra_fields_password', array($instance, 'uwp_builder_extra_fields_password'), 10, 4); | |
| 325 | - add_filter('uwp_builder_extra_fields_email', array($instance, 'uwp_builder_extra_fields_email'), 10, 4); | |
| 326 | - add_filter('uwp_builder_extra_fields_file', array($instance, 'uwp_builder_extra_fields_file'), 10, 4); | |
| 327 | - add_filter('uwp_builder_data_type_text', array($instance, 'uwp_builder_data_type_text'), 10, 4); | |
| 328 | - add_filter('uwp_form_builder_available_fields_head', array($instance, 'uwp_register_available_fields_head'), 10, 2); | |
| 329 | - add_filter('uwp_form_builder_available_fields_note', array($instance, 'uwp_register_available_fields_note'), 10, 2); | |
| 330 | - add_filter('uwp_form_builder_selected_fields_head', array($instance, 'uwp_register_selected_fields_head'), 10, 2); | |
| 331 | - add_filter('uwp_form_builder_selected_fields_note', array($instance, 'uwp_register_selected_fields_note'), 10, 2); | |
| 332 | - add_filter('uwp_register_fields', array($instance, 'uwp_register_extra_fields'), 10, 2); | |
| 333 | - // htmlvar not needed for taxonomy | |
| 334 | - add_filter('uwp_builder_htmlvar_name_taxonomy',array($instance, 'uwp_return_empty_string'),10,4); | |
| 335 | - // default_value not needed for textarea, html, file, fieldset | |
| 336 | - add_filter('uwp_builder_default_value_textarea',array($instance, 'uwp_return_empty_string'),10,4); | |
| 337 | - add_filter('uwp_builder_default_value_html',array($instance, 'uwp_return_empty_string'),10,4); | |
| 338 | - add_filter('uwp_builder_default_value_file',array($instance, 'uwp_return_empty_string'),10,4); | |
| 339 | - add_filter('uwp_builder_default_value_fieldset',array($instance, 'uwp_return_empty_string'),10,4); | |
| 340 | - // is_required not needed for fieldset | |
| 341 | - add_filter('uwp_builder_is_required_fieldset',array($instance, 'uwp_return_empty_string'),10,4); | |
| 342 | - add_filter('uwp_builder_required_msg_fieldset',array($instance, 'uwp_return_empty_string'),10,4); | |
| 343 | - // field_icon not needed for fieldset | |
| 344 | - add_filter('uwp_builder_css_class_fieldset',array($instance, 'uwp_return_empty_string'),10,4); | |
| 345 | - // filters for which is_public not required | |
| 346 | - add_filter('uwp_builder_is_public_password',array($instance, 'uwp_return_empty_string'),10,4); | |
| 347 | - } | |
| 255 | + /** | |
| 256 | + * The class responsible for adding fields in forms | |
| 257 | + */ | |
| 258 | + require_once dirname( dirname( __FILE__ ) ) . '/admin/settings/class-formbuilder.php'; | |
| 348 | 259 | |
| 349 | - public function load_menus_actions_and_filters($instance) { | |
| 350 | - add_action( 'load-nav-menus.php', array($instance, 'users_wp_admin_menu_metabox') ); | |
| 351 | - } | |
| 260 | + /** | |
| 261 | + * The class responsible for adding admin table listing | |
| 262 | + */ | |
| 263 | + require_once dirname ( dirname ( __FILE__ ) ) . '/admin/tables/class-user-types-table.php'; | |
| 352 | 264 | |
| 353 | - public function load_admin_actions_and_filters($instance) { | |
| 354 | - add_action( 'admin_enqueue_scripts', array($instance, 'enqueue_styles') ); | |
| 355 | - add_action( 'admin_enqueue_scripts', array($instance, 'enqueue_scripts') ); | |
| 356 | - add_action( 'admin_menu', array($instance, 'setup_admin_menus') ); | |
| 357 | - add_action('admin_head', array($instance, 'uwp_admin_only_css')); | |
| 358 | - } | |
| 265 | + /** | |
| 266 | + * The class responsible for adding user types | |
| 267 | + */ | |
| 268 | + require_once dirname( dirname( __FILE__ ) ) . '/admin/settings/class-user-types.php'; | |
| 359 | 269 | |
| 360 | - public function load_admin_settings_actions_and_filters($instance) { | |
| 361 | - $instance->init_settings(); | |
| 270 | + /** | |
| 271 | + * The class responsible for defining all admin area settings. | |
| 272 | + */ | |
| 273 | + require_once dirname( dirname( __FILE__ ) ) . '/admin/settings/class-uwp-settings-profile-tabs.php'; | |
| 362 | 274 | |
| 363 | - add_action( 'admin_init', array($instance, 'uwp_register_settings') ); | |
| 364 | - //register settings | |
| 365 | - add_action( 'userswp_settings_main_tab_content', array($instance, 'get_general_content') ); | |
| 366 | - add_action( 'userswp_settings_register_tab_content', array($instance, 'generic_display_form') ); | |
| 367 | - add_action( 'userswp_settings_login_tab_content', array($instance, 'generic_display_form') ); | |
| 368 | - add_action( 'userswp_settings_account_tab_content', array($instance, 'generic_display_form') ); | |
| 369 | - add_action( 'userswp_settings_profile_tab_content', array($instance, 'generic_display_form') ); | |
| 370 | - add_action( 'userswp_settings_users_tab_content', array($instance, 'generic_display_form') ); | |
| 371 | - add_action( 'userswp_settings_change_tab_content', array($instance, 'generic_display_form') ); | |
| 372 | - add_action( 'userswp_settings_uninstall_tab_content', array($instance, 'generic_display_form') ); | |
| 275 | + /** | |
| 276 | + * The class responsible for user sorting builder. | |
| 277 | + */ | |
| 278 | + require_once dirname( dirname( __FILE__ ) ) . '/admin/settings/class-uwp-settings-user-sorting.php'; | |
| 373 | 279 | |
| 374 | - add_action( 'uwp_form_builder_settings_main_tab_content_before', array($instance, 'get_form_builder_tabs') ); | |
| 375 | - add_action( 'uwp_form_builder_settings_main_tab_content', array($instance, 'get_form_builder_content') ); | |
| 376 | - add_filter( 'uwp_display_form_title', array($instance, 'display_form_title'), 10, 3 ); | |
| 377 | - add_action( 'uwp_notifications_settings_main_tab_content', array($instance, 'get_notifications_content') ); | |
| 378 | - add_action( 'uwp_notifications_settings_admin_tab_content', array($instance, 'generic_display_form') ); | |
| 379 | - } | |
| 280 | + /** | |
| 281 | + * The class responsible for adding tools functions | |
| 282 | + */ | |
| 283 | + require_once dirname( dirname( __FILE__ ) ) . '/includes/class-tools.php'; | |
| 380 | 284 | |
| 381 | - public function uwp_register_widgets(){ | |
| 382 | - register_widget("UWP_Register_Widget"); | |
| 383 | - register_widget("UWP_Forgot_Widget"); | |
| 384 | - register_widget("UWP_Login_Widget"); | |
| 385 | - register_widget("UWP_Change_Widget"); | |
| 386 | - register_widget("UWP_Reset_Widget"); | |
| 387 | - register_widget("UWP_Users_Widget"); | |
| 388 | - register_widget("UWP_Account_Widget"); | |
| 389 | - } | |
| 285 | + /** | |
| 286 | + * The class responsible for displaying notices | |
| 287 | + */ | |
| 288 | + require_once dirname( dirname( __FILE__ ) ) . '/includes/class-notices.php'; | |
| 390 | 289 | |
| 391 | - /** | |
| 392 | - * The name of the plugin used to uniquely identify it within the context of | |
| 393 | - * WordPress and to define internationalization functionality. | |
| 394 | - * | |
| 395 | - * @since 1.0.0 | |
| 396 | - * @return string The name of the plugin. | |
| 397 | - */ | |
| 398 | - public function get_plugin_name() { | |
| 399 | - return $this->plugin_name; | |
| 400 | - } | |
| 290 | + /** | |
| 291 | + * contents helpers files and functions. | |
| 292 | + */ | |
| 293 | + require_once( dirname( dirname( __FILE__ ) ) . '/includes/helpers.php' ); | |
| 401 | 294 | |
| 402 | - /** | |
| 403 | - * Retrieve the version number of the plugin. | |
| 404 | - * | |
| 405 | - * @since 1.0.0 | |
| 406 | - * @return string The version number of the plugin. | |
| 407 | - */ | |
| 408 | - public function get_version() { | |
| 409 | - return $this->version; | |
| 410 | - } | |
| 295 | + /** | |
| 296 | + * The class for login widget. | |
| 297 | + */ | |
| 298 | + require_once( dirname( dirname( __FILE__ ) ) . '/widgets/login.php' ); | |
| 411 | 299 | |
| 412 | - /** | |
| 413 | - * Load the required dependencies for this plugin. | |
| 414 | - * | |
| 415 | - * @since 1.0.0 | |
| 416 | - * @access private | |
| 417 | - */ | |
| 418 | - private function load_dependencies() { | |
| 419 | - if ( ! function_exists( 'is_plugin_active' ) ) { | |
| 420 | - /** | |
| 421 | - * Load all plugin functions from WordPress. | |
| 422 | - */ | |
| 423 | - require_once( ABSPATH . '/wp-admin/includes/plugin.php' ); | |
| 424 | - } | |
| 300 | + /** | |
| 301 | + * The class for register widget. | |
| 302 | + */ | |
| 303 | + require_once( dirname( dirname( __FILE__ ) ) . '/widgets/register.php' ); | |
| 425 | 304 | |
| 426 | - /** | |
| 427 | - * The class responsible for defining internationalization functionality | |
| 428 | - * of the plugin. | |
| 429 | - */ | |
| 430 | - require_once dirname(dirname( __FILE__ )) . '/includes/class-i18n.php'; | |
| 305 | + /** | |
| 306 | + * The class for forgot password widget. | |
| 307 | + */ | |
| 308 | + require_once( dirname( dirname( __FILE__ ) ) . '/widgets/forgot.php' ); | |
| 431 | 309 | |
| 432 | - /** | |
| 433 | - * The class responsible for activation functionality | |
| 434 | - * of the plugin. | |
| 435 | - */ | |
| 436 | - require_once dirname(dirname( __FILE__ )) . '/includes/class-activator.php'; | |
| 310 | + /** | |
| 311 | + * The class for reset password widget. | |
| 312 | + */ | |
| 313 | + require_once( dirname( dirname( __FILE__ ) ) . '/widgets/reset.php' ); | |
| 437 | 314 | |
| 438 | - /** | |
| 439 | - * The class responsible for deactivation functionality | |
| 440 | - * of the plugin. | |
| 441 | - */ | |
| 442 | - require_once dirname(dirname( __FILE__ )) . '/includes/class-deactivator.php'; | |
| 315 | + /** | |
| 316 | + * The class for change password widget. | |
| 317 | + */ | |
| 318 | + require_once( dirname( dirname( __FILE__ ) ) . '/widgets/change.php' ); | |
| 443 | 319 | |
| 444 | - /** | |
| 445 | - * The class responsible for sending emails | |
| 446 | - * of the plugin. | |
| 447 | - */ | |
| 448 | - require_once dirname(dirname( __FILE__ )) . '/includes/class-emails.php'; | |
| 320 | + /** | |
| 321 | + * The class for users widget. | |
| 322 | + */ | |
| 323 | + require_once( dirname( dirname( __FILE__ ) ) . '/widgets/users.php' ); | |
| 449 | 324 | |
| 450 | - /** | |
| 451 | - * The class responsible for reading and updating meta | |
| 452 | - * of the plugin. | |
| 453 | - */ | |
| 454 | - require_once dirname(dirname( __FILE__ )) . '/includes/class-meta.php'; | |
| 325 | + /** | |
| 326 | + * The class for users item widget. | |
| 327 | + */ | |
| 328 | + require_once( dirname( dirname( __FILE__ ) ) . '/widgets/users-item.php' ); | |
| 455 | 329 | |
| 456 | - /** | |
| 457 | - * The class responsible for userswp dates | |
| 458 | - * of the plugin. | |
| 459 | - */ | |
| 460 | - require_once dirname(dirname( __FILE__ )) . '/includes/class-date.php'; | |
| 330 | + /** | |
| 331 | + * The class for account widget. | |
| 332 | + */ | |
| 333 | + require_once( dirname( dirname( __FILE__ ) ) . '/widgets/account.php' ); | |
| 461 | 334 | |
| 462 | - /** | |
| 463 | - * The class responsible for userswp pages | |
| 464 | - * of the plugin. | |
| 465 | - */ | |
| 466 | - require_once dirname(dirname( __FILE__ )) . '/includes/class-pages.php'; | |
| 335 | + /** | |
| 336 | + * The class for profile widget. | |
| 337 | + */ | |
| 338 | + require_once( dirname( dirname( __FILE__ ) ) . '/widgets/profile.php' ); | |
| 467 | 339 | |
| 468 | - /** | |
| 469 | - * The class responsible for uploading files | |
| 470 | - * of the plugin. | |
| 471 | - */ | |
| 472 | - require_once dirname(dirname( __FILE__ )) . '/includes/class-files.php'; | |
| 340 | + /** | |
| 341 | + * The class for profile sections widget. | |
| 342 | + */ | |
| 343 | + require_once( dirname( dirname( __FILE__ ) ) . '/widgets/profile-section.php' ); | |
| 473 | 344 | |
| 474 | - /** | |
| 475 | - * The class responsible for defining form handler functionality | |
| 476 | - * of the plugin. | |
| 477 | - */ | |
| 478 | - require_once dirname(dirname( __FILE__ )) . '/includes/class-forms.php'; | |
| 345 | + /** | |
| 346 | + * The class profile header widget | |
| 347 | + */ | |
| 348 | + require_once dirname( dirname( __FILE__ ) ) . '/widgets/profile-header.php'; | |
| 479 | 349 | |
| 480 | - /** | |
| 481 | - * The class responsible for form validation | |
| 482 | - * of the plugin. | |
| 483 | - */ | |
| 484 | - require_once dirname(dirname( __FILE__ )) . '/includes/class-validation.php'; | |
| 350 | + /** | |
| 351 | + * The class for user title widget. | |
| 352 | + */ | |
| 353 | + require_once( dirname( dirname( __FILE__ ) ) . '/widgets/user-title.php' ); | |
| 485 | 354 | |
| 486 | - /** | |
| 487 | - * Country helpers | |
| 488 | - */ | |
| 489 | - require_once dirname(dirname( __FILE__ )) . '/includes/class-countries.php'; | |
| 355 | + /** | |
| 356 | + * The class for user avatar widget. | |
| 357 | + */ | |
| 358 | + require_once( dirname( dirname( __FILE__ ) ) . '/widgets/user-avatar.php' ); | |
| 490 | 359 | |
| 491 | - /** | |
| 492 | - * The class responsible for defining ajax handler functionality | |
| 493 | - * of the plugin. | |
| 494 | - */ | |
| 495 | - require_once dirname(dirname( __FILE__ )) . '/includes/class-ajax.php'; | |
| 360 | + /** | |
| 361 | + * The class for user post count widget. | |
| 362 | + */ | |
| 363 | + require_once( dirname( dirname( __FILE__ ) ) . '/widgets/user-post-counts.php' ); | |
| 496 | 364 | |
| 497 | - /** | |
| 498 | - * The class responsible for defining all shortcodes | |
| 499 | - */ | |
| 500 | - require_once dirname(dirname( __FILE__ )) . '/includes/class-templates.php'; | |
| 365 | + /** | |
| 366 | + * The class for user cover widget. | |
| 367 | + */ | |
| 368 | + require_once( dirname( dirname( __FILE__ ) ) . '/widgets/user-cover.php' ); | |
| 501 | 369 | |
| 502 | - /** | |
| 503 | - * The class responsible for defining profile content | |
| 504 | - */ | |
| 505 | - require_once dirname(dirname( __FILE__ )) . '/includes/class-profile.php'; | |
| 370 | + /** | |
| 371 | + * The class for profile social fields widget. | |
| 372 | + */ | |
| 373 | + require_once( dirname( dirname( __FILE__ ) ) . '/widgets/profile-social.php' ); | |
| 506 | 374 | |
| 507 | - /** | |
| 508 | - * The class responsible for defining all shortcodes | |
| 509 | - */ | |
| 510 | - require_once dirname(dirname( __FILE__ )) . '/includes/class-shortcodes.php'; | |
| 375 | + /** | |
| 376 | + * The class for profile action buttons fields widget. | |
| 377 | + */ | |
| 378 | + require_once( dirname( dirname( __FILE__ ) ) . '/widgets/profile-actions.php' ); | |
| 511 | 379 | |
| 512 | - /** | |
| 513 | - * The class responsible for defining all menus items. | |
| 514 | - */ | |
| 515 | - require_once dirname(dirname( __FILE__ )) . '/admin/menus/class-checklist.php'; | |
| 380 | + /** | |
| 381 | + * The class for profile buttons fields widget. | |
| 382 | + */ | |
| 383 | + require_once( dirname( dirname( __FILE__ ) ) . '/widgets/user-actions.php' ); | |
| 516 | 384 | |
| 517 | - /** | |
| 518 | - * The class responsible for defining all menus in the admin area. | |
| 519 | - */ | |
| 520 | - require_once dirname(dirname( __FILE__ )) . '/admin/menus/class-menus.php'; | |
| 385 | + /** | |
| 386 | + * The class for profile content widget. | |
| 387 | + */ | |
| 388 | + require_once( dirname( dirname( __FILE__ ) ) . '/widgets/profile-tabs.php' ); | |
| 521 | 389 | |
| 522 | - /** | |
| 523 | - * The class responsible for defining all actions that occur in the admin area. | |
| 524 | - */ | |
| 525 | - require_once dirname(dirname( __FILE__ )) . '/admin/class-admin.php'; | |
| 390 | + /** | |
| 391 | + * The class for user meta widget. | |
| 392 | + */ | |
| 393 | + require_once( dirname( dirname( __FILE__ ) ) . '/widgets/user-meta.php' ); | |
| 526 | 394 | |
| 527 | - /** | |
| 528 | - * The class responsible for defining all admin area settings. | |
| 529 | - */ | |
| 530 | - require_once dirname(dirname( __FILE__ )) . '/admin/settings/class-settings.php'; | |
| 395 | + /** | |
| 396 | + * The class for users search widget. | |
| 397 | + */ | |
| 398 | + require_once( dirname( dirname( __FILE__ ) ) . '/widgets/users-search.php' ); | |
| 531 | 399 | |
| 532 | - /** | |
| 533 | - * The class responsible for defining all actions that occur in the public-facing | |
| 534 | - * side of the site. | |
| 535 | - */ | |
| 536 | - require_once dirname(dirname( __FILE__ )) . '/public/class-public.php'; | |
| 400 | + /** | |
| 401 | + * The class for user list sorting widget. | |
| 402 | + */ | |
| 403 | + require_once( dirname( dirname( __FILE__ ) ) . '/widgets/users-loop-actions.php' ); | |
| 537 | 404 | |
| 538 | - /** | |
| 539 | - * The class responsible for table functions | |
| 540 | - */ | |
| 541 | - require_once dirname(dirname( __FILE__ )) . '/includes/class-tables.php'; | |
| 405 | + /** | |
| 406 | + * The class for users list widget. | |
| 407 | + */ | |
| 408 | + require_once( dirname( dirname( __FILE__ ) ) . '/widgets/users-loop.php' ); | |
| 542 | 409 | |
| 543 | - /** | |
| 544 | - * The class responsible for adding fields in forms | |
| 545 | - */ | |
| 546 | - require_once dirname(dirname( __FILE__ )) . '/admin/settings/class-formbuilder.php'; | |
| 410 | + /** | |
| 411 | + * The class for output location widget. | |
| 412 | + */ | |
| 413 | + require_once( dirname( dirname( __FILE__ ) ) . '/widgets/output-location.php' ); | |
| 547 | 414 | |
| 548 | - /** | |
| 549 | - * The class responsible for setting field callbacks | |
| 550 | - */ | |
| 551 | - require_once dirname(dirname( __FILE__ )) . '/includes/class-callback.php'; | |
| 415 | + /** | |
| 416 | + * The class for author box widget. | |
| 417 | + */ | |
| 418 | + require_once( dirname( dirname( __FILE__ ) ) . '/widgets/authorbox.php' ); | |
| 552 | 419 | |
| 553 | - /** | |
| 554 | - * The class responsible for adding tools functions | |
| 555 | - */ | |
| 556 | - require_once dirname(dirname( __FILE__ )) . '/includes/class-tools.php'; | |
| 420 | + /** | |
| 421 | + * The class for user badge widget. | |
| 422 | + */ | |
| 423 | + require_once( dirname( dirname( __FILE__ ) ) . '/widgets/user-badge.php' ); | |
| 557 | 424 | |
| 558 | - /** | |
| 559 | - * The class responsible for displaying notices | |
| 560 | - */ | |
| 561 | - require_once dirname(dirname( __FILE__ )) . '/includes/class-notices.php'; | |
| 425 | + /** | |
| 426 | + * The class for button group widget. | |
| 427 | + */ | |
| 428 | + require_once( dirname( dirname( __FILE__ ) ) . '/widgets/button-group.php' ); | |
| 562 | 429 | |
| 563 | - /** | |
| 564 | - * The libraries required. | |
| 565 | - */ | |
| 566 | - require_once dirname(dirname( __FILE__ )) . '/vendor/autoload.php'; | |
| 430 | + /** | |
| 431 | + * The class responsible for displaying notices | |
| 432 | + */ | |
| 433 | + require_once dirname( dirname( __FILE__ ) ) . '/includes/class-import-export.php'; | |
| 567 | 434 | |
| 568 | - /** | |
| 569 | - * contents helpers files and functions. | |
| 570 | - */ | |
| 571 | - require_once( dirname(dirname( __FILE__ )) .'/includes/helpers.php' ); | |
| 435 | + /** | |
| 436 | + * The class responsible for displaying notices | |
| 437 | + */ | |
| 438 | + require_once dirname( dirname( __FILE__ ) ) . '/includes/class-user-notifications.php'; | |
| 572 | 439 | |
| 573 | - /** | |
| 574 | - * The class for login widget. | |
| 575 | - */ | |
| 576 | - require_once( dirname(dirname( __FILE__ )) .'/widgets/login.php' ); | |
| 440 | + /** | |
| 441 | + * The class responsible for account handling | |
| 442 | + */ | |
| 443 | + require_once dirname( dirname( __FILE__ ) ) . '/includes/class-account.php'; | |
| 577 | 444 | |
| 578 | - /** | |
| 579 | - * The class for register widget. | |
| 580 | - */ | |
| 581 | - require_once( dirname(dirname( __FILE__ )) .'/widgets/register.php' ); | |
| 445 | + /** | |
| 446 | + * The class responsible for adding tools functions | |
| 447 | + */ | |
| 448 | + require_once dirname( dirname( __FILE__ ) ) . '/includes/class-status.php'; | |
| 582 | 449 | |
| 583 | - /** | |
| 584 | - * The class for forgot password widget. | |
| 585 | - */ | |
| 586 | - require_once( dirname(dirname( __FILE__ )) .'/widgets/forgot.php' ); | |
| 450 | + /** | |
| 451 | + * The class responsible for extensions screen functions on admin side | |
| 452 | + */ | |
| 453 | + require_once dirname( dirname( __FILE__ ) ) . '/includes/libraries/class-ayecode-addons.php'; | |
| 587 | 454 | |
| 588 | - /** | |
| 589 | - * The class for reset password widget. | |
| 590 | - */ | |
| 591 | - require_once( dirname(dirname( __FILE__ )) .'/widgets/reset.php' ); | |
| 455 | + /** | |
| 456 | + * The class responsible for extensions screen functions on admin side | |
| 457 | + */ | |
| 458 | + require_once dirname( dirname( __FILE__ ) ) . '/includes/class-addons.php'; | |
| 592 | 459 | |
| 593 | - /** | |
| 594 | - * The class for change password widget. | |
| 595 | - */ | |
| 596 | - require_once( dirname(dirname( __FILE__ )) .'/widgets/change.php' ); | |
| 460 | + /** | |
| 461 | + * The file is responsible for defining deprecated functions. | |
| 462 | + */ | |
| 463 | + require_once dirname( dirname( __FILE__ ) ) . '/includes/deprecated-functions.php'; | |
| 597 | 464 | |
| 598 | - /** | |
| 599 | - * The class for users widget. | |
| 600 | - */ | |
| 601 | - require_once( dirname(dirname( __FILE__ )) .'/widgets/users.php' ); | |
| 465 | + /** | |
| 466 | + * The class responsible for privacy policy functions | |
| 467 | + */ | |
| 468 | + require_once dirname( dirname( __FILE__ ) ) . '/includes/abstract-uwp-privacy.php'; | |
| 469 | + require_once dirname( dirname( __FILE__ ) ) . '/includes/class-uwp-privacy.php'; | |
| 602 | 470 | |
| 603 | - /** | |
| 604 | - * The class for account widget. | |
| 605 | - */ | |
| 606 | - require_once( dirname(dirname( __FILE__ )) .'/widgets/account.php' ); | |
| 471 | + /** | |
| 472 | + * The class responsible for SEO functions | |
| 473 | + */ | |
| 474 | + require_once dirname( dirname( __FILE__ ) ) . '/includes/class-uwp-seo.php'; | |
| 607 | 475 | |
| 608 | - /** | |
| 609 | - * The class responsible for displaying notices | |
| 610 | - */ | |
| 611 | - require_once dirname(dirname( __FILE__ )) . '/includes/class-import-export.php'; | |
| 476 | + /** | |
| 477 | + * The class responsible for compatibility with other themes and plugins | |
| 478 | + */ | |
| 479 | + require_once dirname( dirname( __FILE__ ) ) . '/includes/class-uwp-compatibility.php'; | |
| 612 | 480 | |
| 613 | - /** | |
| 614 | - * The class responsible for displaying notices | |
| 615 | - */ | |
| 616 | - require_once dirname(dirname( __FILE__ )) . '/includes/class-user-notifications.php'; | |
| 481 | + if ( is_plugin_active( 'uwp_geodirectory/uwp_geodirectory.php' ) ) { | |
| 482 | + deactivate_plugins( 'uwp_geodirectory/uwp_geodirectory.php' ); | |
| 483 | + } | |
| 617 | 484 | |
| 618 | - /** | |
| 619 | - * The class responsible for adding tools functions | |
| 620 | - */ | |
| 621 | - require_once dirname(dirname( __FILE__ )) . '/includes/class-status.php'; | |
| 485 | + if ( is_plugin_active( 'geodirectory/geodirectory.php' ) || class_exists( 'GeoDirectory' ) ) { | |
| 486 | + /** | |
| 487 | + * The class responsible for displaying notices | |
| 488 | + * | |
| 489 | + * @since 1.0.12 | |
| 490 | + */ | |
| 491 | + require_once dirname( dirname( __FILE__ ) ) . '/includes/libraries/class-geodirectory-plugin.php'; | |
| 492 | + } | |
| 622 | 493 | |
| 623 | - /** | |
| 624 | - * The class responsible for privacy policy functions | |
| 625 | - */ | |
| 626 | - require_once dirname(dirname( __FILE__ )) . '/includes/abstract-uwp-privacy.php'; | |
| 627 | - require_once dirname(dirname( __FILE__ )) . '/includes/class-uwp-privacy.php'; | |
| 494 | + if ( class_exists( 'WPInv_Plugin' ) ) { | |
| 495 | + /** | |
| 496 | + * The class responsible for displaying notices | |
| 497 | + * | |
| 498 | + * @since 1.0.12 | |
| 499 | + */ | |
| 500 | + require_once dirname( dirname( __FILE__ ) ) . '/includes/libraries/class-invoicing-plugin.php'; | |
| 501 | + } | |
| 502 | + } | |
| 628 | 503 | |
| 629 | - if ( is_plugin_active( 'uwp_geodirectory/uwp_geodirectory.php' ) ) { | |
| 630 | - deactivate_plugins( 'uwp_geodirectory/uwp_geodirectory.php' ); | |
| 631 | - } | |
| 504 | + /** | |
| 505 | + * Hook into actions and filters. | |
| 506 | + */ | |
| 507 | + private function init_hooks() { | |
| 508 | + register_activation_hook( USERSWP_PLUGIN_FILE, array( 'UsersWP_Activator', 'activate' ) ); | |
| 509 | + add_action( 'admin_init', array( 'UsersWP_Activator', 'automatic_upgrade' ) ); | |
| 510 | + add_action( 'init', array( 'UsersWP_Activator', 'init_background_updater' ), 5 ); | |
| 511 | + add_action( 'widgets_init', array( $this, 'register_widgets' ) ); | |
| 512 | + add_action( 'plugins_loaded', array( $this, 'load_plugin_textdomain' ) ); | |
| 513 | + add_action( 'uwp_flush_rewrite_rules', array( $this, 'flush_rewrite_rules' ) ); | |
| 514 | + add_action( 'uwp_language_file_add_string', array( $this, 'register_string' ), 10, 1 ); | |
| 515 | + add_action( 'after_setup_theme', array( $this, 'hide_admin_bar' )); | |
| 516 | + } | |
| 632 | 517 | |
| 633 | - if ( is_plugin_active( 'geodirectory/geodirectory.php' ) || class_exists('GeoDirectory') ) { | |
| 634 | - /** | |
| 635 | - * The class responsible for displaying notices | |
| 636 | - * | |
| 637 | - * @since 1.0.12 | |
| 638 | - */ | |
| 639 | - require_once dirname(dirname( __FILE__ )) . '/includes/libraries/class-geodirectory-plugin.php'; | |
| 640 | - } | |
| 518 | + /** | |
| 519 | + * Actions for assets | |
| 520 | + * | |
| 521 | + * @param $instance | |
| 522 | + */ | |
| 523 | + public function load_assets_actions_and_filters( $instance ) { | |
| 524 | + add_action( 'wp_enqueue_scripts', array( $instance, 'enqueue_styles' ) ); | |
| 525 | + add_action( 'wp_enqueue_scripts', array( $instance, 'enqueue_scripts' ) ); | |
| 526 | + } | |
| 641 | 527 | |
| 642 | - if ( class_exists('WPInv_Invoice') ) { | |
| 643 | - /** | |
| 644 | - * The class responsible for displaying notices | |
| 645 | - * | |
| 646 | - * @since 1.0.12 | |
| 647 | - */ | |
| 648 | - require_once dirname(dirname( __FILE__ )) . '/includes/libraries/class-invoicing-plugin.php'; | |
| 649 | - } | |
| 650 | - } | |
| 528 | + /** | |
| 529 | + * Actions for meta data | |
| 530 | + * | |
| 531 | + * @param $instance | |
| 532 | + */ | |
| 533 | + public function load_meta_actions_and_filters( $instance ) { | |
| 534 | + add_action( 'user_register', array( $instance, 'sync_usermeta' ), 10, 1 ); | |
| 535 | + add_action( 'delete_user', array( $instance, 'delete_usermeta_for_user' ), 10, 1 ); | |
| 536 | + add_action( 'remove_user_from_blog', array( $instance, 'remove_user_from_blog' ), 10, 2 ); | |
| 537 | + add_action( 'wp_login', array( $instance, 'save_user_ip_on_login' ), 10, 2 ); | |
| 538 | + add_filter( 'uwp_before_extra_fields_save', array( $instance, 'save_user_ip_on_register' ), 10, 3 ); | |
| 539 | + add_filter( 'uwp_update_usermeta', array( $instance, 'modify_datepicker_value_on_update' ), 10, 3 ); | |
| 540 | + add_filter( 'uwp_get_usermeta', array( $instance, 'modify_datepicker_value_on_get' ), 10, 4 ); | |
| 541 | + add_action( 'get_user_metadata', array( $instance, 'dynamically_add_user_meta' ), 10, 4 ); | |
| 542 | + // enqueue select2 on auth pages. | |
| 543 | + add_filter( 'aui_is_conditional_select2', array( $this, 'enqueue_select2_on_auth_pages'), 10, 1 ); | |
| 544 | + } | |
| 651 | 545 | |
| 546 | + public function load_files_actions_and_filters( $instance ) { | |
| 547 | + if ( $instance->doing_upload() ) { | |
| 548 | + add_filter( 'wp_handle_upload_prefilter', array( $instance, 'wp_media_restrict_file_types' ) ); | |
| 549 | + } | |
| 550 | + add_filter( 'uwp_get_max_upload_size', array( $instance, 'uwp_modify_get_max_upload_size' ), 10, 2 ); | |
| 551 | + } | |
| 552 | + | |
| 553 | + /** | |
| 554 | + * Actions for forms | |
| 555 | + * | |
| 556 | + * @param $instance | |
| 557 | + */ | |
| 558 | + public function load_forms_actions_and_filters( $instance ) { | |
| 559 | + // login | |
| 560 | + add_action( 'wp_ajax_nopriv_uwp_ajax_login_form', array( $instance, 'ajax_login_form' ) ); | |
| 561 | + add_action( 'wp_ajax_nopriv_uwp_ajax_login', array( $instance, 'process_login' ) ); | |
| 562 | + add_action( 'wp_ajax_nopriv_uwp_ajax_login_process_2fa', array( $instance, 'process_login_2fa' ) ); | |
| 563 | + | |
| 564 | + // register | |
| 565 | + add_action( 'wp_ajax_nopriv_uwp_ajax_register_form', array( $instance, 'ajax_register_form' ) ); | |
| 566 | + add_action( 'wp_ajax_nopriv_uwp_ajax_register', array( $instance, 'process_register' ) ); | |
| 567 | + | |
| 568 | + // forgot | |
| 569 | + add_action( 'wp_ajax_nopriv_uwp_ajax_forgot_password_form', array( $instance, 'ajax_forgot_password_form' ) ); | |
| 570 | + add_action( 'wp_ajax_nopriv_uwp_ajax_forgot_password', array( $instance, 'process_forgot' ) ); | |
| 571 | + | |
| 572 | + // general | |
| 573 | + add_action( 'init', array( $instance, 'init_notices' ), 1 ); | |
| 574 | + add_action( 'uwp_loaded', array( $instance, 'handler' ) ); | |
| 575 | + add_action( 'init', array( $instance, 'privacy_submit_handler' ) ); | |
| 576 | + add_action( 'uwp_template_display_notices', array( $instance, 'display_notices' ), 10, 1 ); | |
| 577 | + add_action( 'wp_ajax_uwp_upload_file_remove', array( $instance, 'upload_file_remove' ) ); | |
| 578 | + //User search form | |
| 579 | + add_action( 'personal_options_update', array( $instance, 'update_profile_extra_admin_edit' ), 10, 1 ); | |
| 580 | + add_action( 'edit_user_profile_update', array( $instance, 'update_profile_extra_admin_edit' ), 10, 1 ); | |
| 581 | + add_action( 'user_edit_form_tag', array( $instance, 'add_multipart_to_admin_edit_form' ) ); | |
| 582 | + add_action( 'template_redirect', array( $instance, 'process_login' ) ); | |
| 583 | + add_action( 'template_redirect', array( $instance, 'process_register' ) ); | |
| 584 | + add_action( 'template_redirect', array( $instance, 'process_account' ) ); | |
| 585 | + add_action( 'template_redirect', array( $instance, 'process_forgot' ) ); | |
| 586 | + add_action( 'template_redirect', array( $instance, 'process_change' ) ); | |
| 587 | + add_action( 'template_redirect', array( $instance, 'process_reset' ) ); | |
| 588 | + | |
| 589 | + // Forms | |
| 590 | + add_filter( 'uwp_form_input_html_datepicker', array( $instance, 'form_input_datepicker' ), 10, 4 ); | |
| 591 | + add_filter( 'uwp_form_input_html_time', array( $instance, 'form_input_time' ), 10, 4 ); | |
| 592 | + add_filter( 'uwp_form_input_html_select', array( $instance, 'form_input_select' ), 10, 4 ); | |
| 593 | + add_filter( 'uwp_form_input_html_multiselect', array( $instance, 'form_input_multiselect' ), 10, 4 ); | |
| 594 | + add_filter( 'uwp_form_input_html_text', array( $instance, 'form_input_text' ), 10, 4 ); | |
| 595 | + add_filter( 'uwp_form_input_html_textarea', array( $instance, 'form_input_textarea' ), 10, 4 ); | |
| 596 | + add_filter( 'uwp_form_input_html_editor', array( $instance, 'form_input_editor' ), 10, 4 ); | |
| 597 | + add_filter( 'uwp_form_input_html_fieldset', array( $instance, 'form_input_fieldset' ), 10, 4 ); | |
| 598 | + add_filter( 'uwp_form_input_html_file', array( $instance, 'form_input_file' ), 10, 4 ); | |
| 599 | + add_filter( 'uwp_form_input_html_checkbox', array( $instance, 'form_input_checkbox' ), 10, 4 ); | |
| 600 | + add_filter( 'uwp_form_input_html_radio', array( $instance, 'form_input_radio' ), 10, 4 ); | |
| 601 | + add_filter( 'uwp_form_input_html_url', array( $instance, 'form_input_url' ), 10, 4 ); | |
| 602 | + add_filter( 'uwp_form_input_html_email', array( $instance, 'form_input_email' ), 10, 4 ); | |
| 603 | + add_filter( 'uwp_form_input_html_password', array( $instance, 'form_input_password' ), 10, 4 ); | |
| 604 | + add_filter( 'uwp_form_input_html_checkbox_register_gdpr', array( $instance, 'form_input_register_gdpr' ), 10, 4 ); | |
| 605 | + add_filter( 'uwp_form_input_html_checkbox_register_tos', array( $instance, 'form_input_register_tos' ), 10, 4 ); | |
| 606 | + // Country select | |
| 607 | + add_filter( 'uwp_form_input_html_select_uwp_country', array( $instance, 'form_input_select_country' ), 10, 4 ); | |
| 608 | + add_filter( 'uwp_form_input_html_phone', array( $instance, 'form_input_phone' ), 10, 4 ); | |
| 609 | + add_filter( 'uwp_form_input_email_email_after', array( $instance, 'register_confirm_email_field' ), 10, 4 ); | |
| 610 | + add_filter( 'uwp_form_input_password_password_after', array( $instance, 'register_confirm_password_field' ), 10, 4 ); | |
| 611 | + add_filter( 'uwp_form_input_html_custom_html', array( $instance, 'form_custom_html' ), 10, 4 ); | |
| 612 | + add_filter( 'uwp_form_input_html_select_uwp_language', array( $instance, 'form_input_uwp_language' ), 10, 4 ); | |
| 613 | + | |
| 614 | + // Emails | |
| 615 | + add_filter( 'uwp_send_mail_form_fields', array( $instance, 'init_mail_form_fields' ), 10, 4 ); | |
| 616 | + } | |
| 617 | + | |
| 618 | + /** | |
| 619 | + * Actions for notices | |
| 620 | + * | |
| 621 | + * @param $instance | |
| 622 | + */ | |
| 623 | + public function load_notices_actions_and_filters( $instance ) { | |
| 624 | + add_action( 'uwp_template_display_notices', array( $instance, 'display_registration_disabled_notice' ) ); | |
| 625 | + add_action( 'uwp_template_display_notices', array( $instance, 'form_notice_by_key' ) ); | |
| 626 | + add_action( 'admin_notices', array( $instance, 'show_admin_notices' ) ); | |
| 627 | + add_action( 'admin_notices', array( $instance, 'try_bootstrap' ) ); | |
| 628 | + add_action( 'admin_notices', array( $instance, 'yoast_user_archives_disabled' ) ); | |
| 629 | + add_action( 'admin_init', array( $instance, 'admin_init_handler' ) ); | |
| 630 | + } | |
| 631 | + | |
| 632 | + /** | |
| 633 | + * Actions for pages | |
| 634 | + * | |
| 635 | + * @param $instance | |
| 636 | + */ | |
| 637 | + public function load_pages_actions_and_filters( $instance ) { | |
| 638 | + add_action( 'wp_initialize_site', array( $instance, 'wpmu_generate_default_pages_on_new_site' ), 10, 1 ); | |
| 639 | + add_filter( 'display_post_states', array( $instance, 'add_display_post_states' ), 10, 2 ); | |
| 640 | + } | |
| 641 | + | |
| 642 | + /** | |
| 643 | + * Actions for user profile | |
| 644 | + * | |
| 645 | + * @param $instance | |
| 646 | + */ | |
| 647 | + public function load_profile_actions_and_filters( $instance ) { | |
| 648 | + add_action( 'template_redirect', array( $instance, 'redirect_author_page' ), 10, 2 ); | |
| 649 | + // Profile page | |
| 650 | + add_filter( 'query_vars', array( $instance, 'profile_query_vars' ), 10, 1 ); | |
| 651 | + add_action( 'init', array( $instance, 'rewrite_profile_link' ), 10, 1 ); | |
| 652 | + add_filter( 'author_link', array( $instance, 'get_author_link' ), 11, 2 ); | |
| 653 | + add_filter( 'edit_profile_url', array( $instance, 'modify_admin_bar_edit_profile_url' ), 10, 3 ); | |
| 654 | + add_filter( 'the_title', array( $instance, 'modify_profile_page_title' ), 10, 2 ); | |
| 655 | + add_filter( 'get_comment_author_link', array( $instance, 'get_comment_author_link' ), 10, 2 ); | |
| 656 | + add_action( 'uwp_user_title', array( $instance, 'get_profile_title' ), 10, 2 ); | |
| 657 | + add_action( 'uwp_profile_social', array( $instance, 'get_profile_social' ), 10, 2 ); | |
| 658 | + add_filter( 'get_avatar_url', array( $instance, 'get_avatar_url' ), 99, 2 ); | |
| 659 | + | |
| 660 | + // Popup and crop functions | |
| 661 | + add_filter( 'ajax_query_attachments_args', array( $instance, 'restrict_attachment_display' ) ); | |
| 662 | + add_action( 'uwp_handle_file_upload_error_checks', array( $instance, 'handle_file_upload_error_checks' ), 10, 4 ); | |
| 663 | + add_action( 'wp_ajax_uwp_avatar_banner_upload', array( $instance, 'ajax_avatar_banner_upload' ) ); | |
| 664 | + add_action( 'wp_ajax_uwp_ajax_image_crop_popup_form', array( $instance, 'ajax_image_crop_popup_form' ) ); | |
| 665 | + add_action( 'wp_ajax_uwp_ajax_profile_image_remove', array( $instance, 'ajax_profile_image_remove' ) ); | |
| 666 | + add_action( 'wp_head', array( $instance, 'define_ajaxurl' ) ); | |
| 667 | + add_action( 'uwp_profile_header', array( $instance, 'image_crop_init' ), 10, 1 ); | |
| 668 | + add_action( 'uwp_admin_profile_edit', array( $instance, 'image_crop_init' ), 10, 1 ); | |
| 669 | + | |
| 670 | + // Profile Tabs | |
| 671 | + add_action( 'uwp_profile_more_info_tab_content', array( $instance, 'get_profile_more_info' ), 10, 1 ); | |
| 672 | + add_action( 'uwp_profile_posts_tab_content', array( $instance, 'get_profile_posts' ), 10, 1 ); | |
| 673 | + add_action( 'uwp_profile_comments_tab_content', array( $instance, 'get_profile_comments' ), 10, 1 ); | |
| 674 | + add_action( 'uwp_profile_user-comments_tab_content', array( $instance, 'get_profile_user_comments' ), 10, 1 ); | |
| 675 | + | |
| 676 | + // Profile Pagination | |
| 677 | + add_action( 'uwp_profile_pagination', array( $instance, 'get_profile_pagination' ) ); | |
| 678 | + | |
| 679 | + // Profile title | |
| 680 | + add_action( 'uwp_profile_after_title', array( $instance, 'edit_profile_button' ), 10, 1 ); | |
| 681 | + | |
| 682 | + // Users | |
| 683 | + add_action( 'uwp_output_location', array( $instance, 'show_output_location_data' ), 10, 2 ); | |
| 684 | + add_action( 'wpdiscuz_profile_url', array( $instance, 'wpdiscuz_profile_url' ), 10, 2 ); | |
| 685 | + | |
| 686 | + // User, allow subscribers to upload profile and banner pictures | |
| 687 | + add_filter( 'plupload_default_params', array( $instance, 'add_uwp_plupload_param' ), 10, 1 ); | |
| 688 | + add_filter( 'user_has_cap', array( $instance, 'allow_all_users_profile_uploads' ), 10, 4 ); | |
| 689 | + } | |
| 690 | + | |
| 691 | + /** | |
| 692 | + * Actions for database tables | |
| 693 | + * | |
| 694 | + * @param $instance | |
| 695 | + */ | |
| 696 | + public function load_tables_actions_and_filters( $instance ) { | |
| 697 | + add_filter( 'wpmu_drop_tables', array( $instance, 'drop_tables_on_delete_blog' ) ); | |
| 698 | + } | |
| 699 | + | |
| 700 | + /** | |
| 701 | + * Actions for templates | |
| 702 | + * | |
| 703 | + * @param $instance | |
| 704 | + */ | |
| 705 | + public function load_templates_actions_and_filters( $instance ) { | |
| 706 | + add_action( 'template_redirect', array( $instance, 'change_default_password_redirect' ) ); | |
| 707 | + add_action( 'uwp_template_fields', array( $instance, 'template_fields' ), 10, 2 ); | |
| 708 | + add_action( 'uwp_template_fields', array( $instance, 'template_extra_fields' ), 10, 2 ); | |
| 709 | + add_action( 'uwp_account_form_display', array( $instance, 'privacy_edit_form_display' ), 10, 1 ); | |
| 710 | + add_action( 'wp_logout', array( $instance, 'logout_redirect' ) ); | |
| 711 | + add_action( 'init', array( $instance, 'wp_login_redirect' ) ); | |
| 712 | + add_action( 'init', array( $instance, 'wp_register_redirect' ) ); | |
| 713 | + // Redirect functions | |
| 714 | + add_action( 'template_redirect', array( $instance, 'profile_redirect' ), 10 ); | |
| 715 | + add_action( 'template_redirect', array( $instance, 'access_checks' ), 20 ); | |
| 716 | + add_action( 'wp', array( $instance, 'redirect_templates_sub_pages' ) ); | |
| 717 | + add_action( 'wp_login', array( $instance, 'unconfirmed_login_redirect' ), 10, 2 ); | |
| 718 | + | |
| 719 | + add_filter( 'wp_setup_nav_menu_item', array( $instance, 'setup_nav_menu_item' ), 10, 1 ); | |
| 720 | + add_filter( 'the_content', array( $instance, 'author_page_content' ), 10, 1 ); | |
| 721 | + add_filter( 'the_content', array( $instance, 'author_box_page_content' ), 10, 1 ); | |
| 722 | + add_filter( 'the_content', array( $instance, 'setup_singular_page_content' ), 10, 1 ); | |
| 723 | + add_filter( 'the_content', array( $instance, 'set_the_content_hook' ), 5, 1 ); | |
| 724 | + add_filter( 'body_class', array( $instance, 'add_body_class' ), 10, 1 ); | |
| 725 | + | |
| 726 | + // Filter the login and register url | |
| 727 | + add_filter( 'login_url', array( $instance, 'wp_login_url' ), 10, 3 ); | |
| 728 | + add_filter( 'register_url', array( $instance, 'wp_register_url' ), 10, 1 ); | |
| 729 | + add_filter( 'lostpassword_url', array( $instance, 'wp_lostpassword_url' ), 10, 1 ); | |
| 730 | + | |
| 731 | + // Oxygen plugin | |
| 732 | + if ( defined( 'CT_VERSION' ) ) { | |
| 733 | + add_filter( 'uwp_get_template', array( $instance, 'oxygen_override_template' ), 11, 5 ); | |
| 734 | + } | |
| 735 | + } | |
| 736 | + | |
| 737 | + /** | |
| 738 | + * Actions for tools | |
| 739 | + * | |
| 740 | + * @param $instance | |
| 741 | + */ | |
| 742 | + public function load_tools_actions_and_filters( $instance ) { | |
| 743 | + add_action( 'uwp_admin_sub_menus', array( $instance, 'uwp_add_admin_tools_sub_menu' ), 100, 1 ); | |
| 744 | + add_action( 'uwp_tools_settings_main_tab_content', array( $instance, 'uwp_tools_main_tab_content' ) ); | |
| 745 | + add_action( 'wp_ajax_uwp_process_diagnosis', array( $instance, 'uwp_process_diagnosis_ajax' ) ); | |
| 746 | + } | |
| 747 | + | |
| 748 | + /** | |
| 749 | + * Actions for notifications | |
| 750 | + * | |
| 751 | + * @param $instance | |
| 752 | + */ | |
| 753 | + public function load_notifications_actions_and_filters( $instance ) { | |
| 754 | + add_action( 'uwp_account_form_display', array( $instance, 'user_notifications_form_front' ), 10, 1 ); | |
| 755 | + add_action( 'init', array( $instance, 'notification_submit_handler' ) ); | |
| 756 | + } | |
| 757 | + | |
| 758 | + /** | |
| 759 | + * Actions for form builder | |
| 760 | + * | |
| 761 | + * @param $instance | |
| 762 | + */ | |
| 763 | + public function load_form_builder_actions_and_filters( $instance ) { | |
| 764 | + // Actions | |
| 765 | + add_action( 'uwp_manage_available_fields_predefined', array( $instance, 'manage_available_fields_predefined' ) ); | |
| 766 | + add_action( 'uwp_manage_available_fields_custom', array( $instance, 'manage_available_fields_custom' ) ); | |
| 767 | + add_action( 'uwp_manage_available_fields', array( $instance, 'manage_available_fields' ) ); | |
| 768 | + add_action( 'uwp_manage_selected_fields', array( $instance, 'manage_selected_fields' ) ); | |
| 769 | + add_action( 'uwp_admin_extra_custom_fields', array( $instance, 'advance_admin_custom_fields' ), 10, 2 ); | |
| 770 | + | |
| 771 | + add_filter( 'uwp_before_form_builder_content', array( $instance, 'multiple_registration_form' ) ); | |
| 772 | + add_filter( 'uwp_before_available_fields', array( $instance, 'display_before_available_fields' ) ); | |
| 773 | + | |
| 774 | + add_action( 'wp_ajax_uwp_ajax_register_action', array( $instance, 'register_ajax_handler' ) ); | |
| 775 | + add_action( 'wp_ajax_uwp_ajax_action', array( $instance, 'create_field' ) ); | |
| 776 | + add_action( 'uwp_form_builder_tabs_content', array( $instance, 'uwp_form_builder' ) ); | |
| 777 | + | |
| 778 | + // Filters | |
| 779 | + add_filter( 'uwp_builder_extra_fields_multiselect', array( $instance, 'builder_extra_fields_smr' ), 10, 4 ); | |
| 780 | + add_filter( 'uwp_builder_extra_fields_select', array( $instance, 'builder_extra_fields_smr' ), 10, 4 ); | |
| 781 | + add_filter( 'uwp_builder_extra_fields_radio', array( $instance, 'builder_extra_fields_smr' ), 10, 4 ); | |
| 782 | + add_filter( 'uwp_builder_extra_fields_datepicker', array( $instance, 'builder_extra_fields_datepicker' ), 10, 4 ); | |
| 783 | + add_filter( 'uwp_builder_extra_fields_password', array( $instance, 'builder_extra_fields_password' ), 10, 4 ); | |
| 784 | + add_filter( 'uwp_builder_extra_fields_email', array( $instance, 'builder_extra_fields_email' ), 10, 4 ); | |
| 785 | + add_filter( 'uwp_builder_extra_fields_file', array( $instance, 'builder_extra_fields_file' ), 10, 4 ); | |
| 786 | + add_filter( 'uwp_builder_data_type_text', array( $instance, 'builder_data_type_text' ), 10, 4 ); | |
| 787 | + add_filter( 'uwp_form_builder_available_fields_head', array( $instance, 'register_available_fields_head' ), 10, 2 ); | |
| 788 | + add_filter( 'uwp_form_builder_available_fields_note', array( $instance, 'register_available_fields_note' ), 10, 2 ); | |
| 789 | + add_filter( 'uwp_form_builder_selected_fields_head', array( $instance, 'register_selected_fields_head' ), 10, 2 ); | |
| 790 | + add_filter( 'uwp_form_builder_selected_fields_note', array( $instance, 'register_selected_fields_note' ), 10, 2 ); | |
| 791 | + // htmlvar not needed for taxonomy | |
| 792 | + add_filter( 'uwp_builder_htmlvar_name_taxonomy', array( $instance, 'return_empty_string' ), 10, 4 ); | |
| 793 | + // default_value not needed for textarea, html, file, fieldset | |
| 794 | + add_filter( 'uwp_builder_default_value_textarea', array( $instance, 'return_empty_string' ), 10, 4 ); | |
| 795 | + add_filter( 'uwp_builder_default_value_html', array( $instance, 'return_empty_string' ), 10, 4 ); | |
| 796 | + add_filter( 'uwp_builder_default_value_file', array( $instance, 'return_empty_string' ), 10, 4 ); | |
| 797 | + add_filter( 'uwp_builder_default_value_fieldset', array( $instance, 'return_empty_string' ), 10, 4 ); | |
| 798 | + // is_required not needed for fieldset | |
| 799 | + add_filter( 'uwp_builder_is_required_fieldset', array( $instance, 'return_empty_string' ), 10, 4 ); | |
| 800 | + add_filter( 'uwp_builder_required_msg_fieldset', array( $instance, 'return_empty_string' ), 10, 4 ); | |
| 801 | + // field_icon not needed for fieldset | |
| 802 | + add_filter( 'uwp_builder_css_class_fieldset', array( $instance, 'return_empty_string' ), 10, 4 ); | |
| 803 | + // filters for which is_public not required | |
| 804 | + add_filter( 'uwp_builder_is_public_password', array( $instance, 'return_empty_string' ), 10, 4 ); | |
| 805 | + add_filter( 'uwp_builder_validation_pattern_text', array( $instance, 'validation_pattern' ), 10, 4 ); | |
| 806 | + add_filter( 'uwp_builder_validation_pattern_email', array( $instance, 'validation_pattern' ), 10, 4 ); | |
| 807 | + add_filter( 'uwp_builder_validation_pattern_phone', array( $instance, 'validation_pattern' ), 10, 4 ); | |
| 808 | + add_filter( 'uwp_builder_validation_pattern_url', array( $instance, 'validation_pattern' ), 10, 4 ); | |
| 809 | + } | |
| 810 | + | |
| 811 | + /** | |
| 812 | + * Actions for admin menus | |
| 813 | + * | |
| 814 | + * @param $instance | |
| 815 | + */ | |
| 816 | + public function load_menus_actions_and_filters( $instance ) { | |
| 817 | + add_action( 'load-nav-menus.php', array( $instance, 'users_wp_admin_menu_metabox' ) ); | |
| 818 | + add_action( 'admin_bar_menu', array( $instance, 'admin_bar_menu' ), 51 ); | |
| 819 | + } | |
| 820 | + | |
| 821 | + /** | |
| 822 | + * Registers an individual text string for WPML translation. | |
| 823 | + * | |
| 824 | + * @since 1.2.2 | |
| 825 | + * | |
| 826 | + * @param string $string The string that needs to be translated. | |
| 827 | + * @param string $domain The plugin domain. Default userswp. | |
| 828 | + * @param string $name The name of the string which helps to know what's being translated. | |
| 829 | + */ | |
| 830 | + public static function register_string( $string, $domain = 'userswp', $name = '' ) { | |
| 831 | + do_action( 'wpml_register_single_string', $domain, $name, $string ); | |
| 832 | + } | |
| 833 | + | |
| 834 | + /** | |
| 835 | + * Register widgets | |
| 836 | + * | |
| 837 | + */ | |
| 838 | + public function register_widgets() { | |
| 839 | + global $pagenow; | |
| 840 | + | |
| 841 | + $block_widget_init_screens = function_exists( 'sd_pagenow_exclude' ) ? sd_pagenow_exclude() : array(); | |
| 842 | + | |
| 843 | + if ( is_admin() && $pagenow && in_array( $pagenow, $block_widget_init_screens ) ) { | |
| 844 | + // Don't initiate in these conditions. | |
| 845 | + } else { | |
| 846 | + $exclude = function_exists( 'sd_widget_exclude' ) ? sd_widget_exclude() : array(); | |
| 847 | + $widgets = $this->get_widgets(); | |
| 848 | + | |
| 849 | + if ( ! empty( $widgets ) ) { | |
| 850 | + foreach ( $widgets as $widget ) { | |
| 851 | + if ( ! in_array( $widget, $exclude ) ) { | |
| 852 | + // SD V1 used to extend the widget class. V2 does not, so we cannot call register widget on it. | |
| 853 | + if ( is_subclass_of( $widget, 'WP_Widget' ) ) { | |
| 854 | + register_widget( $widget ); | |
| 855 | + } else { | |
| 856 | + new $widget(); | |
| 857 | + } | |
| 858 | + } | |
| 859 | + } | |
| 860 | + } | |
| 861 | + } | |
| 862 | + } | |
| 863 | + | |
| 864 | + public function get_widgets(){ | |
| 865 | + $widgets = array( | |
| 866 | + 'UWP_Register_Widget', | |
| 867 | + 'UWP_Forgot_Widget', | |
| 868 | + 'UWP_Login_Widget', | |
| 869 | + 'UWP_Change_Widget', | |
| 870 | + 'UWP_Reset_Widget', | |
| 871 | + 'UWP_Users_Widget', | |
| 872 | + 'UWP_Users_Item_Widget', | |
| 873 | + 'UWP_Account_Widget', | |
| 874 | + 'UWP_Profile_Widget', | |
| 875 | + 'UWP_Profile_Header_Widget', | |
| 876 | + 'UWP_Profile_Social_Widget', | |
| 877 | + 'UWP_Profile_Tabs_Widget', | |
| 878 | + 'UWP_Profile_Actions_Widget', | |
| 879 | + 'UWP_Profile_Section_Widget', | |
| 880 | + 'UWP_User_Title_Widget', | |
| 881 | + 'UWP_User_Avatar_Widget', | |
| 882 | + 'UWP_User_Cover_Widget', | |
| 883 | + 'UWP_User_Post_Counts_Widget', | |
| 884 | + 'UWP_User_Meta_Widget', | |
| 885 | + 'UWP_Users_Search_Widget', | |
| 886 | + 'UWP_Users_Loop_Actions', | |
| 887 | + 'UWP_Users_Loop_Widget', | |
| 888 | + 'UWP_User_Actions_Widget', | |
| 889 | + 'UWP_Output_Location_Widget', | |
| 890 | + 'UWP_Author_Box_Widget', | |
| 891 | + 'UWP_Button_Group_Widget', | |
| 892 | + 'UWP_User_Badge_Widget', | |
| 893 | + ); | |
| 894 | + | |
| 895 | + return apply_filters('uwp_get_widgets', $widgets ); | |
| 896 | + } | |
| 897 | + | |
| 898 | + /** | |
| 899 | + * Load the plugin text domain for translation. | |
| 900 | + * | |
| 901 | + * @since 1.0.0 | |
| 902 | + * @package userswp | |
| 903 | + * @return void | |
| 904 | + */ | |
| 905 | + public function load_plugin_textdomain() { | |
| 906 | + // Determines the current locale. | |
| 907 | + if ( function_exists( 'determine_locale' ) ) { | |
| 908 | + $locale = determine_locale(); | |
| 909 | + } else if ( function_exists( 'get_user_locale' ) ) { | |
| 910 | + $locale = get_user_locale(); | |
| 911 | + } else { | |
| 912 | + $locale = get_locale(); | |
| 913 | + } | |
| 914 | + | |
| 915 | + /** | |
| 916 | + * Filter the locale to use for translations. | |
| 917 | + */ | |
| 918 | + $locale = apply_filters( 'plugin_locale', $locale, 'userswp' ); | |
| 919 | + | |
| 920 | + unload_textdomain( 'userswp', true ); | |
| 921 | + load_textdomain( 'userswp', WP_LANG_DIR . '/userswp/userswp-' . $locale . '.mo' ); | |
| 922 | + load_plugin_textdomain( 'userswp', false, plugin_basename( dirname( USERSWP_PLUGIN_FILE ) ) . '/languages/' ); | |
| 923 | + | |
| 924 | + do_action( 'uwp_loaded' ); | |
| 925 | + } | |
| 926 | + | |
| 927 | + /** | |
| 928 | + * Ensure Select2 is enqueued in auth pages only if not already done. | |
| 929 | + * | |
| 930 | + * @return void | |
| 931 | + * | |
| 932 | + * @since 1.2.29 | |
| 933 | + */ | |
| 934 | + public function enqueue_select2_on_auth_pages() { | |
| 935 | + if ( ! wp_script_is( 'select2', 'enqueued' ) ) { | |
| 936 | + wp_enqueue_script( 'select2' ); | |
| 937 | + } | |
| 938 | + } | |
| 939 | + | |
| 940 | + /** | |
| 941 | + * Flush rewrite rules. | |
| 942 | + * | |
| 943 | + * @return void | |
| 944 | + */ | |
| 945 | + public function flush_rewrite_rules() { | |
| 946 | + flush_rewrite_rules(); | |
| 947 | + } | |
| 948 | + | |
| 949 | + /** | |
| 950 | + * Hide admin bar based on settings. | |
| 951 | + */ | |
| 952 | + public function hide_admin_bar() { | |
| 953 | + $is_hidden = false; | |
| 954 | + | |
| 955 | + if ( is_user_logged_in() ) { | |
| 956 | + $user = get_userdata( (int) get_current_user_id() ); | |
| 957 | + | |
| 958 | + if ( ! empty( $user ) && isset( $user->roles[0] ) ) { | |
| 959 | + $user_role = $user->roles[0]; | |
| 960 | + $is_hidden = uwp_get_option( 'hide_admin_bar_'.$user_role ); | |
| 961 | + } | |
| 962 | + } | |
| 963 | + | |
| 964 | + if ( $is_hidden ) { | |
| 965 | + show_admin_bar( false ); | |
| 966 | + } | |
| 967 | + } | |
| 652 | 968 | } |