示例#1
0
 /**
  * 
  * _SAVE
  * 
  * This function handles various POST requests.
  * 
  * @return html string
  * @author epstudios
  *      
  */
 public function _save()
 {
     // Upload a CSV
     if (isset($_POST['eps_redirect_upload']) && wp_verify_nonce($_POST['eps_redirect_nonce_submit'], 'eps_redirect_nonce')) {
         self::_upload();
     }
     // Refresh the Transient Cache
     if (isset($_POST['eps_redirect_refresh']) && wp_verify_nonce($_POST['eps_redirect_nonce_submit'], 'eps_redirect_nonce')) {
         $post_types = get_post_types(array('public' => true), 'objects');
         foreach ($post_types as $post_type) {
             $options = eps_dropdown_pages(array('post_type' => $post_type->name));
             set_transient('post_type_cache_' . $post_type->name, $options, HOUR_IN_SECONDS);
         }
     }
     // Save Redirects
     if (isset($_POST['eps_redirect_submit']) && wp_verify_nonce($_POST['eps_redirect_nonce_submit'], 'eps_redirect_nonce')) {
         $this->_save_redirects(self::_parse_serial_array($_POST['redirect']));
     }
 }
 /**
  *
  * check_plugin_actions
  *
  * This function handles various POST requests.
  *
  * @return nothing
  * @author epstudios
  *
  */
 public function check_plugin_actions()
 {
     if (is_admin() && isset($_GET['page']) && $_GET['page'] == $this->config('page_slug')) {
         // Upload a CSV
         if (isset($_POST['eps_redirect_upload']) && wp_verify_nonce($_POST['eps_redirect_nonce_submit'], 'eps_redirect_nonce')) {
             self::_upload();
         }
         // Export a CSV
         if (isset($_POST['eps_redirect_export']) && wp_verify_nonce($_POST['eps_redirect_nonce_submit'], 'eps_redirect_nonce')) {
             self::export_csv();
         }
         // Refresh the Transient Cache
         if (isset($_POST['eps_redirect_refresh']) && wp_verify_nonce($_POST['eps_redirect_nonce_submit'], 'eps_redirect_nonce')) {
             $post_types = get_post_types(array('public' => true), 'objects');
             foreach ($post_types as $post_type) {
                 $options = eps_dropdown_pages(array('post_type' => $post_type->name));
                 set_transient('post_type_cache_' . $post_type->name, $options, HOUR_IN_SECONDS);
             }
             $this->add_admin_message("SUCCCESS: Cache Refreshed.", "updated");
         }
         // Save Redirects
         if (isset($_POST['eps_redirect_submit']) && wp_verify_nonce($_POST['eps_redirect_nonce_submit'], 'eps_redirect_nonce')) {
             self::_save_redirects(EPS_Redirects::_parse_serial_array($_POST['redirect']));
         }
         // Create tables
         if (isset($_GET['action']) && $_GET['action'] == 'eps_create_tables') {
             $result = self::_create_redirect_table();
         }
     }
 }
/**
 * 
 * GET_POST_TYPE_SELECT
 * 
 * This function will output the available post types.
 * 
 * @return html string
 * @author epstudios
 *      
 */
function eps_get_post_type_selects($post_type, $current_post = false)
{
    // Start the select.
    $html = '<select class="select-' . $post_type . ' url-selector eps-small-select" ' . (isset($current_post) && $current_post->post_type == $post_type ? null : 'style="display:none;"') . '>';
    $html .= '<option value="">...</option>';
    if (false === ($options = get_transient('post_type_cache_' . $post_type))) {
        $options = eps_dropdown_pages(array('post_type' => $post_type));
        set_transient('post_type_cache_' . $post_type, $options, HOUR_IN_SECONDS);
    }
    foreach ($options as $option => $value) {
        $html .= '<option value="' . $value . '" ' . (isset($current_post) && $current_post->ID == $value ? 'selected="selected"' : null) . ' >' . ucwords($option) . '</option>';
    }
    $html .= '</select>';
    return $html;
}