'ovgxe3xq075ladbp', 'client-secret' => 'b4de5ed2ba7be687e233d152ec1e8fd116052ab0', 'base-dir' => __FILE__ )); /** –– * */ /** –– **\ * Global variables and constants. * @since 1.0.0 */ // Plugin constants define('CDP_VERSION', '1.5.0'); define('CDP_WP_VERSION', get_bloginfo('version')); define('CDP_SCRIPT_DEBUG', false); define('CDP_ROOT_DIR', __DIR__); define('CDP_ROOT_FILE', __FILE__); define('CDP_MODULES_DIR', CDP_ROOT_DIR . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR); $cdp_plug_url = plugins_url('', __FILE__); // Other only admin stuff if (is_admin()) { // Set constant variables for this file $cdp_dir = dirname(__FILE__); $cdp_globals = get_option('_cdp_globals'); $cdp_premium = 'copy-delete-posts-premium/copy-delete-posts-premium.php'; // Try to show error while debugging if (CDP_SCRIPT_DEBUG === true) { error_reporting(E_ALL); ini_set('display_errors', 1); } } /** –– * */ /** –– **\ * Fired on plugin activation. * @since 1.0.0 */ register_activation_hook(__FILE__, function () { if (function_exists('activate_plugin')) { add_option('_cdp_redirect', true); $cdp_premium_path = WP_PLUGIN_DIR . '/copy-delete-posts-premium'; $plugin = 'copy-delete-posts-premium/copy-delete-posts-premium.php'; if (!is_plugin_active($plugin) && is_dir($cdp_premium_path)) activate_plugin($plugin); } if (get_option('_cdp_review', false) == false) { $review = array( 'installed' => time(), 'users' => array() ); update_option('_cdp_review', $review); } do_action('cdp_plugin_setup'); }); /** –– * */ /** –– **\ * Fired on plugin deactivation. * @since 1.0.0 */ register_deactivation_hook(__FILE__, function () { if (function_exists('deactivate_plugins')) { $plugin = 'copy-delete-posts-premium/copy-delete-posts-premium.php'; if (is_plugin_active($plugin)) add_action('update_option_active_plugins', function () { $plugin = 'copy-delete-posts-premium/copy-delete-posts-premium.php'; deactivate_plugins($plugin); }); } }); /** –– * */ /** –– **\ * Fired on plugin load and check permissions. * @since 1.0.0 */ add_action('plugins_loaded', function () { do_action('cdp_loaded'); }); /** –– * */ /** –– **\ * Fired on any plugin upgrade (in case if it's ours) * @since 1.0.6 */ add_action('upgrader_process_complete', function () { if (get_option('_cdp_review', false) == false) { $review = array( 'installed' => time(), 'users' => array() ); update_option('_cdp_review', $review); } }); /** –– * */ /** –– **\ * Include all menus. * @since 1.0.0 */ add_action('cdp_loaded', function () { if (get_option('_cdp_globals', false) === false) { do_action('cdp_plugin_setup'); } // Include footer banner include_once trailingslashit(__DIR__) . '/banner/misc.php'; // Others if (cdp_check_permissions(wp_get_current_user()) == false) return; require_once plugin_dir_path(__FILE__) . 'menu/configuration.php'; require_once plugin_dir_path(__FILE__) . 'menu/tooltips.php'; require_once plugin_dir_path(__FILE__) . 'menu/variables.php'; require_once plugin_dir_path(__FILE__) . 'menu/modal.php'; require_once plugin_dir_path(__FILE__) . 'menu/notifications.php'; require_once plugin_dir_path(__FILE__) . 'post/handler.php'; // Review banner if (!is_dir(WP_PLUGIN_DIR . '/copy-delete-posts-premium')) { if (!(class_exists('Inisev\Subs\Inisev_Review') || class_exists('Inisev_Review'))) require_once CDP_ROOT_DIR . '/modules/review/review.php'; $review_banner = new \Inisev\Subs\Inisev_Review(CDP_ROOT_FILE, CDP_ROOT_DIR, 'copy-delete-posts', 'Copy & Delete Posts', 'https://bit.ly/2VeAf2E', 'copy-delete-posts'); } }); /** –– **/ /** –– **\ * Admin Init * @since 1.0.0 */ add_action('admin_init', function () { if (cdp_check_permissions(wp_get_current_user()) == false) return; if (get_option('_cdp_redirect', false)) { delete_option('_cdp_redirect', false); wp_redirect(admin_url('admin.php?page=copy-delete-posts')); } global $cdp_premium; $cdp_premium_path = WP_PLUGIN_DIR . '/copy-delete-posts-premium'; $cdp_premium_ver_path = WP_PLUGIN_DIR . '/copy-delete-posts-premium/version.txt'; if (defined('CDP_PREMIUM_VERSION') && version_compare(CDP_PREMIUM_VERSION, CDP_VERSION, '!=')) { update_option('_cdp_mishmash', true); } else { if (is_dir($cdp_premium_path) && file_exists($cdp_premium_ver_path)) { $cdp_prem_ver_file = fopen($cdp_premium_ver_path, 'r') or false; $cdp_prem_ver = fgets($cdp_prem_ver_file); fclose($cdp_prem_ver_file); if ((trim($cdp_prem_ver) == CDP_VERSION) && !is_plugin_active($cdp_premium)) { activate_plugin($cdp_premium, '', false, true); // add_option('_cdp_redirect', false); } if (trim($cdp_prem_ver) == CDP_VERSION) update_option('_cdp_mishmash', false); } } if (is_plugin_active($cdp_premium) && !file_exists($cdp_premium_ver_path)) { if (is_plugin_active($cdp_premium)) deactivate_plugins($cdp_premium, true); } }); /** –– * */ /** –– **\ * Setup assets. * @since 1.0.0 */ add_action('admin_enqueue_scripts', function () { if (cdp_check_permissions(wp_get_current_user()) == false) return; if (function_exists('wp_doing_ajax') && wp_doing_ajax()) return; global $cdp_plug_url; global $pagenow, $post; $screen = get_current_screen(); $min = defined('CDP_SCRIPT_DEBUG') && CDP_SCRIPT_DEBUG ? '' : '.min'; $allowed = ['post', 'edit-post', 'toplevel_page_copy-delete-posts', 'edit-page', 'page']; $at = ($screen->id != 'attachment'); $g = get_option('_cdp_globals', array()); if (isset($g['others'])) { $g = $g['others']; } else { $g = cdp_default_global_options(); } if (is_object($post)) $type = $post->post_type; else $type = false; if (isset($g['cdp-menu-in-settings']) && $g['cdp-menu-in-settings'] == 'true') { ?> is_block_editor() && $pagenow == 'post.php' && $at) { if (isset($g['cdp-display-edit']) && isset($g['cdp-content-posts']) && isset($g['cdp-content-pages']) && isset($g['cdp-content-custom']) && $g['cdp-display-edit'] == 'true') { $a = ($type == 'post' && $g['cdp-content-posts'] == 'true'); $b = ($type == 'page' && $g['cdp-content-pages'] == 'true'); $c = ($type != 'post' && $type != 'page' && $g['cdp-content-custom'] == 'true'); if (($a || $b || $c) && $pagenow != 'post-new.php') wp_enqueue_style('cdp-editor', "{$cdp_plug_url}/assets/css/cdp-editor{$min}.css", '', $ver); } } } $ver = preg_replace('#[^\pL\pN/-]+#', '', CDP_VERSION); if ((!$screen || !in_array($screen->id, $allowed)) && !($pagenow == 'edit.php' || $pagenow == 'post.php')) return; wp_enqueue_style('cdp-css', "{$cdp_plug_url}/assets/css/cdp{$min}.css", '', $ver); wp_enqueue_style('cdp-css-user', "{$cdp_plug_url}/assets/css/cdp-user{$min}.css", '', $ver); wp_enqueue_script('cdp-icPagination', "{$cdp_plug_url}/assets/js/cdp-icPagination{$min}.js", '', $ver); wp_enqueue_script('cdp', "{$cdp_plug_url}/assets/js/cdp{$min}.js", '', $ver, true); wp_enqueue_script('cdp-modal', "{$cdp_plug_url}/assets/js/cdp-modal{$min}.js", '', $ver, true); if (isset($g['cdp-content-custom']) && $g['cdp-content-custom'] == 'true') { wp_enqueue_script('cdp-bulk', "{$cdp_plug_url}/assets/js/cdp-bulk{$min}.js", '', $ver, true); $cdpBulkJSArgs = ['strOptCopy' => __('Copy', 'copy-delete-posts')]; wp_localize_script('cdp-bulk', 'cdpBulkJS', $cdpBulkJSArgs); } cdp_load_localize_end_js(); }, 1000); /** –– * */ /** –– **\ * Setup assets (not admin). * @since 1.0.0 */ add_action('wp_enqueue_scripts', function () { if (cdp_check_permissions(wp_get_current_user()) == false) return; if ((function_exists('wp_doing_ajax') && wp_doing_ajax()) || (!(is_single() || is_page()))) return; global $cdp_plug_url; $ver = preg_replace('#[^\pL\pN/-]+#', '', CDP_VERSION); $min = defined('CDP_SCRIPT_DEBUG') && CDP_SCRIPT_DEBUG ? '' : '.min'; wp_enqueue_script('jquery-ui-draggable'); wp_enqueue_script('jquery-ui-droppable'); wp_enqueue_script('jquery-ui-sortable'); wp_enqueue_style('cdp-css-global', "{$cdp_plug_url}/assets/css/cdp-global{$min}.css", '', $ver); wp_enqueue_script('cdp-js-global', "{$cdp_plug_url}/assets/js/cdp-global{$min}.js", ['jquery'], $ver, true); wp_enqueue_style('cdp-css', "{$cdp_plug_url}/assets/css/cdp{$min}.css", '', $ver); wp_enqueue_style('cdp-css-user', "{$cdp_plug_url}/assets/css/cdp-user{$min}.css", '', $ver); wp_enqueue_script('cdp', "{$cdp_plug_url}/assets/js/cdp{$min}.js", ['jquery'], $ver, true); wp_enqueue_script('cdp-tooltips', "{$cdp_plug_url}/assets/js/cdp.tooltip{$min}.js", '', $ver, true); wp_enqueue_style('cdp-tooltips-css', "{$cdp_plug_url}/assets/css/cdp.tooltip{$min}.css", '', $ver); wp_enqueue_script('cdp-modal', "{$cdp_plug_url}/assets/js/cdp-modal{$min}.js", ['jquery'], $ver, true); wp_enqueue_script('cdp-js-user', "{$cdp_plug_url}/assets/js/cdp-user{$min}.js", '', $ver, true); wp_enqueue_style('cdp-css-select', "{$cdp_plug_url}/assets/css/cdp-select{$min}.css", '', $ver); wp_enqueue_script('cdp-js-select', "{$cdp_plug_url}/assets/js/cdp-select{$min}.js", '', $ver, true); cdp_load_localize_global_js(); cdp_load_localize_end_js(); }); /** –– * */ /** –– **\ * Setup assets (for gutenberg). * @since 1.0.0 */ add_action('enqueue_block_editor_assets', function () { if (cdp_check_permissions(wp_get_current_user()) == false) return; global $post; global $cdp_plug_url; $min = defined('CDP_SCRIPT_DEBUG') && CDP_SCRIPT_DEBUG ? '' : '.min'; $g = get_option('_cdp_globals', array()); if (isset($g['others'])) { $g = $g['others']; } else { $g = cdp_default_global_options(); } $ver = preg_replace('#[^\pL\pN/-]+#', '', CDP_VERSION); if (is_object($post)) { $type = $post->post_type; } else { $type = false; } $a = ($type == 'post' && (isset($g['cdp-content-posts']) && $g['cdp-content-posts'] == 'true')); $b = ($type == 'page' && (isset($g['cdp-content-pages']) && $g['cdp-content-pages'] == 'true')); $c = ($type != 'post' && $type != 'page' && (isset($g['cdp-content-custom']) && $g['cdp-content-custom'] == 'true')); if ((isset($g['cdp-display-gutenberg']) && $g['cdp-display-gutenberg'] == 'true') && ($a || $b || $c)) { wp_enqueue_style('cdp-gutenberg', "{$cdp_plug_url}/assets/css/cdp-gutenberg{$min}.css", '', $ver); wp_enqueue_script('cdp-js-gutenberg', "{$cdp_plug_url}/assets/js/cdp-gutenberg{$min}.js", ['jquery'], $ver, true); $cdpGutenbergJSArgs = ['cdpCopy' => __('Copy this', 'copy-delete-posts')]; wp_localize_script('cdp-js-gutenberg', 'cdpGutenbergJS', $cdpGutenbergJSArgs); } }); /** –– * */ /** –– **\ * Settings and menu initializer. * @since 1.0.0 */ add_action('admin_menu', function () { if (cdp_check_permissions(wp_get_current_user()) == false) return; // Menu icon $icon_url = plugin_dir_url(__FILE__) . 'assets/imgs/icon.png'; // Main menu slug $parentSlug = 'copy-delete-posts'; // Globals $g = get_option('_cdp_globals', array()); if (isset($g['others'])) { $g = $g['others']; } else { $g = cdp_default_global_options(); } // Main menu hook add_menu_page(__('Copy & Delete Posts', 'copy-delete-posts'), __('', 'copy-delete-posts'), 'read', $parentSlug, 'cdp_configuration', $icon_url, $position = 98); if (isset($g['cdp-menu-in-settings']) && $g['cdp-menu-in-settings'] == 'true') { add_submenu_page('tools.php', __('Copy & Delete Posts Menu', 'copy-delete-posts'), __('', 'copy-delete-posts'), 'read', 'copy-delete-posts', 'cdp_configuration', 3); } // Remove default submenu by menu remove_submenu_page($parentSlug, $parentSlug); }); /** –– * */ /** –– **\ * Add cdp scripts and styles to the whitelist of mailpoet. * @since 1.5.0 */ add_filter('mailpoet_conflict_resolver_whitelist_style', function ($whitelist) { // Add your plugin's unique identifier or path to the whitelist $whitelist[] = 'cdp'; return $whitelist; }); /** –– **\ * Add copy option to Quick Actions of Posts. * @since 1.0.0 */ add_filter('post_row_actions', function ($actions, $post) { if (cdp_check_permissions(wp_get_current_user()) == false) return $actions; // Get global options and post type $g = get_option('_cdp_globals', array()); if (isset($g['others'])) { $g = $g['others']; } else { $g = cdp_default_global_options(); } $type = $post->post_type; // If user want to see the copy buton here pass if (isset($g['cdp-display-posts']) && $g['cdp-display-posts'] == 'true') { if (($type == 'post' && isset($g['cdp-content-posts']) && $g['cdp-content-posts'] == 'true') || ($type != 'post' && isset($g['cdp-content-custom']) && $g['cdp-content-custom'] == 'true')) { $actions['cdp_copy'] = ""; } } return $actions; }, 10, 2); /** –– * */ /** –– **\ * Add copy option to Quick Actions of Pages. * @since 1.0.0 */ add_filter('page_row_actions', function ($actions, $page) { if (cdp_check_permissions(wp_get_current_user()) == false) { return $actions; } // Get global options and post type $g = get_option('_cdp_globals', array()); if (isset($g['others'])) { $g = $g['others']; } else { $g = cdp_default_global_options(); } $type = $page->post_type; // If user want to see the copy buton here pass if (isset($g['cdp-display-posts']) && $g['cdp-display-posts'] == 'true') { if (($type == 'page' && $g['cdp-content-pages'] == 'true') || ($type != 'page' && $g['cdp-content-custom'] == 'true')) { $actions['cdp_copy'] = ""; } } return $actions; }, 10, 2); /** –– * */ /** –– **\ * Add copy option to Bulk Actions of Posts. * @since 1.0.0 */ add_filter('bulk_actions-edit-post', function ($bulk_actions) { if (cdp_check_permissions(wp_get_current_user()) == false) return; $g = get_option('_cdp_globals', array()); if (isset($g['others'])) { $g = $g['others']; } else { $g = cdp_default_global_options(); } if (isset($g['cdp-display-bulk']) && $g['cdp-display-bulk'] == 'true' && isset($g['cdp-content-posts']) && $g['cdp-content-posts'] == 'true') { $bulk_actions['cdp_bulk_copy'] = __('Copy', 'copy-delete-posts'); } return $bulk_actions; }); /** –– * */ /** –– **\ * Add copy option to Bulk Actions of Pages. * @since 1.0.0 */ add_filter('bulk_actions-edit-page', function ($bulk_actions) { if (cdp_check_permissions(wp_get_current_user()) == false) return; $g = get_option('_cdp_globals', array()); if (isset($g['others'])) { $g = $g['others']; } else { $g = cdp_default_global_options(); } if (isset($g['cdp-display-bulk']) && $g['cdp-display-bulk'] == 'true' && isset($g['cdp-content-pages']) && $g['cdp-content-pages'] == 'true') { $bulk_actions['cdp_bulk_copy'] = __('Copy', 'copy-delete-posts'); } return $bulk_actions; }); /** –– * */ /** –– **\ * Add copy option to admin bar inside preview. * @since 1.0.0 */ add_action('admin_bar_menu', function ($admin_bar) { if (cdp_check_permissions(wp_get_current_user()) == false) { return; } $screen = ((function_exists('get_current_screen') ? get_current_screen() : false)); $screens = ['post', 'page']; if (!(is_single() || is_page() || (isset($screen) && ($screen != false && in_array($screen->id, $screens))))) { return; } $g = get_option('_cdp_globals', array()); if (isset($g['others'])) { $g = $g['others']; } else { $g = cdp_default_global_options(); } global $post; if (is_object($post)) { $type = $post->post_type; } else { $type = false; } $a = ($type == 'post' && (isset($g['cdp-content-posts']) && $g['cdp-content-posts'] == 'true')); $b = ($type == 'page' && (isset($g['cdp-content-pages']) && $g['cdp-content-pages'] == 'true')); $c = ($type != 'post' && $type != 'page' && (isset($g['cdp-content-custom']) && $g['cdp-content-custom'] == 'true')); if (isset($g['cdp-display-admin']) && $g['cdp-display-admin'] == 'false') { return; } global $cdp_plug_url; if ($a || $b || $c) { $icon = ''; $admin_bar->add_menu(array( 'id' => 'cdp-copy-bar-x', 'parent' => null, 'group' => null, 'title' => $icon . __('Copy this', 'copy-delete-posts'), 'href' => '#', 'meta' => array('class' => 'cdp-admin-bar-copy', 'target' => '_self') )); } }, 80); /** –– * */ /** –– **\ * Add notification to admin bar. * @since 1.0.0 */ add_action('admin_bar_menu', function ($admin_bar) { if (cdp_check_permissions(wp_get_current_user()) == false) return; if (!is_admin()) return; if (!function_exists('cdp_notifications_menu')) require_once plugin_dir_path(__FILE__) . 'menu/notifications.php'; if (function_exists('cdp_notifications_menu')) { $data = cdp_notifications_menu(); $admin_bar->add_menu(array( 'id' => 'wp-admin-copy-and-delete-posts', 'parent' => null, 'group' => null, 'title' => $data['html'], 'href' => '#', 'meta' => array( 'class' => 'cdp-admin-bar-noti menupop' . (($data['in_list'] == 0) ? ' cdp-noti-hide' : ''), 'target' => '_self' ) )); } }, 80); /** –– * */ /** –– **\ * This function adds version info. * @since 1.0.0 */ add_action('wp_head', function () { echo ''; }); /** –– * */ /** –– **\ * This function adds thickbox modal to preview and view pages. * @since 1.0.0 */ add_action('wp_footer', function () { if (cdp_check_permissions(wp_get_current_user()) == false) return; $g = get_option('_cdp_globals', array()); if (isset($g['others'])) { $g = $g['others']; } else { $g = cdp_default_global_options(); } if (isset($g['cdp-display-admin']) && $g['cdp-display-admin'] == 'false') return; global $cdp_plug_url, $post; $post_id = false; if (isset($post->ID)) $post_id = $post->ID; $screen = ((function_exists('get_current_screen')) ? get_current_screen() : false); $profiles = get_option('_cdp_profiles'); if (is_single() || is_page()) { $hx = false; if (isset($g['cdp-premium-hide-tooltip']) && $g['cdp-premium-hide-tooltip'] == 'true') { $hx = true; } cdp_vars($hx, $cdp_plug_url, $post_id); cdp_modal($screen, $profiles); } }); /** –– * */ /** –– **\ * Add prepared HTML for tooltips and other info. * @since 1.0.0 */ add_action('admin_init', function () { add_action('admin_notices', function () { if (cdp_check_permissions(wp_get_current_user()) == false) return; global $post, $cdp_plug_url, $cdp_globals, $pagenow; $post_id = false; $hasParent = false; $screen = get_current_screen(); $profiles = get_option('_cdp_profiles', array()); $deny = ['edit-page', 'edit-post']; $hx = false; if (!in_array($screen->id, $deny)) { if (isset($post->ID)) { $post_id = $post->ID; $meta = get_post_meta($post->ID, '_cdp_origin'); $site = get_post_meta($post->ID, '_cdp_origin_site'); if ($cdp_globals && isset($cdp_globals['others']) && isset($cdp_globals['others']['cdp-references-post'])) { if ($cdp_globals['others']['cdp-references-edit'] == 'true') { if (function_exists('switch_to_blog') && $site) switch_to_blog($site); if (isset($meta[0]) && get_post_status($meta[0])) { $parentTitle = get_the_title($meta[0]); $link = get_post_permalink($meta[0]); $hasParent = array( 'title' => $parentTitle, 'link' => $link ); } if (function_exists('restore_current_blog') && $site) restore_current_blog(); } } } } if ($cdp_globals && isset($cdp_globals['others']) && isset($cdp_globals['others']['cdp-premium-hide-tooltip']) && $cdp_globals['others']['cdp-premium-hide-tooltip'] == 'true') { $hx = true; } if (get_option('_cdp_show_copy', false)) { echo ''; delete_option('_cdp_show_copy'); } if ($pagenow == 'edit.php') $post_id = false; cdp_vars($hx, $cdp_plug_url, $post_id, $hasParent, true); cdp_tooltip_content($profiles); cdp_modal($screen, $profiles); }); }, 10000); /** –– * */ /** –– **\ * Add button in standard editor. * @since 1.0.0 */ add_action('post_submitbox_start', function () { if (cdp_check_permissions(wp_get_current_user()) == false) return; $g = get_option('_cdp_globals', array()); if (isset($g['others'])) { $g = $g['others']; } else { $g = cdp_default_global_options(); } if (isset($g['cdp-display-edit']) && $g['cdp-display-edit'] == 'false') { return; } global $post, $pagenow; if (is_object($post)) { $type = $post->post_type; } else { $type = false; } $a = ($type == 'post' && (isset($g['cdp-content-posts']) && $g['cdp-content-posts'] == 'true')); $b = ($type == 'page' && (isset($g['cdp-content-pages']) && $g['cdp-content-pages'] == 'true')); $c = ($type != 'post' && $type != 'page' && (isset($g['cdp-content-custom']) && $g['cdp-content-custom'] == 'true')); if (($a || $b || $c) && $pagenow != 'post-new.php') echo '
'; }); /** –– * */ /** –– **\ * Add hook for cron (deletion). * @since 1.0.0 */ add_action('cdp_cron_delete', function ($args = false) { $ids = $args['ids']; $trash = $args['trash']; $site = (isset($args['site'])) ? $args['site'] : '-1'; $tok = $args['token']['token']; $tsk = $args['token']['tsk']; if ($args == false) return; $cdp_cron = get_option('_cdp_crons'); if (!isset($cdp_cron[$tok]) || !$cdp_cron[$tok]) return; $auit = $cdp_cron[$tok]['auit']; $auitd = $cdp_cron[$tok]['auitd']; $areWePro = areWePro(true, '/handler/crons.php', true); if ($auit == true && $areWePro && function_exists('cdpp_make_redirect')) cdpp_make_redirect($ids, $auitd); if ($trash == true && $areWePro && function_exists('cdpp_crons_trash_post')) cdpp_crons_trash_post($ids); else foreach ($ids as $i => $id) wp_delete_post($id, true); $cdp_cron[$tok]['tasks'][$tsk] = current_time('timestamp'); $falsed = false; $last = false; $i = 0; $size = sizeof($cdp_cron[$tok]['tasks']); foreach ($cdp_cron[$tok]['tasks'] as $otsk => $val) { if ($val == false) $falsed = true; $i++; if ($i == ($size - 1)) $last = $otsk; } if ($tsk == '-0' || $last == $tsk || $falsed == false || $cdp_cron[$tok]['tasks'][$last] != false) { $cdp_cron[$tok]['done'] = current_time('timestamp'); $cdp_cron[$tok]['data'] = array('formated-date' => date('d M Y, H:i:s')); if (isset($cdp_cron[$tok]['del_size'])) { $cdp_cron[$tok]['data']['amount'] = $cdp_cron[$tok]['del_size']; $cdp_cron[$tok]['data']['text'] = __('Manual Cleanup removed ', 'copy-delete-posts') . $cdp_cron[$tok]['del_size'] . ' post(s).'; } $cdp_cron[$tok]['shown'] = false; } update_option('_cdp_crons', $cdp_cron); }); /** –– * */ /** –– **\ * Check if user is permmited to use this plugin. * @since 1.0.0 * @param $user = current_user = object * * @return boolean */ function cdp_check_permissions($user = array()) { if (!isset($user) || empty($user)) return false; $access = false; $access_roles = get_option('_cdp_globals'); if (!isset($access_roles['roles'])) $access_roles = array(); foreach ($user->roles as $role => $name) { if ($name == 'administrator' || (isset($access_roles['roles'][$name]) && $access_roles['roles'][$name] == 'true')) { $access = true; break; } } return $access; } /** –– * */ /** –– **\ * First run of the plugin setup default options for Default profile * @since 1.0.0 */ add_action('cdp_plugin_setup', 'cdp_setup_default_profile'); function cdp_setup_default_profile() { $current = get_option('_cdp_globals'); $isSetup = get_option('_cdp_default_setup'); if (($current != false && isset($current['default'])) || $isSetup) return; $already = array(); $globals = array(); $already['default'] = cdp_default_options(); $globals['others'] = cdp_default_global_options(); $s1 = update_option('_cdp_globals', $globals); $s2 = update_option('_cdp_profiles', $already); if ($s1 || $s2) update_option('_cdp_default_setup', true); } /** –– * */ function cdp_load_localize_global_js() { $cdpGlobalJSArgs = [ 'strDissmisIssue' => __('There was an issue while dismissing banner, please do it next time again.', 'copy-delete-posts'), 'strDissmisRequestIssue' => __('Cannot send dismiss request. Are you connected to the internet?', 'copy-delete-posts'), 'strReviewReview' => __('Thank you very much for the review, this banner will not appear again!', 'copy-delete-posts'), 'strReviewAlready' => __('Thank you very much for the review, this banner will not appear again!', 'copy-delete-posts'), 'strReviewLater' => __('Alright! We will ask you again in 14 days!', 'copy-delete-posts'), 'strReviewDefault' => __('This banner will not appear again, if any feature is missing you can ask for it on our support forum!', 'copy-delete-posts'), 'strTasksCleared' => __('Tasks cleared!', 'copy-delete-posts'), 'strTasksUpdateIssue' => __('We couldn\'t update task list, please try again later or kill tasks individualy.', 'copy-delete-posts'), 'strTasksUpdateIssue2' => __('We couldn\'t update task list, please try again later or kill tasks individualy.', 'copy-delete-posts'), 'strTaskHide' => __('The task has been hidden', 'copy-delete-posts'), 'strTaskHideIssue' => __('There was an error and we couldn\'t hide the task.', 'copy-delete-posts'), 'strTaskHideIssue2' => __('There was an error and we couldn\'t hide the task.', 'copy-delete-posts'), 'strTaskKill' => __('The task has been killed', 'copy-delete-posts'), 'strTaskKillIssue' => __('There was an error and we couldn\'t kill the task.', 'copy-delete-posts'), 'strTaskKillIssue2' => __('There was an error and we couldn\'t kill the task.', 'copy-delete-posts'), 'strCDPInstallSuccess' => __('Plugin has been installed successfully, feel free to check those awesome features!', 'copy-delete-posts'), 'strCDPInfo' => __('Copy & Delete Posts', 'copy-delete-posts'), 'strCDPInfoPremium' => __('Premium', 'copy-delete-posts'), 'strHideBannerNow' => __('It will hide this banner just for now.', 'copy-delete-posts'), 'strErrWithNotif' => __('There was an error with this notification.', 'copy-delete-posts'), 'strCDPInfo2' => __('Copy & Delete Posts', 'copy-delete-posts'), 'ajaxNonce' => wp_create_nonce('copy-delete-posts-ajax') ]; wp_localize_script('cdp-js-global', 'cdpGlobalJS', $cdpGlobalJSArgs); } function cdp_load_localize_end_js() { $cdpJSArgs = [ 'strNoItems' => __('No items to show, try with other filters!', 'copy-delete-posts'), 'strIntroSaveIssue' => __('Something went wrong and we couldn\'t save intro settings!', 'copy-delete-posts'), 'strIntroSaveIssue2' => __('Something went wrong and we couldn\'t save intro settings.', 'copy-delete-posts'), 'strIntroUpdateIssue' => __('Something went wrong and we couldn\'t update intro settings – try again!', 'copy-delete-posts'), 'strIntroUpdateIssue2' => __('Something went wrong and we couldn\'t update intro settings. – Please check console for more info.', 'copy-delete-posts'), 'strSettingsSaved' => __('All your settings were saved!', 'copy-delete-posts'), 'strSettingsSaveIssue' => __('Something went wrong and we couldn\'t save your settings.', 'copy-delete-posts'), 'strSettingsSaveIssue2' => __('Something went wrong and we couldn\'t save your settings. – Please check console for more info.', 'copy-delete-posts'), 'strTogglableName' => __('(Name of original)', 'copy-delete-posts'), 'strCopyNumIssue' => __('You need to insert positive number for copies.', 'copy-delete-posts'), 'strCopyPostIssue' => __('Something went wrong and we couldn\'t copy this post – please try again!', 'copy-delete-posts'), 'strCopyPostIssueConsInfo' => __('Something went wrong and we couldn\'t copy this post. – See dev console for more info.', 'copy-delete-posts'), 'strTooltipBtnIssue' => __('Couldn\'t recognize that button, please try again.', 'copy-delete-posts'), 'strSelectedProfIssue' => __('Unable to recognize selected profile, please try again.', 'copy-delete-posts'), 'strSelectedProfGetIssue' => __('Something went wrong and we couldn\'t get profile settings. – Check console for more details', 'copy-delete-posts'), 'strConsLogErr' => __('Copy & Delete Post – Error', 'copy-delete-posts'), 'strSelectedProfGetIssue2' => __('Something went wrong and we couldn\'t get profile settings – please try again!', 'copy-delete-posts'), 'strCopyInProgress' => __('Copy in progress...', 'copy-delete-posts'), 'strServerDataIssue' => __('There was an error while getting data from server, please try again.', 'copy-delete-posts'), 'strPostListIssue' => __('Something went wrong and we couldn\'t get post list. – Please check console for more info.', 'copy-delete-posts'), 'strCheckDuplicatesSearch' => __('Please, check for: which duplicates you are looking for', 'copy-delete-posts'), 'strServerConnectIssue' => __('Cannot connect to the server, premium filters will not be applied.', 'copy-delete-posts'), 'strFilterNotSelected' => __('You did not select any filter.