コード例 #1
0
ファイル: PodsForm.php プロジェクト: erkmen/wpstartersetup
 /**
  * Check if a user has permission to be editing a field
  *
  * @param $type
  * @param null $name
  * @param null $options
  * @param null $fields
  * @param null $pod
  * @param null $id
  * @param null $params
  *
  * @static
  *
  * @since 2.0
  */
 public static function permission($type, $name = null, $options = null, $fields = null, $pod = null, $id = null, $params = null)
 {
     $permission = pods_permission($options);
     $permission = (bool) apply_filters('pods_form_field_permission', $permission, $type, $name, $options, $fields, $pod, $id, $params);
     return $permission;
 }
コード例 #2
0
ファイル: Pages.php プロジェクト: erkmen/wpstartersetup
 /**
  * Run any precode for current Pod Page
  */
 public function precode()
 {
     global $pods;
     // Fix any global confusion wherever this runs
     if (isset($pods) && !isset($GLOBALS['pods'])) {
         $GLOBALS['pods'] =& $pods;
     } elseif (!isset($pods) && isset($GLOBALS['pods'])) {
         $pods =& $GLOBALS['pods'];
     }
     if (false !== self::$exists) {
         $permission = pods_permission(self::$exists['options']);
         $permission = (bool) apply_filters('pods_pages_permission', $permission, self::$exists);
         if ($permission) {
             $content = false;
             if (!is_object($pods) && 404 != $pods && 0 < strlen(pods_var('pod', self::$exists['options']))) {
                 $slug = pods_var_raw('pod_slug', self::$exists['options'], null, null, true);
                 // Handle special magic tags
                 if (0 < strlen($slug)) {
                     $slug = pods_evaluate_tags($slug, true);
                 }
                 $pods = pods(pods_var('pod', self::$exists['options']), $slug);
                 // Auto 404 handling if item doesn't exist
                 if (0 < strlen($slug) && !$pods->exists() && apply_filters('pods_pages_auto_404', true, $slug, $pods, self::$exists)) {
                     $pods = 404;
                 }
             }
             if (0 < strlen(trim(self::$exists['precode']))) {
                 $content = self::$exists['precode'];
             }
             if (false !== $content && (!defined('PODS_DISABLE_EVAL') || !PODS_DISABLE_EVAL)) {
                 pods_deprecated('Pod Page Precode has been deprecated, please use WP Page Templates or hook into the pods_content filter instead of embedding PHP.', '2.1');
                 eval("?>{$content}");
             }
             do_action('pods_page_precode', self::$exists, $pods, $content);
         } elseif (self::$exists['options']['restrict_redirect']) {
             $redirect_url = '';
             if (self::$exists['options']['restrict_redirect_login']) {
                 $redirect_url = wp_login_url(pods_current_url());
             } elseif (!empty(self::$exists['options']['restrict_redirect_url'])) {
                 $redirect_url = self::$exists['options']['restrict_redirect_url'];
             }
             if (!empty($redirect_url)) {
                 wp_redirect($redirect_url);
                 die;
             }
         }
         if (!$permission || !is_object($pods) && (404 == $pods || is_wp_error($pods))) {
             remove_action('template_redirect', array($this, 'template_redirect'));
             remove_action('wp_head', array($this, 'wp_head'));
             remove_filter('redirect_canonical', '__return_false');
             remove_filter('wp_title', array($this, 'wp_title'));
             remove_filter('body_class', array($this, 'body_class'));
             remove_filter('status_header', array($this, 'status_header'));
             remove_action('wp', array($this, 'silence_404'), 1);
         }
     }
 }
コード例 #3
0
ファイル: Pages.php プロジェクト: centaurustech/chipin
 /**
  * Run any precode for current Pod Page
  */
 public function precode()
 {
     global $pods;
     // Fix any global confusion wherever this runs
     if (isset($pods) && !isset($GLOBALS['pods'])) {
         $GLOBALS['pods'] =& $pods;
     } elseif (!isset($pods) && isset($GLOBALS['pods'])) {
         $pods =& $GLOBALS['pods'];
     }
     if (false !== self::$exists) {
         $permission = pods_permission(self::$exists['options']);
         $permission = (bool) apply_filters('pods_pages_permission', $permission, self::$exists);
         if ($permission) {
             $content = false;
             if (!is_object($pods) && 404 != $pods && 0 < strlen(pods_var('pod', self::$exists['options']))) {
                 $pods = pods(pods_var('pod', self::$exists['options']), pods_evaluate_tags(pods_var_raw('pod_slug', self::$exists['options'], null, null, true), true));
             }
             if (0 < strlen(trim(self::$exists['precode']))) {
                 $content = self::$exists['precode'];
             }
             if (false !== $content && (!defined('PODS_DISABLE_EVAL') || !PODS_DISABLE_EVAL)) {
                 pods_deprecated('Use WP Page Templates or hook into the pods_page_precode action instead of using Pod Page Precode', '2.1');
                 eval("?>{$content}");
             }
             do_action('pods_page_precode', self::$exists, $pods, $content);
         }
         if (!$permission || !is_object($pods) && (404 == $pods || is_wp_error($pods))) {
             remove_action('template_redirect', array($this, 'template_redirect'));
             remove_action('wp_head', array($this, 'wp_head'));
             remove_filter('redirect_canonical', '__return_false');
             remove_filter('wp_title', array($this, 'wp_title'));
             remove_filter('body_class', array($this, 'body_class'));
             remove_filter('status_header', array($this, 'status_header'));
             remove_action('wp', array($this, 'silence_404'));
         }
     }
 }
コード例 #4
0
ファイル: Templates.php プロジェクト: erkmen/wpstartersetup
 /**
  * Display the page template
  *
  * @param string $template_name The template name
  * @param string $code Custom template code to use instead
  * @param object $obj The Pods object
  * @param bool $deprecated Whether to use deprecated functionality based on old function usage
  *
  * @return mixed|string|void
  * @since 2.0
  */
 public static function template($template_name, $code = null, $obj = null, $deprecated = false)
 {
     if (!empty($obj)) {
         self::$obj =& $obj;
     } else {
         $obj =& self::$obj;
     }
     self::$deprecated = $deprecated;
     if (empty($obj) || !is_object($obj)) {
         return '';
     }
     $template = array('id' => 0, 'slug' => $template_name, 'code' => $code, 'options' => array());
     if (empty($code) && !empty($template_name)) {
         $template_obj = $obj->api->load_template(array('name' => $template_name));
         if (!empty($template_obj)) {
             $template = $template_obj;
             if (!empty($template['code'])) {
                 $code = $template['code'];
             }
             $permission = pods_permission($template['options']);
             $permission = (bool) apply_filters('pods_templates_permission', $permission, $code, $template, $obj);
             if (!$permission) {
                 return apply_filters('pods_templates_permission_denied', __('You do not have access to view this content.', 'pods'), $code, $template, $obj);
             }
         }
     }
     $code = apply_filters('pods_templates_pre_template', $code, $template, $obj);
     $code = apply_filters('pods_templates_pre_template_' . $template['slug'], $code, $template, $obj);
     ob_start();
     if (!empty($code)) {
         // Only detail templates need $this->id
         if (empty($obj->id)) {
             while ($obj->fetch()) {
                 echo self::do_template($code, $obj);
             }
         } else {
             echo self::do_template($code, $obj);
         }
     } elseif ($template_name == trim(preg_replace('/[^a-zA-Z0-9_\\-\\/]/', '', $template_name), ' /-')) {
         $default_templates = array('pods/' . $template_name, 'pods-' . $template_name, $template_name);
         $default_templates = apply_filters('pods_template_default_templates', $default_templates);
         if (empty($obj->id)) {
             while ($obj->fetch()) {
                 pods_template_part($default_templates, compact(array_keys(get_defined_vars())));
             }
         } else {
             pods_template_part($default_templates, compact(array_keys(get_defined_vars())));
         }
     }
     $out = ob_get_clean();
     $out = apply_filters('pods_templates_post_template', $out, $code, $template, $obj);
     $out = apply_filters('pods_templates_post_template_' . $template['slug'], $out, $code, $template, $obj);
     return $out;
 }
コード例 #5
0
ファイル: Templates.php プロジェクト: centaurustech/chipin
 /**
  * Display the page template
  *
  * @param string $template The template name
  * @param string $code Custom template code to use instead
  * @param object $obj The Pods object
  * @param bool $deprecated Whether to use deprecated functionality based on old function usage
  *
  * @return mixed|string|void
  * @since 2.0
  */
 public static function template($template, $code = null, $obj = null, $deprecated = false)
 {
     if (!empty($obj)) {
         self::$obj =& $obj;
     } else {
         $obj =& self::$obj;
     }
     self::$deprecated = $deprecated;
     if (empty($obj) || !is_object($obj)) {
         return '';
     }
     if (empty($code) && !empty($template)) {
         $template = $obj->api->load_template(array('name' => $template));
         if (!empty($template)) {
             if (!empty($template['code'])) {
                 $code = $template['code'];
             }
             $permission = pods_permission($template['options']);
             $permission = (bool) apply_filters('pods_templates_permission', $permission, $code, $template, $obj);
             if (!$permission) {
                 return apply_filters('pods_templates_permission_denied', __('You do not have access to view this content.', 'pods'), $code, $template, $obj);
             }
         }
     }
     $code = apply_filters('pods_templates_pre_template', $code, $template, $obj);
     $code = apply_filters('pods_templates_pre_template_' . $template['slug'], $code, $template, $obj);
     ob_start();
     if (!empty($code)) {
         // Only detail templates need $this->id
         if (empty($obj->id)) {
             while ($obj->fetch()) {
                 echo self::do_template($code, $obj);
             }
         } else {
             echo self::do_template($code, $obj);
         }
     }
     $out = ob_get_clean();
     $out = apply_filters('pods_templates_post_template', $out, $code, $template, $obj);
     $out = apply_filters('pods_templates_post_template_' . $template['slug'], $out, $code, $template, $obj);
     return $out;
 }