| 1 |
<?php |
| 2 |
/******************************************************************************* |
| 3 |
* Plugin Name: Import Users |
| 4 |
* Description: Seamlessly create users and import from your CSV data with ease. |
| 5 |
* Version: 1.0 |
| 6 |
* Author: smackcoders |
| 7 |
* Text Domain: Import-Users |
| 8 |
* Domain Path: /languages/ |
| 9 |
*/ |
| 10 |
|
| 11 |
/******************************************************************************* |
| 12 |
* Import Users is a Tool for importing CSV for the Wordpress |
| 13 |
* plugin developed by Smackcoders. Copyright (C) 2017 Smackcoders. |
| 14 |
* |
| 15 |
* Import Users is free software; you can redistribute it and/or |
| 16 |
* modify it under the terms of the GNU Affero General Public License version 3 |
| 17 |
* as published by the Free Software Foundation with the addition of the |
| 18 |
* following permission added to Section 15 as permitted in Section 7(a): FOR |
| 19 |
* ANY PART OF THE COVERED WORK IN WHICH THE COPYRIGHT IS OWNED BY Import Users, |
| 20 |
Import Users DISCLAIMS THE WARRANTY OF NON |
| 21 |
* INFRINGEMENT OF THIRD PARTY RIGHTS. |
| 22 |
* |
| 23 |
* Import Users is distributed in the hope that it will be useful, |
| 24 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 25 |
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public |
| 26 |
* License for more details. |
| 27 |
* |
| 28 |
* You should have received a copy of the GNU Affero General Public License |
| 29 |
* along with this program; if not, see http://www.gnu.org/licenses or write |
| 30 |
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 31 |
* Boston, MA 02110-1301 USA. |
| 32 |
* |
| 33 |
* You can contact Smackcoders at email address info@smackcoders.com. |
| 34 |
* |
| 35 |
* The interactive user interfaces in original and modified versions |
| 36 |
* of this program must display Appropriate Legal Notices, as required under |
| 37 |
* Section 5 of the GNU Affero General Public License version 3. |
| 38 |
* |
| 39 |
* In accordance with Section 7(b) of the GNU Affero General Public License |
| 40 |
* version 3, these Appropriate Legal Notices must retain the display of the |
| 41 |
* Import Users copyright notice. If the display of the logo is |
| 42 |
* not reasonably feasible for technical reasons, the Appropriate Legal |
| 43 |
* Notices must display the words |
| 44 |
* "Copyright Smackcoders. 2017. All rights reserved". |
| 45 |
********************************************************************************/ |
| 46 |
if ( ! defined( 'ABSPATH' ) ) |
| 47 |
exit; // Exit if accessed directly |
| 48 |
|
| 49 |
if ( ! class_exists( 'User_SM_WPUltimateCSVImporter' ) ) : |
| 50 |
/** |
| 51 |
* Main WPUltimateCSVImporter Class. |
| 52 |
* |
| 53 |
* @class WPUltimateCSVImporter Class |
| 54 |
* @version 5.0 |
| 55 |
*/ |
| 56 |
class User_SM_WPUltimateCSVImporter { |
| 57 |
|
| 58 |
public $version = '1.0'; |
| 59 |
|
| 60 |
/** |
| 61 |
* The single instance of the class. |
| 62 |
* |
| 63 |
* @var $_instance |
| 64 |
* @since 5.0 |
| 65 |
*/ |
| 66 |
protected static $_instance = null; |
| 67 |
|
| 68 |
/** |
| 69 |
* Main WPUltimateCSVImporter Instance. |
| 70 |
* |
| 71 |
* Ensures only one instance of WPUltimateCSVImporter is loaded or can be loaded. |
| 72 |
* |
| 73 |
* @since 5.0 |
| 74 |
* @static |
| 75 |
* @see WC() |
| 76 |
* @return SM_WPUltimateCSVImporter - Main instance. |
| 77 |
*/ |
| 78 |
public static function instance() { |
| 79 |
if ( is_null( self::$_instance ) ) { |
| 80 |
self::$_instance = new self(); |
| 81 |
} |
| 82 |
return self::$_instance; |
| 83 |
} |
| 84 |
|
| 85 |
/** |
| 86 |
* SM_WPUltimateCSVImporter Constructor. |
| 87 |
*/ |
| 88 |
public function __construct() { |
| 89 |
include_once ( 'includes/class-uci-install.php' ); |
| 90 |
include_once ( 'uninstall.php' ); |
| 91 |
|
| 92 |
do_action( 'wp_ultimate_csv_importer_loaded' ); |
| 93 |
//add_filter( 'plugin_row_meta', array('User_SmackUCIInstall', 'plugin_row_meta'), 10, 2 ); |
| 94 |
add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array('User_SmackUCIInstall', 'plugin_row_meta'), 10, 2 ); |
| 95 |
|
| 96 |
if ( ! function_exists( 'is_plugin_active' ) ) { |
| 97 |
require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 98 |
} |
| 99 |
if ( is_plugin_active('Import-Users/index.php') ) { |
| 100 |
// add plugin upgrade notification |
| 101 |
if(get_option('ULTIMATE_CSV_IMP_VERSION') <= 5.0) |
| 102 |
add_action( 'admin_notices', array('User_SmackUCIInstall', 'important_upgrade_notice') ); |
| 103 |
add_action( 'admin_notices', array('User_SmackUCIInstall', 'important_cron_notice') ); |
| 104 |
add_action( 'admin_notices', array( 'User_SmackUCIInstall', 'wp_ultimate_csv_importer_notice' ) ); |
| 105 |
} |
| 106 |
|
| 107 |
add_action('in_plugin_update_message-Import-Users/index.php', array('User_SmackUCIInstall', 'showUpgradeNotification'), 10, 2); |
| 108 |
|
| 109 |
add_filter('cron_schedules', array('User_SmackUCIInstall', 'cron_schedules')); |
| 110 |
$this->define_constants(); |
| 111 |
$this->includes(); |
| 112 |
$this->init_hooks(); |
| 113 |
} |
| 114 |
|
| 115 |
/** |
| 116 |
* Hook into actions and filters. |
| 117 |
* @since 5.0 |
| 118 |
*/ |
| 119 |
private function init_hooks() { |
| 120 |
register_activation_hook( __FILE__, array( 'User_SmackUCIInstall', 'install' ) ); |
| 121 |
add_action( 'plugins_loaded', array( $this, 'init' ), 0 ); |
| 122 |
add_action( 'init', array( $this, 'smack_uci_enqueue_scripts') ); |
| 123 |
/* add_action( 'wp_default_scripts', function( $scripts ) { |
| 124 |
if ( ! empty( $scripts->registered['jquery'] ) ) { |
| 125 |
$scripts->registered['jquery']->deps = array_diff( $scripts->registered['jquery']->deps, array( 'jquery-migrate' ) ); |
| 126 |
} |
| 127 |
} ); */ |
| 128 |
add_action('wp_dashboard_setup', array($this,'uci_pro_add_dashboard_widgets')); |
| 129 |
add_action('smack_uci_email_scheduler', array('User_SmackUCIEmailScheduler', 'send_login_credentials_to_users')); |
| 130 |
add_action('smack_uci_image_scheduler', array('User_SmackUCIMediaScheduler', 'populateFeatureImages')); |
| 131 |
register_deactivation_hook( __FILE__, array( 'User_SmackUCIUnInstall', 'uninstall' ) ); |
| 132 |
} |
| 133 |
|
| 134 |
/** |
| 135 |
* Define User_SmackUCI Constants. |
| 136 |
*/ |
| 137 |
public function define_constants() { |
| 138 |
$upload_dir = wp_upload_dir(); |
| 139 |
$this->define( 'USER_SM_UCI_PLUGIN_FILE', __FILE__ ); |
| 140 |
$this->define( 'USER_SM_UCI_PLUGIN_BASENAME', plugin_basename( __FILE__ ) ); |
| 141 |
$this->define( 'USER_SM_UCI_VERSION', $this->version ); |
| 142 |
$this->define( 'USER_SM_UCI_DELIMITER', ',' ); |
| 143 |
$this->define( 'USER_SM_UCI_PRO_DIR', plugin_dir_path(__FILE__)); |
| 144 |
$this->define( 'USER_SM_UCI_PRO_URL', plugins_url().'/Import-Users'); |
| 145 |
$this->define( 'USER_SM_UCI_LOG_DIR', $upload_dir['basedir'] . '/smack_uci_uploads/import_logs/' ); |
| 146 |
$this->define( 'USER_SM_UCI_DEFAULT_UPLOADS_DIR', $upload_dir['basedir'] ); |
| 147 |
$this->define( 'USER_SM_UCI_DEFAULT_UPLOADS_URL', $upload_dir['baseurl'] ); |
| 148 |
$this->define( 'USER_SM_UCI_FILE_MANAGING_DIR', $upload_dir['basedir'] . '/smack_uci_uploads/' ); |
| 149 |
$this->define( 'USER_SM_UCI_IMPORT_DIR', $upload_dir['basedir'] . '/smack_uci_uploads/imports' ); |
| 150 |
$this->define( 'USER_SM_UCI_IMPORT_URL', $upload_dir['baseurl'] . '/smack_uci_uploads/imports' ); |
| 151 |
$this->define( 'USER_SM_UCI_EXPORT_DIR', $upload_dir['basedir'] . '/smack_uci_uploads/exports/' ); |
| 152 |
$this->define( 'USER_SM_UCI_EXPORT_URL', $upload_dir['baseurl'] . '/smack_uci_uploads/exports/' ); |
| 153 |
$this->define( 'USER_SM_UCI_ZIP_FILES_DIR', $upload_dir['basedir'] . '/smack_uci_uploads/zip_files/' ); |
| 154 |
$this->define( 'USER_SM_UCI_INLINE_IMAGE_DIR', $upload_dir['basedir'] . '/smack_inline_images/' ); |
| 155 |
$this->define( 'USER_SM_UCI_SCREENS_DATA',$upload_dir['basedir'].'/smack_uci_uploads/screens_data'); |
| 156 |
$this->define( 'USER_SM_UCI_SESSION_CACHE_GROUP', 'smack_uci_session_id' ); |
| 157 |
$this->define( 'USER_SM_UCI_SETTINGS', 'Import Users' ); |
| 158 |
$this->define( 'USER_SM_UCI_NAME', 'Import Users' ); |
| 159 |
$this->define( 'USER_SM_UCI_SLUG', 'Import-Users' ); |
| 160 |
$this->define( 'USER_SM_UCI_DEBUG_LOG', $upload_dir['basedir'] . '/Import-Users.log'); |
| 161 |
} |
| 162 |
|
| 163 |
/** |
| 164 |
* Define constant if not already set. |
| 165 |
* |
| 166 |
* @param string $name |
| 167 |
* @param string|bool $value |
| 168 |
*/ |
| 169 |
public function define( $name, $value ) { |
| 170 |
if ( ! defined( $name ) ) { |
| 171 |
define( $name, $value ); |
| 172 |
} |
| 173 |
} |
| 174 |
|
| 175 |
/** |
| 176 |
* Include required core files used in admin and on the frontend. |
| 177 |
*/ |
| 178 |
public function includes() { |
| 179 |
include_once ( 'includes/class-uci-helper.php' ); |
| 180 |
include_once ( 'libs/parsers/SmackCSVParser.php' ); |
| 181 |
include_once ( 'includes/class-uci-admin-ajax.php' ); |
| 182 |
include_once ( 'includes/class-uci-event-logging.php' ); |
| 183 |
include_once ( 'admin/class-uci-admin.php' ); |
| 184 |
include_once ( 'includes/class-uci-email-scheduler.php' ); |
| 185 |
include_once ( 'includes/class-uci-media-scheduler.php' ); |
| 186 |
#User_SmackUCIMediaScheduler::populateFeatureImages(); |
| 187 |
} |
| 188 |
|
| 189 |
public function smack_uci_enqueue_scripts() { |
| 190 |
// Register / Enqueue the plugin scripts & style |
| 191 |
$uciPages = array('user-uci-dashboard', 'user-uci-import', 'sm-uci-managers', 'sm-uci-export', 'user-uci-settings', 'user-uci-support'); |
| 192 |
if (isset($_REQUEST['page']) && in_array(sanitize_text_field($_REQUEST['page']), $uciPages)) { |
| 193 |
// Ultimate CSV Importer Styles |
| 194 |
wp_enqueue_style( 'ultimate-css', plugins_url( 'assets/css/ultimate-importer.css', __FILE__ ) ); |
| 195 |
wp_enqueue_style( 'boot.css', plugins_url( 'assets/css/bootstrap.css', __FILE__ ) ); |
| 196 |
wp_enqueue_style( 'Icomoon Icons', plugins_url( 'assets/css/icomoon.css', __FILE__ ) ); |
| 197 |
wp_enqueue_style( 'Animate CSS', plugins_url( 'assets/css/animate.css', __FILE__ ) ); |
| 198 |
wp_enqueue_style( 'jquery-fileupload.css', plugins_url( 'assets/css/jquery.fileupload.css', __FILE__ ) ); |
| 199 |
wp_enqueue_style( 'jquery-style', plugins_url( 'assets/css/jquery-ui.css', __FILE__ ) ); |
| 200 |
wp_enqueue_style('icheck', plugins_url('assets/css/icheck/green.css', __FILE__)); |
| 201 |
wp_enqueue_style( 'bootstrap-datepicker-css', plugins_url('assets/css/bootstrap-datepicker.css', __FILE__ ) ); |
| 202 |
wp_enqueue_style( 'file-tree-css', plugins_url( 'assets/css/jqueryfiletree.css', __FILE__ ) ); |
| 203 |
// WaitMe CSS & JS for blur the page and show the progressing loader |
| 204 |
wp_enqueue_style('waitme-css', plugins_url('assets/css/waitMe.css', __FILE__)); |
| 205 |
wp_enqueue_style('sweet-alert-css', plugins_url('assets/css/sweetalert.css', __FILE__)); |
| 206 |
wp_enqueue_style('custom-style', plugins_url('assets/css/custom-style.css', __FILE__)); |
| 207 |
//new files include |
| 208 |
//wp_enqueue_style('custom-new-style', plugins_url('assets/css/custom-new-style.css', __FILE__)); |
| 209 |
wp_enqueue_style( 'bootstrap-select-css', plugins_url( 'assets/css/bootstrap-select.css', __FILE__ )); |
| 210 |
// Ultimate CSV Importer Scripts |
| 211 |
wp_enqueue_script( 'jquery' ); |
| 212 |
wp_enqueue_script( 'icheck-js', plugins_url( 'assets/js/icheck.min.js', __FILE__ ) ); |
| 213 |
wp_enqueue_script( 'file-download-js', plugins_url( 'assets/js/jquery.fileDownload.js', __FILE__ ) ); |
| 214 |
wp_register_script( 'ultimate-importer-js', plugins_url( 'assets/js/ultimate-importer.js', __FILE__ ) ); |
| 215 |
wp_enqueue_script( 'ultimate-importer-js' ); |
| 216 |
wp_register_script( 'bootstrap-datepicker-js', plugins_url( 'assets/js/bootstrap-datepicker.js', __FILE__ ) ); |
| 217 |
wp_enqueue_script( 'bootstrap-datepicker-js' ); |
| 218 |
wp_enqueue_script( 'jquery-ui-dialog' ); |
| 219 |
wp_enqueue_script('jquery-ui-draggable'); |
| 220 |
wp_enqueue_script('jquery-ui-droppable'); |
| 221 |
wp_enqueue_script('jquery-ui-core'); |
| 222 |
wp_enqueue_script( 'file-tree', plugins_url( 'assets/js/jqueryfiletree.js', __FILE__ ) ); |
| 223 |
wp_localize_script( 'ultimate-importer-js', 'uci_importer', array( |
| 224 |
'adminurl' => admin_url(), |
| 225 |
'siteurl' => site_url(), |
| 226 |
'requestpage' => $_REQUEST['page'], |
| 227 |
'db_orphanedMsg' => __('no of Orphaned Post/Page meta has been removed.', 'Import-Users'), |
| 228 |
'db_tagMsg' => __('no of Unassigned tags has been removed.', 'Import-Users'), |
| 229 |
'db_revisionMsg' => __('no of Post/Page revisions has been removed.', 'Import-Users'), |
| 230 |
'db_draftMSg' => __('no of Auto drafted Post/Page has been removed.', 'Import-Users'), |
| 231 |
'db_trashMsg' => __('no of Post/Page in trash has been removed.', 'Import-Users'), |
| 232 |
'db_spamMsg' => __('no of Spam comments has been removed.', 'Import-Users'), |
| 233 |
'db_commentTrashMsg' => __('no of Comments in trash has been removed.', 'Import-Users'), |
| 234 |
'db_unapprovedMsg' => __('no of Unapproved comments has been removed.', 'Import-Users'), |
| 235 |
'db_pingbackMsg' => __('no of Pingback comments has been removed.', 'Import-Users'), |
| 236 |
'db_trackbackMsg' => __('no of Trackback comments has been removed.', 'Import-Users'), |
| 237 |
) ); |
| 238 |
wp_register_script('bootstrap-js', plugins_url('assets/js/bootstrap.js', __FILE__)); |
| 239 |
wp_enqueue_script('bootstrap-js'); |
| 240 |
wp_register_script('bootstrap-select-js', plugins_url('assets/js/bootstrap-select.js', __FILE__)); |
| 241 |
wp_enqueue_script('bootstrap-select-js'); |
| 242 |
wp_register_script('stickySidebar-js', plugins_url('assets/js/stickySidebar.js', __FILE__)); |
| 243 |
wp_enqueue_script('stickySidebar-js'); |
| 244 |
//new files include close |
| 245 |
wp_register_script('waitme-js', plugins_url('assets/js/waitMe.js', __FILE__)); |
| 246 |
wp_enqueue_script('waitme-js'); |
| 247 |
// Sweet Alert Js |
| 248 |
wp_register_script('sweet-alert-js', plugins_url('assets/js/sweetalert-dev.js', __FILE__)); |
| 249 |
wp_enqueue_script('sweet-alert-js'); |
| 250 |
// Tinymce Editor Js |
| 251 |
wp_register_script('ckeditor-js', plugins_url('assets/js/ckeditor-js/ckeditor.js', __FILE__)); |
| 252 |
wp_enqueue_script('ckeditor-js'); |
| 253 |
//MODAL POP UP JS |
| 254 |
wp_enqueue_script('pop-up',plugins_url('assets/js/modal.js',__FILE__)); |
| 255 |
// Morris chart CSS & JS for dashboard |
| 256 |
if(isset($_REQUEST['page']) && sanitize_text_field($_REQUEST['page']) == 'user-uci-dashboard') { |
| 257 |
wp_enqueue_script( 'chart-utils-js', plugins_url('assets/js/chart-js/utils.js', __FILE__) ); |
| 258 |
wp_enqueue_script( 'uci-dashboard', plugins_url('assets/js/chart-js/Chart.bundle.js', __FILE__) ); |
| 259 |
wp_enqueue_script( 'uci-dashboard-chart', plugins_url( 'assets/js/chart-js/dashchart.js', __FILE__ ) ); |
| 260 |
} |
| 261 |
//new files include |
| 262 |
wp_enqueue_style('custom-new-style', plugins_url('assets/css/custom-new-style.css', __FILE__)); |
| 263 |
} |
| 264 |
wp_enqueue_style('style-maintenance', plugins_url('assets/css/style-maintenance.css', __FILE__)); |
| 265 |
} |
| 266 |
|
| 267 |
/** |
| 268 |
* Init SM_WPUltimateCSVImporterPro when WordPress Initialises. |
| 269 |
*/ |
| 270 |
public function init() { |
| 271 |
if(is_admin()) : |
| 272 |
// Init action. |
| 273 |
do_action( 'uci_init' ); |
| 274 |
if(is_admin()) { |
| 275 |
#$this->includes(); |
| 276 |
User_SmackUCIAdminAjax::smuci_ajax_events(); |
| 277 |
# Removed: De-Register the media sizes |
| 278 |
} |
| 279 |
endif; |
| 280 |
} |
| 281 |
|
| 282 |
public function uci_pro_add_dashboard_widgets(){ |
| 283 |
wp_enqueue_script( 'chart-utils-js', plugins_url('assets/js/chart-js/utils.js', __FILE__) ); |
| 284 |
wp_enqueue_script( 'uci-wp-dash-chart-js', plugins_url('assets/js/chart-js/Chart.bundle.js', __FILE__) ); |
| 285 |
wp_enqueue_script( 'uci-dashboard-chart-widget', plugins_url( 'assets/js/chart-js/dashchart-widget.js', __FILE__ ) ); |
| 286 |
// Add widget on WordPress Dashboard |
| 287 |
$get_current_user = wp_get_current_user(); |
| 288 |
$role = $get_current_user->roles[0]; |
| 289 |
if( $role == "administrator" ) { |
| 290 |
wp_add_dashboard_widget( 'uci_pro_dashboard_linechart', 'Ultimate-CSV-Importer-Pro-Activity', array( |
| 291 |
'User_SmackUCIAdmin', |
| 292 |
'LineChart' |
| 293 |
), $screen = get_current_screen(), 'advanced', 'high' ); |
| 294 |
wp_add_dashboard_widget( 'uci_pro_dashboard_piechart', 'Ultimate-CSV-Importer-Pro-Statistics', array( |
| 295 |
'User_SmackUCIAdmin', |
| 296 |
'PieChart' |
| 297 |
), $screen = get_current_screen(), 'advanced', 'high' ); |
| 298 |
} |
| 299 |
} |
| 300 |
|
| 301 |
/** |
| 302 |
* Get the plugin url. |
| 303 |
* @return string |
| 304 |
*/ |
| 305 |
public function plugin_url() { |
| 306 |
return untrailingslashit( plugins_url( '/', __FILE__ ) ); |
| 307 |
} |
| 308 |
|
| 309 |
/** |
| 310 |
* Get the plugin path. |
| 311 |
* @return string |
| 312 |
*/ |
| 313 |
public function plugin_path() { |
| 314 |
return untrailingslashit( plugin_dir_path( __FILE__ ) ); |
| 315 |
} |
| 316 |
|
| 317 |
/** |
| 318 |
* Get Ajax URL. |
| 319 |
* @return string |
| 320 |
*/ |
| 321 |
public function ajax_url() { |
| 322 |
return admin_url( 'admin-ajax.php', 'relative' ); |
| 323 |
} |
| 324 |
|
| 325 |
/** |
| 326 |
* Email Class. |
| 327 |
* @return USER_SM_UCI_Emails |
| 328 |
*/ |
| 329 |
public function mailer() { |
| 330 |
return USER_SM_UCI_Emails::instance(); |
| 331 |
} |
| 332 |
} |
| 333 |
endif; |
| 334 |
|
| 335 |
|
| 336 |
add_action('plugins_loaded','UserSmackCSVImporterLoadLanguages'); |
| 337 |
function UserSmackCSVImporterLoadLanguages(){ |
| 338 |
$wp_csv_importer_lang_dir = dirname( plugin_basename( __FILE__ ) ) . '/languages/'; |
| 339 |
load_plugin_textdomain( USER_SM_UCI_SLUG , false, $wp_csv_importer_lang_dir ); |
| 340 |
} |
| 341 |
|
| 342 |
|
| 343 |
/** |
| 344 |
* Main instance of WPUltimateCSVImporterPro. |
| 345 |
* |
| 346 |
* Returns the main instance of WC to prevent the need to use globals. |
| 347 |
* |
| 348 |
* @since 5.0 |
| 349 |
* @return WPUltimateCSVImporterPro |
| 350 |
*/ |
| 351 |
function User_SmackUCI() { |
| 352 |
return User_SM_WPUltimateCSVImporter::instance(); |
| 353 |
} |
| 354 |
// Global for backwards compatibility. |
| 355 |
$GLOBALS['wp_ultimate_csv_importer'] = User_SmackUCI(); |
| 356 |
|