コード例 #1
0
ファイル: general.php プロジェクト: Ingenex/redesign
/**
 * Determine if Strict Mode is enabled
 *
 * @param bool $include_debug Whether to include WP_DEBUG in strictness level
 *
 * @return bool Whether Strict Mode is enabled
 *
 * @since 2.3.5
 */
function pods_strict($include_debug = true)
{
    if (defined('PODS_STRICT') && PODS_STRICT) {
        return true;
    } elseif (pods_allow_deprecated(false) && defined('PODS_STRICT_MODE') && PODS_STRICT_MODE) {
        return true;
    } elseif ($include_debug && defined('WP_DEBUG') && WP_DEBUG) {
        return true;
    }
    return false;
}
コード例 #2
0
ファイル: PodsObject.php プロジェクト: Ingenex/redesign
 /**
  * Get value from array usage $object['offset'];
  *
  * @param mixed $offset Used to get value of Array
  *
  * @return mixed|null
  *
  * @since 2.3.10
  */
 public function offsetGet($offset)
 {
     if (!empty($this->_methods) && in_array($offset, $this->_methods)) {
         $value = call_user_func(array($this, $offset));
     } elseif ('options' == $offset) {
         $value = null;
         if (pods_allow_deprecated()) {
             $value = $this->_object;
         }
     } elseif (isset($this->_object[$offset])) {
         $value = $this->_object[$offset];
         if (!$this->_live) {
             // i18n plugin integration
             if ('label' == $offset || 0 === strpos($offset, 'label_')) {
                 $value = __($value);
             }
         }
     } elseif (isset($this->_addtl[$offset])) {
         $value = $this->_addtl[$offset];
         if (!$this->_live) {
             // i18n plugin integration
             if ('label' == $offset || 0 === strpos($offset, 'label_')) {
                 $value = __($value);
             }
         }
     } elseif (isset($this->_deprecated_keys[$offset])) {
         $value = null;
         if (pods_allow_deprecated()) {
             $value = $this->offsetGet($this->_deprecated_keys[$offset]);
         } else {
             pods_deprecated('$object[\'' . $offset . '\']', '2.0', '$object[\'' . $this->_deprecated_keys[$offset] . '\']');
         }
     } else {
         $value = $this->_meta($offset);
         if (null !== $value) {
             $this->_addtl[$offset] = $value;
         }
     }
     return $value;
 }
コード例 #3
0
ファイル: init.php プロジェクト: ngdinhbinh/fine-interior
    define('PODS_SLUG', plugin_basename(__FILE__));
    define('PODS_URL', plugin_dir_url(__FILE__));
    define('PODS_DIR', plugin_dir_path(__FILE__));
    // Prevent conflicts with old Pods UI plugin
    if (function_exists('pods_ui_manage')) {
        add_action('init', 'pods_deactivate_pods_ui');
    } else {
        global $pods, $pods_init, $pods_form;
        require_once PODS_DIR . 'includes/classes.php';
        require_once PODS_DIR . 'includes/data.php';
        require_once PODS_DIR . 'includes/general.php';
        if (!defined('PODS_MEDIA') || PODS_MEDIA) {
            require_once PODS_DIR . 'includes/media.php';
        }
        if (!defined('SHORTINIT') || !SHORTINIT) {
            if (pods_allow_deprecated()) {
                require_once PODS_DIR . 'deprecated/deprecated.php';
            }
            if (false !== pods_compatibility_check()) {
                $pods_form = pods_form();
                if (!is_network_admin()) {
                    $pods_init = pods_init();
                }
            }
        }
    }
}
/**
 * Deactivate Pods 1.x or other Pods plugins
 */
function pods_deactivate_pods_1_x()
コード例 #4
0
ファイル: PodsObject_Field.php プロジェクト: Ingenex/redesign
 /**
  * Load the object
  *
  * @param string|array|WP_Post $name Get the Object by Name, or pass an array/WP_Post of Object
  * @param int $id Get the Object by ID (overrides $name)
  * @param mixed $parent Parent Object or ID
  *
  * @return int|bool $id The Object ID or false if Object not found
  */
 public function load($name = null, $id = 0, $parent = null)
 {
     // Post Object
     $_object = false;
     // Custom Object
     $object = false;
     // Allow for refresh of object
     if (null === $name && 0 == $id && null === $parent && $this->is_valid()) {
         $id = $this->_object['id'];
         $this->destroy();
     }
     // Parent ID passed
     $parent_id = $parent;
     // Parent object passed
     if (is_object($parent_id) && isset($parent_id->id)) {
         $parent_id = $parent_id->id;
     } elseif (is_array($parent_id) && isset($parent_id['id'])) {
         $parent_id = $parent_id['id'];
     }
     $parent_id = (int) $parent_id;
     // Object ID passed
     if (0 < $id) {
         $_object = get_post((int) $id, ARRAY_A);
         // Fallback to Object name
         if (empty($_object) || $this->_post_type != $_object['post_type']) {
             return $this->load($name, 0);
         }
     } elseif (is_object($name) && 'WP_Post' == get_class($name) && $this->_post_type == $name->post_type) {
         $_object = get_object_vars($name);
     } elseif (is_object($name) && isset($name->post_type) && $this->_post_type == $name->post_type) {
         $_object = get_post((int) $name->ID, ARRAY_A);
     } elseif (is_array($name)) {
         $object = $name;
     } else {
         $find_args = array('name' => $name, 'post_type' => $this->_post_type, 'posts_per_page' => 1, 'post_parent' => $parent_id);
         $find_object = get_posts($find_args);
         // Object found
         if (!empty($find_object) && is_array($find_object)) {
             /**
              * @var WP_Post $_object
              */
             $_object = $find_object[0];
             if ('WP_Post' == get_class($_object)) {
                 $_object = $_object->to_array();
             } else {
                 $_object = get_object_vars($_object);
             }
         }
     }
     if (!empty($_object) || !empty($object)) {
         $defaults = array('id' => 0, 'name' => '', 'label' => '', 'description' => '', 'type' => 'text', 'weight' => 0, 'parent_id' => $parent_id);
         if (!empty($_object)) {
             $object = array('id' => $_object['ID'], 'name' => $_object['post_name'], 'label' => $_object['post_title'], 'description' => $_object['post_content'], 'parent_id' => $_object['post_parent'], 'type' => 'text');
         }
         $object = array_merge($defaults, $object);
         if (strlen($object['label']) < 1) {
             $object['label'] = $object['name'];
         }
         $tableless_meta = array('pick_object', 'pick_val', 'sister_id');
         if (0 < $object['id']) {
             $meta = array('type');
             foreach ($meta as $meta_key) {
                 $value = $this->_meta($meta_key, $object['id'], true);
                 if (null !== $value) {
                     $object[$meta_key] = $value;
                 }
             }
             if (empty($object['type'])) {
                 $object['type'] = 'text';
             }
             if (in_array($object['type'], PodsForm::tableless_field_types())) {
                 foreach ($tableless_meta as $meta_key) {
                     $value = $this->_meta($meta_key, $object['id'], true);
                     if (null !== $value) {
                         $object[$meta_key] = $value;
                     }
                 }
                 // Backwards compatibility
                 if (pods_allow_deprecated() && !isset($object['sister_id'])) {
                     $meta_key = 'sister_field_id';
                     $value = $this->_meta($meta_key, $object['id']);
                     if (null !== $value) {
                         $object[$meta_key] = $value;
                     }
                 }
             } else {
                 foreach ($tableless_meta as $meta_key) {
                     $object[$meta_key] = '';
                 }
             }
         }
         if (in_array($object['type'], PodsForm::tableless_field_types())) {
             if ($object['id'] < 1) {
                 // Backwards compatibility
                 if (pods_allow_deprecated() && !isset($object['sister_id']) && isset($object['sister_field_id'])) {
                     $object['sister_id'] = $object['sister_field_id'];
                     unset($object['sister_field_id']);
                 }
             }
             foreach ($tableless_meta as $meta_key) {
                 if (!isset($tableless_meta[$meta_key]) || empty($object['pick_object'])) {
                     $object[$meta_key] = '';
                 }
             }
         }
         $this->_object = $object;
         return $this->_object['id'];
     }
     return false;
 }