Exemplo n.º 1
0
/**
 * Set the default order on the portfolio posts page to display by
 * menu order and not date
 * 
 * @param obj $query The original query object
 * @return void
 */
function set_portfolio_post_type_admin_order($query)
{
    if (is_admin()) {
        $post_type = $query->query['post_type'];
        if ($post_type == 'portfolio' && empty($_GET['orderby'])) {
            $query->set('orderby', 'menu_order');
            $query->set('order', 'ASC');
        }
    }
}
Exemplo n.º 2
0
/**
 * Order posts.
 *
 * @since	1.3
 * @param	obj		$query		The WP_Query object
 * @return	void
 */
function mdjm_quote_post_order($query)
{
    if (!is_admin() || 'mdjm-quotes' != $query->get('post_type')) {
        return;
    }
    switch ($query->get('orderby')) {
        case 'quote_view_date':
            $query->set('meta_key', '_mdjm_quote_viewed_date');
            $query->set('orderby', 'meta_value');
            break;
        case 'quote_value':
            // TO DO
            break;
    }
}
Exemplo n.º 3
0
/**
 * Order posts.
 *
 * @since	1.3
 * @param	obj		$query		The WP_Query object
 * @return	void
 */
function mdjm_venue_post_order($query)
{
    if (!is_admin() || 'mdjm-venue' != $query->get('post_type')) {
        return;
    }
    switch ($query->get('orderby')) {
        case 'town':
            $query->set('meta_key', '_venue_town');
            $query->set('orderby', 'meta_value');
            break;
        case 'county':
            $query->set('meta_key', '_venue_county');
            $query->set('orderby', 'meta_value');
            break;
    }
}
Exemplo n.º 4
0
 /**
  * Exclude pages from search
  *
  * @param  obj $query the query object
  * @return obj        the modified object
  */
 function tz_exclude_pages($query)
 {
     if ($query->is_search) {
         $query->set('post_type', 'post');
     }
     return $query;
 }
Exemplo n.º 5
0
/**
 * Order posts.
 *
 * @since	1.3
 * @param	obj		$query		The WP_Query object
 * @return	void
 */
function mdjm_transaction_post_order($query)
{
    if (!is_admin() || 'mdjm-transaction' != $query->get('post_type')) {
        return;
    }
    switch ($query->get('orderby')) {
        case 'txn_date':
        default:
            $query->set('orderby', 'post_date');
            break;
        case 'txn_status':
            $query->set('orderby', '_mdjm_txn_status');
            break;
        case 'event':
            $query->set('orderby', 'post_parent');
            break;
        case 'txn_value':
            $query->set('meta_key', '_mdjm_txn_total');
            $query->set('orderby', 'meta_value_num');
            break;
    }
}
Exemplo n.º 6
0
/**
 * Process the image edit form posted
 * @param obj $image Image object
 * @param type $index Index of the image if within the images list or 0 if single image edit
 * @param boolean $massedit Whether editing single image (false) or multiple images at once (true). Note: to determine whether to process additional fields in single image edit mode.
 */
function processImageEdit($image, $index, $massedit = true)
{
    $notify = '';
    if (isset($_POST[$index . '-MoveCopyRename'])) {
        $movecopyrename_action = sanitize($_POST[$index . '-MoveCopyRename'], 3);
    } else {
        $movecopyrename_action = '';
    }
    if ($movecopyrename_action == 'delete') {
        $image->remove();
    } else {
        if ($thumbnail = sanitize($_POST['album_thumb-' . $index])) {
            //selected as an album thumb
            $talbum = newAlbum($thumbnail);
            if ($image->imagefolder == $thumbnail) {
                $talbum->setThumb($image->filename);
            } else {
                $talbum->setThumb('/' . $image->imagefolder . '/' . $image->filename);
            }
            $talbum->save();
        }
        if (isset($_POST[$index . '-reset_rating'])) {
            $image->set('total_value', 0);
            $image->set('total_votes', 0);
            $image->set('used_ips', 0);
        }
        $image->setPublishDate(sanitize($_POST['publishdate-' . $index]));
        $image->setExpireDate(sanitize($_POST['expirationdate-' . $index]));
        $image->setTitle(process_language_string_save("{$index}-title", 2));
        $image->setDesc(process_language_string_save("{$index}-desc", EDITOR_SANITIZE_LEVEL));
        if (isset($_POST[$index . '-oldrotation']) && isset($_POST[$index . '-rotation'])) {
            $oldrotation = (int) $_POST[$index . '-oldrotation'];
            $rotation = (int) $_POST[$index . '-rotation'];
            if ($rotation != $oldrotation) {
                $image->set('EXIFOrientation', $rotation);
                $image->updateDimensions();
                $album = $image->getAlbum();
                Gallery::clearCache(SERVERCACHE . '/' . $album->name);
            }
        }
        if (!$massedit) {
            $image->setLocation(process_language_string_save("{$index}-location", 3));
            $image->setCity(process_language_string_save("{$index}-city", 3));
            $image->setState(process_language_string_save("{$index}-state", 3));
            $image->setCountry(process_language_string_save("{$index}-country", 3));
            $image->setCredit(process_language_string_save("{$index}-credit", 1));
            $image->setCopyright(process_language_string_save("{$index}-copyright", 1));
            $tagsprefix = 'tags_' . $index . '-';
            $tags = array();
            $l = strlen($tagsprefix);
            foreach ($_POST as $key => $value) {
                $key = postIndexDecode($key);
                if (substr($key, 0, $l) == $tagsprefix) {
                    if ($value) {
                        $tags[] = sanitize(substr($key, $l));
                    }
                }
            }
            $tags = array_unique($tags);
            $image->setTags($tags);
            if (zp_loggedin(CODEBLOCK_RIGHTS)) {
                $image->setCodeblock(processCodeblockSave($index));
            }
            $custom = process_language_string_save("{$index}-custom_data", 1);
            $image->setCustomData(zp_apply_filter('save_image_custom_data', $custom, $index));
        }
        $image->setDateTime(sanitize($_POST["{$index}-date"]));
        $image->setShow(isset($_POST["{$index}-Visible"]));
        $image->setCommentsAllowed(isset($_POST["{$index}-allowcomments"]));
        if (isset($_POST["reset_hitcounter{$index}"])) {
            $image->set('hitcounter', 0);
        }
        $wmt = sanitize($_POST["{$index}-image_watermark"], 3);
        $image->setWatermark($wmt);
        $wmuse = 0;
        if (isset($_POST['wm_image-' . $index])) {
            $wmuse = $wmuse | WATERMARK_IMAGE;
        }
        if (isset($_POST['wm_thumb-' . $index])) {
            $wmuse = $wmuse | WATERMARK_THUMB;
        }
        if (isset($_POST['wm_full-' . $index])) {
            $wmuse = $wmuse | WATERMARK_FULL;
        }
        $image->setWMUse($wmuse);
        if (isset($_POST[$index . '-owner'])) {
            $image->setOwner(sanitize($_POST[$index . '-owner']));
        }
        $image->set('filesize', filesize($image->localpath));
        zp_apply_filter('save_image_utilities_data', $image, $index);
        $image->save();
        // Process move/copy/rename
        $folder = $image->getAlbumName();
        if ($movecopyrename_action == 'move') {
            $dest = sanitize_path($_POST[$index . '-albumselect']);
            if ($dest && $dest != $folder) {
                if ($e = $image->move($dest)) {
                    $notify = "&mcrerr=" . $e;
                }
            } else {
                // Cannot move image to same album.
                $notify = "&mcrerr=2";
            }
        } else {
            if ($movecopyrename_action == 'copy') {
                $dest = sanitize_path($_POST[$index . '-albumselect']);
                if ($dest && $dest != $folder) {
                    if ($e = $image->copy($dest)) {
                        $notify = "&mcrerr=" . $e;
                    }
                } else {
                    // Cannot copy image to existing album.
                    // Or, copy with rename?
                    $notify = "&mcrerr=2";
                }
            } else {
                if ($movecopyrename_action == 'rename') {
                    $renameto = sanitize_path($_POST[$index . '-renameto']);
                    if ($e = $image->rename($renameto)) {
                        $notify = "&mcrerr=" . $e;
                    }
                }
            }
        }
    }
    return $notify;
}
Exemplo n.º 7
0
/**
 * Order addon posts.
 *
 * @since	1.4
 * @param	obj		$query		The WP_Query object
 * @return	void
 */
function mdjm_addon_post_order($query)
{
    if (!is_admin() || 'mdjm-addon' != $query->get('post_type')) {
        return;
    }
    $orderby = $query->get('orderby');
    $order = $query->get('order');
    switch ($orderby) {
        case 'ID':
            $query->set('orderby', 'ID');
            $query->set('order', $order);
            break;
        case 'price':
            $query->set('meta_key', '_addon_price');
            $query->set('orderby', 'meta_value_num');
            $query->set('order', $order);
            break;
    }
}
Exemplo n.º 8
0
 /**
  * Set the order for portfolio type taxonomy archives
  *
  * @param  obj $query the query object
  * @return void
  */
 function zilla_set_archive_order($query)
 {
     if ($query->is_tax('portfolio-type') && $query->is_main_query()) {
         $query->set('orderby', 'menu_order');
         $query->set('order', 'ASC');
     }
 }
Exemplo n.º 9
0
/**
 * Hide inactive events from the 'all' events list.
 *
 * @since	1.0
 * @param	obj		$query	The WP_Query.
 * @return	void
 */
function mdjm_hide_inactive_events($query)
{
    if (!is_admin() || !$query->is_main_query() || 'mdjm-event' != $query->get('post_type')) {
        return;
    }
    $active_statuses = mdjm_active_event_statuses();
    if (isset($_GET['post_status']) && in_array($_GET['post_status'], $active_statuses)) {
        return;
    }
    if (!mdjm_get_option('show_active_only', false)) {
        return;
    }
    $active_ids = mdjm_get_events(array('post_status' => $active_statuses, 'fields' => 'ids'));
    if ($active_ids) {
        $query->set('post__in', $active_ids);
    }
}