="L948" rel="L948"> * @return object of posts and success or fail message
  • */
  • function cdp_get_all_posts() {
  • $output = array();
  • $args = array(
  • 'numberposts' => -1,
  • 'post_type' => 'post',
  • 'post_status' => 'publish,private,draft,future,pending,inherit,sticky'
  • );
  • $output['posts'] = get_posts($args);
  • $args['post_type'] = 'page';
  • $output['pages'] = get_posts($args);
  • $output['custom'] = array();
  • $post_types = get_post_types(array('public' => true, '_builtin' => false));
  • if (sizeof($post_types) > 0)
  • $output['custom'] = get_posts(array(
  • 'post_type' => $post_types,
  • 'numberposts' => -1,
  • 'post_status' => 'publish,private,draft,future,pending,inherit,sticky'
  • ));
  • $output['meta'] = array();
  • foreach ($output['posts'] as $k => $p)
  • $output['meta'][$p->ID] = get_post_meta($p->ID);
  • foreach ($output['pages'] as $k => $p)
  • $output['meta'][$p->ID] = get_post_meta($p->ID);
  • foreach ($output['custom'] as $k => $p)
  • $output['meta'][$p->ID] = get_post_meta($p->ID);
  • echo json_encode(cdp_sanitize_array($output));
  • }
  • /** –– * */
  • /** –– **\
  • * This function will delete all posts in array PERMANENTLY!
  • * @return object of success message or error
  • */
  • function cdp_delete_posts() {
  • $ids = ((isset($_POST['ids'])) ? cdp_sanitize_array($_POST['ids']) : false); // ids to delete
  • $throttling = sanitize_text_field($_POST['throttling']); // throttling if enabeld
  • $thc = sanitize_text_field($_POST['thc']); // throttling count if enabeld
  • $thrs = sanitize_text_field($_POST['thrs']) == 'true' ? true : false; // trash or not?
  • $redi = sanitize_text_field($_POST['redi']) == 'true' ? true : false; // redirect if enabled
  • $auit = sanitize_text_field($_POST['auit']) == 'true' ? true : false; // auit if enabled
  • $auitd = ((isset($_POST['auitd'])) ? cdp_sanitize_array($_POST['auitd']) : false); // auitd if auit enabled
  • $prepared_ids = array();
  • $inGroup = 0;
  • $curr = current_time('timestamp');
  • $token = uniqid($curr, true);
  • $cdp_cron = get_option('_cdp_crons');
  • $site = is_multisite() ? get_current_blog_id() : '-1';
  • if ($cdp_cron == false)
  • $cdp_cron = array();
  • $cdp_cron[$token] = array(
  • 'start' => $curr,
  • 'ids' => $ids,
  • 'done' => false,
  • 'shown' => false,
  • 'f' => 'delete',
  • 'del_size' => sizeof($ids),
  • 'handler' => 'cdp_cron_delete',
  • 'auit' => $auit,
  • 'auitd' => $auitd
  • );
  • $cdp_cron[$token]['tasks'] = array();
  • $cdp_cron[$token]['args'] = array();
  • if ($throttling == '1' && $thc && intval($thc) >= 1 && intval($thc) <= 10240) {
  • $inGroup = ceil(intval($thc) / 30);
  • for ($i = 0, $k = 2; $i < sizeof($ids); $i = $i + $inGroup, $k++)
  • $cdp_cron[$token]['tasks']["-$k"] = false;
  • update_option('_cdp_crons', $cdp_cron);
  • for ($i = 0, $k = 2; $i < sizeof($ids); $i = $i + $inGroup, $k++) {
  • $tg = array();
  • $tt = array('tsk' => "-" . $k, 'token' => $token);
  • for ($j = $i; $j < ($i + $inGroup); $j++)
  • if (isset($ids[$j]))
  • array_push($tg, $ids[$j]);
  • array_push($prepared_ids, $tg);
  • $time = $k * 2;
  • $args = array(array('ids' => $tg, 'site' => $site, 'trash' => $thrs, 'token' => $tt));
  • wp_schedule_single_event(strtotime("+$time seconds"), 'cdp_cron_delete', $args);
  • array_push($cdp_cron[$token]['args'], $args);
  • }
  • } else {
  • $cdp_cron[$token]['tasks']["-0"] = false;
  • update_option('_cdp_crons', $cdp_cron);
  • $tt = array('tsk' => "-0", 'token' => $token);
  • $args = array(array('ids' => $ids, 'site' => $site, 'trash' => $thrs, 'token' => $tt));
  • wp_schedule_single_event(strtotime('+2 seconds'), 'cdp_cron_delete', $args);
  • array_push($cdp_cron[$token]['args'], $args);
  • }
  • echo json_encode(array('status' => 'success', 'token' => cdp_sanitize_array($token)));
  • }
  • /** –– * */
  • /** –– **\
  • * This function will delete all posts in array PERMANENTLY!
  • * @return object of success message or error
  • */
  • function cdp_clear_all_crons() {
  • $cdp_cron = get_option('_cdp_crons');
  • foreach ($cdp_cron as $cron => $val) {
  • if (array_key_exists('done', $val)) {
  • if ($val['done'] != true) {
  • echo json_encode(array(
  • 'status' => 'fail',
  • 'type' => 'warning',
  • 'msg' => __('You can\'t clear messages when tasks are in progress, please firstly kill tasks or wait till the end.', 'copy-delete-posts')
  • ));
  • return;
  • }
  • }
  • }
  • $cdp_cron = delete_option('_cdp_crons');
  • echo json_encode(array('status' => 'success'));
  • }
  • /** –– * */
  • /** –– **\
  • * Local function which sets default profile for user
  • * @return Boolean
  • */
  • function cdp_set_default_profile() {
  • $curr = get_option('_cdp_preselections');
  • $id = get_current_user_id();
  • $new = array();
  • $selection = ((isset($_POST['selection'])) ? cdp_sanitize_array($_POST['selection']) : false);
  • if ($curr && !is_object($curr) || $curr == false)
  • $new = array($id => $selection);
  • else {
  • $new = $curr;
  • $new[$id] = $selection;
  • }
  • $stat = update_option('_cdp_preselections', $new);
  • echo cdp_sanitize_array($stat);
  • }
  • /** –– * */
  • /** –– **\
  • * Local function which gets default profile for user
  • * @return String
  • */
  • function cdp_get_default_profile() {
  • echo(esc_html(get_option('_cdp_preselections')[get_current_user_id()]));
  • }
  • /** –– * */
  • /** –– **\
  • * This function will set as seen notification!
  • * @return object of success message — WARNING: ALWAYS
  • */
  • function cdp_set_noti_as_seen() {
  • if (wp_doing_cron())
  • return;
  • $token = ((isset($_POST['noti_token'])) ? sanitize_text_field($_POST['noti_token']) : false);
  • $cdp_cron = get_option('_cdp_crons', array());
  • $cdp_cron[$token]['shown'] = true;
  • update_option('_cdp_crons', $cdp_cron);
  • echo json_encode(array('status' => 'success'));
  • }
  • /** –– * */
  • /** –– **\
  • * This function will delete task from the history!
  • * @return object of success message or fail
  • */
  • function cdp_just_hide_task() {
  • $token = ((isset($_POST['task'])) ? sanitize_text_field($_POST['task']) : false);
  • $cdp_cron = get_option('_cdp_crons', array());
  • unset($cdp_cron[$token]);
  • $res = update_option('_cdp_crons', $cdp_cron);
  • if ($res)
  • echo json_encode(array('status' => 'success'));
  • else
  • echo json_encode(array('status' => 'fail', 'type' => 'error', 'msg' => __('We can\'t hide this task now, – maybe it\'t already hidden. Please try again later.', 'copy-delete-posts')));
  • }
  • /** –– * */
  • /** –– **\
  • * This function will kill task from the cron!
  • * @return object of success message or fail
  • */
  • function cdp_just_kill_task() {
  • $token = ((isset($_POST['task'])) ? sanitize_text_field($_POST['task']) : false);
  • $cdp_cron = get_option('_cdp_crons', array());
  • $handler = $cdp_cron[$token]['handler'];
  • $args = (array_key_exists('args', $cdp_cron[$token]) ? $cdp_cron[$token]['args'] : array());
  • if ($cdp_cron[$token]['done'] != false) {
  • echo json_encode(array('status' => 'fail', 'type' => 'error', 'msg' => __('This task has already ended this work, please wait for list refresh and try again.', 'copy-delete-posts')));
  • return;
  • }
  • $status = true;
  • $res = false;
  • foreach ($args as $arg => $val) {
  • $sres = wp_clear_scheduled_hook($handler, $val);
  • if ($sres == false)
  • $status = false;
  • }
  • if ($cdp_cron[$token]['done'] != false)
  • $status = true;
  • if ($status == true) {
  • unset($cdp_cron[$token]);
  • $res = update_option('_cdp_crons', $cdp_cron);
  • }
  • if ($status || $res)
  • echo json_encode(array('status' => 'success'));
  • else
  • echo json_encode(array('status' => 'fail', 'type' => 'error', 'msg' => __('We can\'t confirm that we killed this task now, please try again later or check if it\'t killed.', 'copy-delete-posts')));
  • }
  • /** –– * */
  • /** –– **\
  • * This function will catch current cron tasks!
  • * @return object of tasks or fail
  • */
  • function cdp_just_get_tasks() {
  • $cdp_cron = get_option('_cdp_crons', false);
  • if ($cdp_cron)
  • echo json_encode(array('status' => 'success', 'tasks' => cdp_sanitize_array($cdp_cron)));
  • else
  • echo json_encode(array('status' => 'fail', 'type' => 'error', 'msg' => __('We couldn\'t catch current tasks, please try again later.', 'copy-delete-posts')));
  • }
  • /** –– * */
  • /** –– **\
  • * This function will remove performance notice
  • * @return void
  • */
  • function cdp_hide_perf_notice() {
  • update_option('cdp_dismiss_perf_notice', true);
  • update_option('cdp_latest_slow_performance', false);
  • echo json_encode(array('status' => 'success'));
  • }
  • /** –– * */
  • /** –– **\
  • * This function is just for debug have fun with it!
  • * It can be fired by function cdp_totally_know_what_i_am_doing('really');
  • * It won't work in production mode so dont even try it, if you're not me ~ Mikołaj :P
  • * @return mixed
  • */
  • function cdp_debug_function() {
  • // require_once('C:/Developer/Web/wordpress/wp-content/plugins/copy-delete-posts-premium/classes/methods.php');
  • // $settings = get_option('cdpp_aci_settings', false);
  • // $meth = new CDP_Premium($settings);
  • // $posts = $meth->load_posts($settings['scan']);
  • // $filtred = $meth->filter_posts($posts);
  • $cdp_cron = get_option('_cdp_crons', false);
  • $things_to_debug = array(
  • '$cdp_cron' => $cdp_cron
  • );
  • var_export($things_to_debug);
  • }
  • /** –– **/
  • tmt/tiger_frontend - Gogs: Simplico Git Service

    Geen omschrijving

    golf 77628cf8bf first comm 2 jaren geleden
    ..
    index.js 77628cf8bf first comm 2 jaren geleden
    parse.js 77628cf8bf first comm 2 jaren geleden
    parseValues.js 77628cf8bf first comm 2 jaren geleden
    stringify.js 77628cf8bf first comm 2 jaren geleden
    stringifyValues.js 77628cf8bf first comm 2 jaren geleden
    uni-regexp.js 77628cf8bf first comm 2 jaren geleden