本文整理汇总了PHP中obj::set方法的典型用法代码示例。如果您正苦于以下问题:PHP obj::set方法的具体用法?PHP obj::set怎么用?PHP obj::set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类obj
的用法示例。
在下文中一共展示了obj::set方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: set_portfolio_post_type_admin_order
/**
* 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');
}
}
}
示例2: mdjm_quote_post_order
/**
* 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;
}
}
示例3: mdjm_venue_post_order
/**
* 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;
}
}
示例4:
/**
* 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;
}
示例5: mdjm_transaction_post_order
/**
* 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;
}
}
示例6: processImageEdit
/**
* 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') {
//.........这里部分代码省略.........
示例7: mdjm_addon_post_order
/**
* 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;
}
}
示例8:
/**
* 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');
}
}
示例9: mdjm_hide_inactive_events
/**
* 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);
}
}