function wpduact_users_bulk_action()
{
    if (!current_user_can('activate_plugins')) {
        return;
    }
    $wp_list_table = _get_list_table('WP_Users_List_Table');
    $action = $wp_list_table->current_action();
    switch ($action) {
        case 'wpduact_deactivate_account':
            $user_ids = $_GET['users'];
            $deactivated = 0;
            foreach ($user_ids as $user_id) {
                if (get_current_user_id() != $user_id) {
                    update_user_meta($user_id, 'wpduact_status', 'inactive');
                    $deactivated++;
                }
            }
            $sendback = add_query_arg(array('deactivated' => $deactivated), $sendback);
            break;
        case 'wpduact_activate_account':
            $user_ids = $_GET['users'];
            $activated = 0;
            foreach ($user_ids as $user_id) {
                update_user_meta($user_id, 'wpduact_status', 'active');
                $activated++;
            }
            $sendback = add_query_arg(array('activated' => $activated), $sendback);
            break;
        default:
            return;
    }
    wp_redirect($sendback);
    exit;
}
Example #2
0
function github_theme_update_row($theme_key, $theme)
{
    $current = get_site_transient('update_themes');
    if (!isset($current->response[$theme_key]) and !isset($current->up_to_date[$theme_key])) {
        return false;
    }
    $r = $current->response[$theme_key];
    $wp_list_table = _get_list_table('WP_MS_Themes_List_Table');
    // custom additions
    if (isset($r['error'])) {
        echo '<tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message-gtu update-error">';
        printf('Error with Github Theme Updater. %1$s', $r['error']);
    } else {
        if (isset($current->up_to_date[$theme_key])) {
        } else {
            $themes_allowedtags = array('a' => array('href' => array(), 'title' => array()), 'abbr' => array('title' => array()), 'acronym' => array('title' => array()), 'code' => array(), 'em' => array(), 'strong' => array());
            $theme_name = wp_kses($theme['Name'], $themes_allowedtags);
            $github_url = esc_url($r['url']);
            $diff_url = esc_url($r['url'] . '/compare/' . $theme['Version'] . '...' . $r['new_version']);
            echo '<tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message-gtu">';
            printf('Github has as a new version of <a href="%s" target="blank">%s</a>. ', $github_url, $theme_name);
            printf('View <a href="%s" target="blank">version diff</a> with %s. ', $diff_url, $r['new_version']);
            if (current_user_can('update_themes')) {
                if (empty($r['package'])) {
                    echo '<em>Automatic update is unavailable for this plugin.</em>';
                } else {
                    printf('<a href="%s">Update automatically</a>.', wp_nonce_url(self_admin_url('update.php?action=upgrade-github-theme&theme=') . $theme_key, 'upgrade-theme_' . $theme_key));
                }
            }
        }
    }
    do_action("in_theme_update_message-{$theme_key}", $theme, $r);
    echo '</div></td></tr>';
}
 function setUp()
 {
     parent::setUp();
     set_current_screen('edit-page');
     $GLOBALS['hook_suffix'] = '';
     $this->table = _get_list_table('WP_Posts_List_Table');
 }
 /**
  * Runs the appropriate callback handler
  *
  * @return void
  */
 private static function runCallbacks()
 {
     // 0. get the action
     $wp_list_table = _get_list_table('WP_Posts_List_Table');
     $action = $wp_list_table->current_action();
     // 1. Get the custom action object
     $bulkAction = self::getCustomBulkAction($action);
     if ($bulkAction === null) {
         return;
     }
     // 2. security check
     check_admin_referer('bulk-posts');
     // Get the post ids
     if (isset($_REQUEST['post'])) {
         $post_ids = array_map('intval', $_REQUEST['post']);
     }
     if (empty($post_ids)) {
         return;
     }
     // Run the callback
     $callback = $bulkAction->getCallback();
     $callback($post_ids);
     // Build the redirect url. Add all id's to the query args
     $sendback = remove_query_arg(array('untrashed', 'deleted', 'ids'), wp_get_referer());
     $sendback = add_query_arg(array('ids' => join(',', $post_ids)), $sendback);
     // 4. Redirect client
     wp_redirect($sendback);
     exit;
 }
Example #5
0
 function pl_custom_bulk_action()
 {
     $wp_list_table = _get_list_table('WP_Posts_List_Table');
     $action = $wp_list_table->current_action();
     switch ($action) {
         case 'pl-template':
             $done = 0;
             $post_ids = $_REQUEST['post'];
             $post_type = $_REQUEST['pl-post-type'];
             $template = $_REQUEST['selected-template'];
             if (!$post_ids || !$template) {
                 return false;
             }
             foreach ($post_ids as $post_id) {
                 $set = pl_meta($post_id, PL_SETTINGS);
                 $set['live']['custom-map']['template']['ctemplate'] = $template;
                 $set['draft']['custom-map']['template']['ctemplate'] = $template;
                 update_post_meta($post_id, PL_SETTINGS, $set);
                 if ('post' == $post_type) {
                     update_post_meta($post_id, 'pl_template_mode', 'local');
                 }
                 $done++;
             }
             $sendback = add_query_arg(array('pl-template' => $done, 'selected-template-name' => $_REQUEST['selected-template-name'], 'ids' => join(',', $post_ids)), admin_url('edit.php?post_type=' . $post_type));
             break;
         default:
             return;
     }
     wp_redirect($sendback);
     exit;
 }
 public function get_comments_async()
 {
     global $wp_list_table;
     $wp_list_table = _get_list_table('WP_Comments_List_Table', array('screen' => 'edit-comments'));
     $wp_list_table->prepare_items();
     ob_start();
     $wp_list_table->views();
     $views = ob_get_clean();
     ob_start();
     $wp_list_table->display_tablenav('top');
     $top = ob_get_clean();
     ob_start();
     $wp_list_table->display_tablenav('bottom');
     $bottom = ob_get_clean();
     ob_start();
     foreach ($wp_list_table->items as $comment) {
         if (!current_user_can('edit_comment', $comment->comment_ID)) {
             continue;
         }
         get_comment($comment);
         $wp_list_table->single_row($comment);
     }
     $rows = ob_get_clean();
     return compact('views', 'rows', 'top', 'bottom');
 }
function ds_npr_bulk_action_update_action()
{
    // 1. get the action
    $wp_list_table = _get_list_table('WP_Posts_List_Table');
    $action = $wp_list_table->current_action();
    switch ($action) {
        // 3. Perform the action
        case 'updateNprStory':
            // make sure ids are submitted.  depending on the resource type, this may be 'media' or 'ids'
            if (isset($_REQUEST['post'])) {
                $post_ids = array_map('intval', $_REQUEST['post']);
            }
            $exported = 0;
            foreach ($post_ids as $post_id) {
                $api_id = get_post_meta($post_id, NPR_STORY_ID_META_KEY, TRUE);
                $api = new NPRAPIWordpress();
                $params = array('id' => $api_id, 'apiKey' => get_option('ds_npr_api_key'));
                $api->request($params, 'query', get_option('ds_npr_api_pull_url'));
                $api->parse();
                if (empty($api->message) || $api->message->level != 'warning') {
                    error_log('updating story for API ID=' . $api_id);
                    $story = $api->update_posts_from_stories();
                }
            }
            // build the redirect url
            //$sendback = add_query_arg( array('exported' => $exported, 'ids' => join(',', $post_ids) ), $sendback );
            break;
        default:
            return;
    }
    // ...
    // 4. Redirect client
    //wp_redirect($sendback);
    //exit();
}
Example #8
0
 /**
  * Prepare actions according to screen and post type.
  *
  * @since 3.8.2
  *
  * @uses Jetpack_Autoupdate::get_possible_failures()
  *
  * @param object $screen
  */
 function prepare_jitms($screen)
 {
     if (!current_user_can('jetpack_manage_modules')) {
         return;
     }
     global $pagenow;
     // Only show auto update JITM if auto updates are allowed in this installation
     $possible_reasons_for_failure = Jetpack_Autoupdate::get_possible_failures();
     self::$auto_updates_allowed = empty($possible_reasons_for_failure);
     if ('media-new.php' == $pagenow && !Jetpack::is_module_active('photon')) {
         add_action('admin_enqueue_scripts', array($this, 'jitm_enqueue_files'));
         add_action('post-plupload-upload-ui', array($this, 'photon_msg'));
     } elseif ('post-new.php' == $pagenow && in_array($screen->post_type, array('post', 'page'))) {
         add_action('admin_enqueue_scripts', array($this, 'jitm_enqueue_files'));
         add_action('admin_notices', array($this, 'editor_msg'));
     } elseif (self::$auto_updates_allowed) {
         if ('update-core.php' == $pagenow && !Jetpack::is_module_active('manage')) {
             add_action('admin_enqueue_scripts', array($this, 'jitm_enqueue_files'));
             add_action('admin_notices', array($this, 'manage_msg'));
         } elseif ('plugins.php' == $pagenow) {
             if (isset($_GET['activate']) && 'true' === $_GET['activate'] || isset($_GET['activate-multi']) && 'true' === $_GET['activate-multi']) {
                 add_action('admin_enqueue_scripts', array($this, 'jitm_enqueue_files'));
                 add_action('pre_current_active_plugins', array($this, 'manage_pi_msg'));
             } else {
                 // Save plugins that are activated. This is used when one or more plugins are activated to know
                 // what was activated and use it in Jetpack_JITM::manage_pi_msg() before deleting the option.
                 $wp_list_table = _get_list_table('WP_Plugins_List_Table');
                 $action = $wp_list_table->current_action();
                 if ($action && ('activate' == $action || 'activate-selected' == $action)) {
                     update_option('jetpack_temp_active_plugins_before', get_option('active_plugins', array()));
                 }
             }
         }
     }
 }
Example #9
0
 public function show_license_message($file, $plugin)
 {
     $wp_list_table = _get_list_table('WP_Plugins_List_Table');
     echo '<tr class="plugin-update-tr active"><td colspan="' . esc_attr($wp_list_table->get_column_count()) . '" class="plugin-update colspanchange"><div class="update-message">';
     echo sprintf(__('Your %1$s license key is missing. Please add it on the %2$slicenses page%3$s.', 'formidable'), $this->plugin_name, '<a href="' . esc_url(admin_url('admin.php?page=formidable-settings&t=licenses_settings')) . '">', '</a>');
     $id = sanitize_title($plugin['Name']);
     echo '<script type="text/javascript">var d = document.getElementById("' . esc_attr($id) . '");if ( d !== null ){ d.className = d.className + " update"; }</script>';
     echo '</div></td></tr>';
 }
    static function DisplayInstallPlugins()
    {
        if (!current_user_can('install_plugins')) {
            wp_die(__('You do not have sufficient permissions to install plugins on this site.'));
        }
        global $tab;
        $tab = $_GET['tab'] = 'new';
        // required for list table (in 3.5.1)
        $wp_list_table = _get_list_table('WP_Plugin_Install_List_Table');
        $pagenum = $wp_list_table->get_pagenum();
        $wp_list_table->orderby = 'order';
        $wp_list_table->prepare_items();
        $total_pages = $wp_list_table->get_pagination_arg('total_pages');
        if ($pagenum > $total_pages && $total_pages > 0) {
            WPFB_AdminLite::JsRedirect(add_query_arg('paged', $total_pages));
            exit;
        }
        $title = __('Extensions', 'wp-filebase');
        wp_print_scripts('plugin-install');
        ?>
        <style type="text/css" media="screen">
            .vers.column-rating, .column-downloaded { display: none; }
            #TB_ajaxWindowTitle { display: none; }
        </style>

        <div class="wrap">
            <h3><?php 
        echo esc_html($title);
        ?>
</h3>
			<p>Each extensions is an additional plugin. You can test all extensions in the <a href="http://demo.wpfilebase.com/wp-admin/admin.php?page=wpfilebase_manage" target="_blank">Live Demo Sandbox</a>.</p>
        <?php 
        //$wp_list_table->views();
        //echo '<br class="clear" />';
        ?>
            <form id="plugin-filter" action="" method="post">
            <?php 
        $wp_list_table->display();
        ?>
            </form>
        </div>
        <script>
            jQuery('a.buy-now').click(function (e) {
                if (jQuery(this).text() === 'Refresh') {
                    if(window.location.search.indexOf('&no_api_cache=1') > 0)
                        window.location.reload();
                    else
                        window.location.search += '&no_api_cache=1';
                    return false;
                }
                jQuery(this).text('Refresh');
                return true;
            });
        </script>
        <?php 
    }
 function vp_php_version_inline_error($file, $plugin_data)
 {
     global $phpVersionMessage;
     $wp_list_table = _get_list_table('WP_Plugins_List_Table');
     echo '<tr class="active plugin-update-tr">';
     echo '<td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange">';
     echo '<div class="update-message">';
     echo $phpVersionMessage;
     echo '</div></td></tr>';
 }
Example #12
0
 private function get_table()
 {
     if (is_null($this->table)) {
         if (!get_current_screen()) {
             set_current_screen(self::USERS_SCREEN);
         }
         $this->table = _get_list_table('WP_Users_List_Table', array('screen' => self::USERS_SCREEN));
     }
     return $this->table;
 }
Example #13
0
/**
 * Function to handle bulk actions at page load.
 *
 * @since 2.9.2
 *
 * @global object $wpmem The WP_Members object.
 */
function wpmem_posts_page_load()
{
    global $wpmem;
    $wp_list_table = _get_list_table('WP_Posts_List_Table');
    $action = $wp_list_table->current_action();
    $sendback = '';
    switch ($action) {
        case 'block':
        case 'unblock':
            // Validate nonce.
            check_admin_referer('bulk-posts');
            // Get the posts.
            $posts = isset($_REQUEST['post']) ? $_REQUEST['post'] : '';
            // Update posts.
            $x = '';
            if ($posts) {
                foreach ($posts as $post_id) {
                    $x++;
                    $post = get_post($post_id);
                    $type = $post->post_type;
                    // Update accordingly.
                    if ($wpmem->block[$type] == 0) {
                        if ($action == 'block') {
                            update_post_meta($post_id, '_wpmem_block', 1);
                        } else {
                            delete_post_meta($post_id, '_wpmem_block');
                        }
                    }
                    if ($wpmem->block[$type] == 1) {
                        if ($action == 'unblock') {
                            update_post_meta($post_id, '_wpmem_block', 0);
                        } else {
                            delete_post_meta($post_id, '_wpmem_block');
                        }
                    }
                }
                // Set the return message.
                $arr = array('a' => $action, 'n' => $x, 'post_type' => $type);
                if (isset($_GET['post_status']) && 'all' != $_GET['post_status']) {
                    $arr['post_status'] = $_GET['post_status'];
                }
                $sendback = add_query_arg(array($arr), '', $sendback);
            } else {
                // Set the return message.
                $sendback = add_query_arg(array('a' => 'none'), '', $sendback);
            }
            break;
        default:
            return;
    }
    // If we did not return already, we need to wp_redirect.
    wp_redirect($sendback);
    exit;
}
Example #14
0
/**
 * Step 2: handle the custom Bulk Action
 * 
 * Based on the post http://wordpress.stackexchange.com/questions/29822/custom-bulk-action
 */
function custom_bulk_action()
{
    global $typenow;
    $post_type = $typenow;
    if ($post_type == 'post' or $post_type == 'page') {
        //	if($post_type == 'post') {
        // get the action
        $wp_list_table = _get_list_table('WP_Posts_List_Table');
        // depending on your resource type this could be WP_Users_List_Table, WP_Comments_List_Table, etc
        $action = $wp_list_table->current_action();
        $allowed_actions = array("export");
        if (!in_array($action, $allowed_actions)) {
            return;
        }
        // security check
        check_admin_referer('bulk-posts');
        // make sure ids are submitted.  depending on the resource type, this may be 'media' or 'ids'
        if (isset($_REQUEST['post'])) {
            $post_ids = array_map('intval', $_REQUEST['post']);
            //проверка что входные величины - числа.
        }
        if (empty($post_ids)) {
            return;
        }
        // this is based on wp-admin/edit.php
        $sendback = remove_query_arg(array('exported', 'untrashed', 'deleted', 'ids'), wp_get_referer());
        if (!$sendback) {
            $sendback = admin_url("edit.php?post_type={$post_type}");
        }
        $pagenum = $wp_list_table->get_pagenum();
        $sendback = add_query_arg('paged', $pagenum, $sendback);
        switch ($action) {
            case 'export':
                // if we set up user permissions/capabilities, the code might look like:
                //if ( !current_user_can($post_type_object->cap->export_post, $post_id) )
                //	wp_die( __('You are not allowed to export this post.') );
                //				$exported = 10;
                //				foreach( $post_ids as $post_id ) {
                $exported = perform_export($post_ids);
                if (!$exported) {
                    wp_die(__('Error exporting post.'));
                }
                //					$exported++;
                //				}
                $sendback = add_query_arg(array('exported' => $exported, 'ids' => join(',', $post_ids)), $sendback);
                break;
            default:
                return;
        }
        $sendback = remove_query_arg(array('action', 'action2', 'tags_input', 'post_author', 'comment_status', 'ping_status', '_status', 'post', 'bulk_edit', 'post_view'), $sendback);
        wp_redirect($sendback);
        exit;
    }
}
Example #15
0
/**
 * Function to handle bulk actions at page load
 *
 * @since 2.9.2
 *
 * @uses WP_Users_List_Table
 */
function wpmem_posts_page_load()
{
    $wp_list_table = _get_list_table('WP_Posts_List_Table');
    $action = $wp_list_table->current_action();
    $sendback = '';
    switch ($action) {
        case 'block':
        case 'unblock':
            /** validate nonce **/
            check_admin_referer('bulk-posts');
            /** get the posts **/
            $posts = isset($_REQUEST['post']) ? $_REQUEST['post'] : '';
            /** update posts **/
            $x = '';
            if ($posts) {
                foreach ($posts as $post_id) {
                    $x++;
                    $post = get_post($post_id);
                    $type = $post->post_type;
                    // update accordingly
                    if ($type == 'post' && WPMEM_BLOCK_POSTS == 0 || $type == 'page' && WPMEM_BLOCK_PAGES == 0) {
                        if ($action == 'block') {
                            update_post_meta($post_id, '_wpmem_block', 1);
                        } else {
                            delete_post_meta($post_id, '_wpmem_block');
                        }
                    }
                    if ($type == 'post' && WPMEM_BLOCK_POSTS == 1 || $type == 'page' && WPMEM_BLOCK_PAGES == 1) {
                        if ($action == 'unblock') {
                            update_post_meta($post_id, '_wpmem_block', 0);
                        } else {
                            delete_post_meta($post_id, '_wpmem_block');
                        }
                    }
                }
                /** set the return message */
                $arr = array('a' => $action, 'n' => $x);
                if ($type == 'page') {
                    $arr['post_type'] = 'page';
                }
                $sendback = add_query_arg(array($arr), '', $sendback);
            } else {
                /** set the return message */
                $sendback = add_query_arg(array('a' => 'none'), '', $sendback);
            }
            break;
        default:
            return;
    }
    /** if we did not return already, we need to wp_redirect */
    wp_redirect($sendback);
    exit;
}
    static function DisplayInstallPlugins()
    {
        if (!current_user_can('install_plugins')) {
            wp_die(__('You do not have sufficient permissions to install plugins on this site.'));
        }
        global $tab;
        $tab = $_GET['tab'] = 'new';
        // required for list table (in 3.5.1)
        $wp_list_table = _get_list_table('WP_Plugin_Install_List_Table');
        $pagenum = $wp_list_table->get_pagenum();
        $wp_list_table->orderby = 'order';
        $wp_list_table->prepare_items();
        $total_pages = $wp_list_table->get_pagination_arg('total_pages');
        if ($pagenum > $total_pages && $total_pages > 0) {
            WPFB_AdminLite::JsRedirect(add_query_arg('paged', $total_pages));
            exit;
        }
        $title = __('Add Extensions');
        wp_print_scripts('plugin-install');
        ?>
<style type="text/css" media="screen">
	.vers.column-rating, .column-downloaded { display: none; }
	#TB_ajaxWindowTitle { display: none; }
</style>

<div class="wrap">
<h2><?php 
        echo esc_html($title);
        ?>
</h2>

<?php 
        //$wp_list_table->views();
        //echo '<br class="clear" />';
        ?>
	<form id="plugin-filter" action="" method="post">
		<?php 
        $wp_list_table->display();
        ?>
	</form>
</div>
<script>
	jQuery('a.buy-now').click(function(e) {
		if(jQuery(this).text() === 'Refresh') {
			window.location.reload();
			return false;
		}
		jQuery(this).text('Refresh');
		return true;
	});
	</script>
<?php 
    }
Example #17
0
 /**
  * Get WP default supported admin columns per post type.
  *
  * @see CPAC_Type::get_default_columns()
  * @since 1.0
  *
  * @return array
  */
 public function get_default_columns()
 {
     if (!function_exists('_get_list_table')) {
         return array();
     }
     // You can use this filter to add thirdparty columns by hooking into this.
     // See classes/third_party.php for an example.
     do_action("cac/columns/default/storage_key={$this->key}");
     // get columns
     $table = _get_list_table('WP_Comments_List_Table', array('screen' => 'comments'));
     $columns = (array) $table->get_columns();
     return $columns;
 }
Example #18
0
 /**
  * Step 2: handle the custom Bulk Action
  * 
  * Based on the post http://wordpress.stackexchange.com/questions/29822/custom-bulk-action
  */
 function custom_bulk_action()
 {
     global $typenow;
     $post_type = $typenow;
     /*if($post_type == 'post') {*/
     // get the action
     $wp_list_table = _get_list_table('WP_Posts_List_Table');
     // depending on your resource type this could be WP_Users_List_Table, WP_Comments_List_Table, etc
     $action = $wp_list_table->current_action();
     $allowed_actions = array("approve");
     if (!in_array($action, $allowed_actions)) {
         return;
     }
     // security check
     check_admin_referer('bulk-posts');
     // make sure ids are submitted.  depending on the resource type, this may be 'media' or 'ids'
     if (isset($_REQUEST['post'])) {
         $post_ids = array_map('intval', $_REQUEST['post']);
     }
     if (empty($post_ids)) {
         return;
     }
     // this is based on wp-admin/edit.php
     //$sendback = remove_query_arg( array('exported', 'untrashed', 'deleted', 'ids'), wp_get_referer() );
     if (!$sendback) {
         $sendback = admin_url("edit.php?post_type={$post_type}");
     }
     $pagenum = $wp_list_table->get_pagenum();
     $sendback = add_query_arg('paged', $pagenum, $sendback);
     switch ($action) {
         case 'approve':
             // if we set up user permissions/capabilities, the code might look like:
             //if ( !current_user_can($post_type_object->cap->export_post, $post_id) )
             //	wp_die( __('You are not allowed to export this post.') );
             $exported = 0;
             foreach ($post_ids as $post_id) {
                 if (!$this->perform_export($post_id)) {
                     wp_die(__('Error exporting post.'));
                 }
                 change_post_status($post_id, 'publish');
                 $exported++;
             }
             break;
         default:
             return;
     }
     wp_redirect($sendback);
     exit;
     /*}*/
 }
Example #19
0
 public function get_default_columns()
 {
     if (!function_exists('_get_list_table')) {
         return array();
     }
     // You can use this filter to add thirdparty columns by hooking into this.
     // See classes/third_party.php for an example.
     do_action("cac/columns/default/storage_key={$this->key}");
     $table = _get_list_table('WP_Media_List_Table', array('screen' => 'upload'));
     $columns = (array) $table->get_columns();
     if (cac_is_setting_screen()) {
         $columns = array_merge(get_column_headers('upload'), $columns);
     }
     return $columns;
 }
Example #20
0
 /**
  * @see CPAC_Type::get_default_columns()
  */
 public function get_default_columns()
 {
     if (!function_exists('_get_list_table')) {
         return array();
     }
     // You can use this filter to add third_party columns by hooking into this.
     do_action("cac/columns/default/storage_key={$this->key}");
     // get columns
     $table = _get_list_table('WP_Users_List_Table', array('screen' => 'users'));
     $columns = (array) $table->get_columns();
     if ($this->is_settings_page()) {
         $columns = array_merge(get_column_headers('users'), $columns);
     }
     return $columns;
 }
Example #21
0
 /**
  * Handle the custom Bulk Action
  */
 function action()
 {
     global $typenow;
     $post_type = $typenow;
     // get the action
     $wp_list_table = _get_list_table('WP_Posts_List_Table');
     $action = $wp_list_table->current_action();
     $allowed_actions = array("clone");
     if (!in_array($action, $allowed_actions)) {
         return;
     }
     // security check
     check_admin_referer('bulk-posts');
     // make sure ids are submitted.  depending on the resource type, this may be 'media' or 'ids'
     if (isset($_REQUEST['post'])) {
         $post_ids = array_map('intval', $_REQUEST['post']);
     }
     if (empty($post_ids)) {
         return;
     }
     // this is based on wp-admin/edit.php
     $sendback = remove_query_arg(array('cloned', 'untrashed', 'deleted', 'ids'), wp_get_referer());
     if (!$sendback) {
         $sendback = admin_url("edit.php?post_type={$post_type}");
     }
     $pagenum = $wp_list_table->get_pagenum();
     $sendback = add_query_arg('paged', $pagenum, $sendback);
     switch ($action) {
         case 'clone':
             $cloned = 0;
             foreach ($post_ids as $post_id) {
                 if (!current_user_can('edit_post', $post_id)) {
                     wp_die(__('You are not allowed to clone this post.'));
                 }
                 if (!$this->clone_single_post($post_id)) {
                     wp_die(__('Error cloning post.'));
                 }
                 $cloned++;
             }
             $sendback = add_query_arg(array('cloned' => $cloned, 'ids' => join(',', $post_ids)), $sendback);
             break;
         default:
             return;
     }
     $sendback = remove_query_arg(array('action', 'action2', 'tags_input', 'post_author', 'comment_status', 'ping_status', '_status', 'post', 'bulk_edit', 'post_view'), $sendback);
     wp_redirect($sendback);
     exit;
 }
Example #22
0
 public function get_default_columns()
 {
     if (!function_exists('_get_list_table')) {
         return array();
     }
     // You can use this filter to add thirdparty columns by hooking into this.
     // See classes/third_party.php for an example.
     do_action("cac/columns/default/storage_key={$this->key}");
     // get columns
     $table = _get_list_table('WP_Comments_List_Table', array('screen' => 'comments'));
     // Since 4.4 the `floated_admin_avatar` filter is added in the constructor of the `WP_Comments_List_Table` class.
     // Here we remove the filter from the constructor.
     remove_filter('comment_author', array($table, 'floated_admin_avatar'), 10, 2);
     $columns = (array) $table->get_columns();
     return $columns;
 }
 /**
  * Processes 'verify cheque payment' bulk action
  */
 function process_cheque_bulk_actions()
 {
     global $typenow;
     if ($typenow !== 'ngg_order') {
         return;
     }
     if (empty($_REQUEST['post'])) {
         return;
     }
     $wp_list_table = _get_list_table('WP_Posts_List_Table');
     $action = $wp_list_table->current_action();
     $ids = array_map('intval', $_REQUEST['post']);
     if (empty($ids)) {
         return;
     }
     $url = remove_query_arg(array('verify_cheques'), wp_get_referer());
     if (!$url) {
         $url = admin_url('edit.php?post_type=ngg_order');
     }
     $url = add_query_arg('paged', $wp_list_table->get_pagenum(), $url);
     switch ($action) {
         case 'verify_cheques':
             $checkout = new C_NextGen_Pro_Checkout();
             $verified = 0;
             foreach ($ids as $post_id) {
                 $order = C_Order_Mapper::get_instance()->find($post_id, TRUE);
                 if ($order->status !== 'unverified' || $order->payment_gateway !== 'cheque') {
                     continue;
                 }
                 $order->status = 'verified';
                 if ($order->save()) {
                     $verified++;
                     $checkout->send_email_receipt($order->hash);
                 }
             }
             if (session_id() == '') {
                 session_start();
             }
             $_SESSION['ngg_verified_cheques'] = $verified;
             session_write_close();
             wp_redirect($url);
             throw new E_Clean_Exit();
         default:
             return;
     }
 }
 protected function go_to_listing(array $args)
 {
     $_GET = $_REQUEST = $args;
     $GLOBALS['hook_suffix'] = 'edit.php';
     set_current_screen($args['post_type']);
     do_action('load-edit.php');
     wp_set_current_user(1);
     // @TODO change
     $wp_list_table = _get_list_table('WP_Posts_List_Table');
     $this->assertInstanceOf('WP_List_Table', $wp_list_table);
     ob_start();
     $wp_list_table->prepare_items();
     $wp_list_table->views();
     $wp_list_table->display();
     $output = ob_get_clean();
     return $output;
 }
 /**
  * Step 2: handle the custom Bulk Action
  * 
  * Based on the post http://wordpress.stackexchange.com/questions/29822/custom-bulk-action
  */
 function custom_bulk_action()
 {
     // get the action
     $wp_list_table = _get_list_table('WP_Plugins_List_Table');
     // depending on your resource type this could be WP_Users_List_Table, WP_Comments_List_Table, etc
     $action = $wp_list_table->current_action();
     // allow only defined actions
     $allowed_actions = array_keys($this->actions);
     if (!in_array($action, $allowed_actions)) {
         return;
     }
     // security check
     check_admin_referer('bulk-plugins');
     // make sure ids are submitted.  depending on the resource type, this may be 'media' or 'ids'
     // if(isset($_REQUEST['post'])) {
     // 	$post_ids = array_map('intval', $_REQUEST['post']);
     // }
     $post_ids = $_REQUEST['checked'];
     // this is based on wp-admin/edit.php
     $sendback = remove_query_arg(array('exported', 'untrashed', 'deleted', 'ids'), wp_get_referer());
     if (!$sendback) {
         $sendback = admin_url("plugins.php");
     }
     $pagenum = $wp_list_table->get_pagenum();
     $sendback = add_query_arg('paged', $pagenum, $sendback);
     if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
         //check that we have anonymous function as a callback
         $anon_fns = array_filter($this->actions[$action], function ($el) {
             return $el instanceof Closure;
         });
         if (count($anon_fns) != 0) {
             //Finally use the callback
             $result = $this->actions[$action]['callback']($post_ids);
         } else {
             $result = call_user_func($this->actions[$action]['callback'], $post_ids);
         }
     } else {
         $result = call_user_func($this->actions[$action]['callback'], $post_ids);
     }
     $sendback = add_query_arg(array('success_action' => $action, 'count' => HackRepair_Plugin_Archiver::$count), $sendback);
     $sendback = remove_query_arg(array('action', 'paged', 'mode', 'action2', 'tags_input', 'post_author', 'comment_status', 'ping_status', '_status', 'post', 'bulk_edit', 'post_view'), $sendback);
     wp_redirect($sendback);
     exit;
     // }
 }
/**
 * Process the new bulk actions for get order IDs
 */
function bulk_action_etiqueta()
{
    $wp_list_table = _get_list_table('WP_Posts_List_Table');
    $action = $wp_list_table->current_action();
    // Bail out if this is not a status-changing action
    if (strpos($action, 'gerar_') === false) {
        return;
    }
    $new_status = substr($action, 5);
    // get the status name from action
    $report_action = 'gerada' . $new_status;
    $changed = 0;
    $post_ids = array_map('absint', (array) $_REQUEST['post']);
    $sendback = add_query_arg(array('post_type' => 'shop_order', $report_action => true, 'changed' => $changed, 'ids' => join(',', $post_ids)), '');
    wp_redirect($sendback);
    // esse é o padrão
    exit;
}
 /**
  * handle the Bulk Action
  * 
  * Based on the post http://wordpress.stackexchange.com/questions/29822/custom-bulk-action
  */
 function bulk_action()
 {
     global $typenow;
     $post_type = $typenow;
     if ($post_type == 'post' || $post_type == 'page') {
         // get the action
         $wp_list_table = _get_list_table('WP_Posts_List_Table');
         // depending on your resource type this could be WP_Users_List_Table, WP_Comments_List_Table, etc
         $action = $wp_list_table->current_action();
         $allowed_actions = array('print', "export", 'export_day', 'export_user');
         if (!in_array($action, $allowed_actions)) {
             return;
         }
         // security check
         check_admin_referer('bulk-posts');
         // make sure ids are submitted.  depending on the resource type, this may be 'media' or 'ids'
         if (isset($_REQUEST['post'])) {
             $post_ids = array_map('intval', $_REQUEST['post']);
         }
         if (empty($post_ids)) {
             return;
         }
         global $wp_query;
         switch ($action) {
             case 'export':
                 $wp_query = new \WP_Query(array('post__in' => $post_ids, 'orderby' => 'title', 'order' => 'ASC', 'post_type' => $post_type, 'wp_side_comments_print_csv' => 1));
                 break;
             case 'export_day':
                 $wp_query = new \WP_Query(array('post__in' => $post_ids, 'orderby' => 'title', 'order' => 'ASC', 'post_type' => $post_type, 'wp_side_comments_print_csv' => 2));
                 break;
             case 'export_user':
                 $wp_query = new \WP_Query(array('post__in' => $post_ids, 'orderby' => 'title', 'order' => 'ASC', 'post_type' => $post_type, 'wp_side_comments_print_csv' => 3));
                 break;
             case 'print':
                 $wp_query = new \WP_Query(array('post__in' => $post_ids, 'orderby' => 'title', 'order' => 'ASC', 'post_type' => $post_type));
                 break;
             default:
                 return;
         }
         include CTLT_WP_SIDE_COMMENTS_PLUGIN_PATH . 'print/print.php';
         exit;
     }
 }
Example #28
0
/**
 * Ajax callback for Create New Stack button
 *
 * @since    1.0.0
 * @link     http://codex.wordpress.org/Function_Reference/add_editor_style
 * @see      get_bloginfo()
 * @param    array $wp See link for description.
 * @return   void
 */
function mp_stacks_add_new_stack_ajax()
{
    //Check nonce
    if (!check_ajax_referer('mp-stacks-nonce-action-name', 'mp_stacks_nonce', false)) {
        echo __('Ajax Security Check', 'mp_stacks');
        die;
    }
    $new_stack_name = $_POST['mp_stacks_new_stack_name'];
    $mp_stacks_new_stack_source_type = $_POST['mp_stacks_new_stack_source_type'];
    $new_stack_duplicate_id = $_POST['mp_stacks_new_stack_duplicate_id'];
    $new_stack_template_slug = $_POST['mp_stacks_new_stack_template_slug'];
    if (!empty($new_stack_name) && current_user_can('edit_theme_options')) {
        //If the user wants to duplicate an existing stack
        if ($mp_stacks_new_stack_source_type == 'duplicate-stack-option') {
            //Duplicate the stack id passed to ajax
            $new_stack_id = mp_stacks_duplicate_stack($new_stack_duplicate_id, $new_stack_name);
        } else {
            if ($mp_stacks_new_stack_source_type == 'template-stack-option') {
                $new_stack_id = mp_stacks_create_stack_from_template($new_stack_template_slug(), $new_stack_name);
            } else {
                //Make new stack
                $new_stack_array = wp_insert_term($new_stack_name, 'mp_stacks');
                //If there was an error making the stack, echo that error
                if (is_wp_error($new_stack_array)) {
                    $error_string = $new_stack_array->get_error_message();
                    echo '<div id="message" class="error"><p>' . $error_string . '</p></div>';
                    die;
                }
                $new_stack_id = $new_stack_array['term_id'];
            }
        }
        //Get the updated Stacks Table
        $wp_list_table = _get_list_table('WP_Terms_List_Table', array('screen' => 'edit-mp_stacks'));
        ob_start();
        $wp_list_table->display_rows_or_placeholder();
        $updated_stacks_table = ob_get_clean();
        echo json_encode(array('new_stack_id' => $new_stack_id, 'updated_stacks_table' => $updated_stacks_table));
    }
    die;
    // this is required to return a proper result
}
/**
 * Função que trata a ação de edição em massa do prazo de discussão
 */
function delibera_custom_bulk_action()
{
    $wp_list_table = _get_list_table('WP_Posts_List_Table');
    $action = $wp_list_table->current_action();
    switch ($action) {
        case 'set_prazodiscussao':
            check_admin_referer('bulk-posts');
            $pautas_ids = $_REQUEST['post'];
            $novo_prazo_discussao = $_REQUEST['novo_prazo_discussao'];
            $inovo_prazo_discussao = DateTime::createFromFormat('d/m/Y', $novo_prazo_discussao)->getTimestamp();
            $pautas_afetadas = 0;
            foreach ($pautas_ids as $pauta_id) {
                delibera_set_novo_prazo_discussao_relatoria($pauta_id, $inovo_prazo_discussao, delibera_get_config());
                $pautas_afetadas++;
            }
            $sendback = admin_url("edit.php?post_type=pauta&pautas_afetadas={$pautas_afetadas}&novo_prazo={$novo_prazo_discussao}");
            wp_redirect($sendback);
            exit;
            break;
    }
}
Example #30
-1
 function setUp()
 {
     set_current_screen('edit-page');
     $GLOBALS['hook_suffix'] = '';
     $this->table = _get_list_table('WP_Posts_List_Table');
     parent::setUp();
     // note that our top/children/grandchildren arrays are 1-indexed
     // create top level pages
     $num_posts = 5;
     foreach (range(1, $num_posts) as $i) {
         $this->top[$i] = $this->factory->post->create_and_get(array('post_type' => 'page', 'post_title' => sprintf('Top Level Page %d', $i)));
     }
     // create child pages
     $num_children = 3;
     foreach ($this->top as $top => $top_page) {
         foreach (range(1, $num_children) as $i) {
             $this->children[$top][$i] = $this->factory->post->create_and_get(array('post_type' => 'page', 'post_parent' => $top_page->ID, 'post_title' => sprintf('Child %d', $i)));
         }
     }
     // create grand-child pages for the third and fourth top-level pages
     $num_grandchildren = 3;
     foreach (range(3, 4) as $top) {
         foreach ($this->children[$top] as $child => $child_page) {
             foreach (range(1, $num_grandchildren) as $i) {
                 $this->grandchildren[$top][$child][$i] = $this->factory->post->create_and_get(array('post_type' => 'page', 'post_parent' => $child_page->ID, 'post_title' => sprintf('Grandchild %d', $i)));
             }
         }
     }
 }