当前位置: 首页>>代码示例>>PHP>>正文


PHP GVCommon::get_template_setting方法代码示例

本文整理汇总了PHP中GVCommon::get_template_setting方法的典型用法代码示例。如果您正苦于以下问题:PHP GVCommon::get_template_setting方法的具体用法?PHP GVCommon::get_template_setting怎么用?PHP GVCommon::get_template_setting使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GVCommon的用法示例。


在下文中一共展示了GVCommon::get_template_setting方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: check_user_cap_edit_entry

 /**
  * checks if user has permissions to edit a specific entry
  *
  * Needs to be used combined with GravityView_Edit_Entry::user_can_edit_entry for maximum security!!
  *
  * @param  array $entry Gravity Forms entry array
  * @param int $view_id ID of the view you want to check visibility against {@since 1.9.2}
  * @return bool
  */
 public static function check_user_cap_edit_entry($entry, $view_id = 0)
 {
     // No permission by default
     $user_can_edit = false;
     // If they can edit any entries (as defined in Gravity Forms)
     // Or if they can edit other people's entries
     // Then we're good.
     if (GVCommon::has_cap(array('gravityforms_edit_entries', 'gravityview_edit_others_entries'), $entry['id'])) {
         do_action('gravityview_log_debug', __METHOD__ . ' - User has ability to edit all entries.');
         $user_can_edit = true;
     } else {
         if (!isset($entry['created_by'])) {
             do_action('gravityview_log_error', 'GravityView_Edit_Entry[check_user_cap_edit_entry] Entry `created_by` doesn\'t exist.');
             $user_can_edit = false;
         } else {
             // get user_edit setting
             if (empty($view_id) || $view_id == GravityView_View::getInstance()->getViewId()) {
                 // if View ID not specified or is the current view
                 $user_edit = GravityView_View::getInstance()->getAtts('user_edit');
             } else {
                 // in case is specified and not the current view
                 $user_edit = GVCommon::get_template_setting($view_id, 'user_edit');
             }
             $current_user = wp_get_current_user();
             // User edit is disabled
             if (empty($user_edit)) {
                 do_action('gravityview_log_debug', 'GravityView_Edit_Entry[check_user_cap_edit_entry] User Edit is disabled. Returning false.');
                 $user_can_edit = false;
             } else {
                 if (is_user_logged_in() && intval($current_user->ID) === intval($entry['created_by'])) {
                     do_action('gravityview_log_debug', sprintf('GravityView_Edit_Entry[check_user_cap_edit_entry] User %s created the entry.', $current_user->ID));
                     $user_can_edit = true;
                 } else {
                     if (!is_user_logged_in()) {
                         do_action('gravityview_log_debug', __METHOD__ . ' No user defined; edit entry requires logged in user');
                     }
                 }
             }
         }
     }
     /**
      * @filter `gravityview/edit_entry/user_can_edit_entry` Modify whether user can edit an entry.
      * @since 1.15 Added `$entry` and `$view_id` parameters
      * @param[in,out] boolean $user_can_edit Can the current user edit the current entry? (Default: false)
      * @param[in] array $entry Gravity Forms entry array {@since 1.15}
      * @param[in] int $view_id ID of the view you want to check visibility against {@since 1.15}
      */
     $user_can_edit = apply_filters('gravityview/edit_entry/user_can_edit_entry', $user_can_edit, $entry, $view_id);
     return (bool) $user_can_edit;
 }
开发者ID:kidaak,项目名称:GravityView,代码行数:59,代码来源:class-edit-entry.php

示例2: gravityview_get_template_setting

/**
 * Get the setting for a View
 *
 * If the setting isn't set by the View, it returns the plugin default.
 *
 * @param  int $post_id View ID
 * @param  string $key     Key for the setting
 * @return mixed|null          Setting value, or NULL if not set.
 */
function gravityview_get_template_setting($post_id, $key)
{
    return GVCommon::get_template_setting($post_id, $key);
}
开发者ID:mgratch,项目名称:GravityView,代码行数:13,代码来源:connector-functions.php

示例3: check_user_cap_edit_entry

 /**
  * checks if user has permissions to edit a specific entry
  *
  * Needs to be used combined with GravityView_Edit_Entry::user_can_edit_entry for maximum security!!
  *
  * @param  array $entry Gravity Forms entry array
  * @param int $view_id ID of the view you want to check visibility against {@since 1.9.2}
  * @return bool
  */
 public static function check_user_cap_edit_entry($entry, $view_id = 0)
 {
     // No permission by default
     $user_can_edit = false;
     // Or if they can edit any entries (as defined in Gravity Forms), we're good.
     if (GFCommon::current_user_can_any('gravityforms_edit_entries')) {
         $user_can_edit = true;
     } else {
         if (!isset($entry['created_by'])) {
             do_action('gravityview_log_error', 'GravityView_Edit_Entry[check_user_cap_edit_entry] Entry `created_by` doesn\'t exist.');
             $user_can_edit = false;
         } else {
             // get user_edit setting
             if (empty($view_id) || $view_id == GravityView_View::getInstance()->getViewId()) {
                 // if View ID not specified or is the current view
                 $user_edit = GravityView_View::getInstance()->getAtts('user_edit');
             } else {
                 // in case is specified and not the current view
                 $user_edit = GVCommon::get_template_setting($view_id, 'user_edit');
             }
             $current_user = wp_get_current_user();
             // User edit is disabled
             if (empty($user_edit)) {
                 do_action('gravityview_log_debug', 'GravityView_Edit_Entry[check_user_cap_edit_entry] User Edit is disabled. Returning false.');
                 $user_can_edit = false;
             } else {
                 if (is_user_logged_in() && intval($current_user->ID) === intval($entry['created_by'])) {
                     do_action('gravityview_log_debug', sprintf('GravityView_Edit_Entry[check_user_cap_edit_entry] User %s created the entry.', $current_user->ID));
                     $user_can_edit = true;
                 }
             }
         }
     }
     /**
      * @param boolean $user_can_edit Can the current user edit the current entry? (Default: false)
      */
     $user_can_edit = apply_filters('gravityview/edit_entry/user_can_edit_entry', $user_can_edit);
     return (bool) $user_can_edit;
 }
开发者ID:roarmoser,项目名称:gv1,代码行数:48,代码来源:class-edit-entry.php


注:本文中的GVCommon::get_template_setting方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。