Overview

Classes

  • Papi_Admin
  • Papi_Admin_Ajax
  • Papi_Admin_Assets
  • Papi_Admin_Management_Pages
  • Papi_Admin_Menu
  • Papi_Admin_Meta_Box
  • Papi_Admin_Meta_Box_Tabs
  • Papi_Admin_Option_Handler
  • Papi_Admin_Post_Handler
  • Papi_Admin_View
  • Papi_Attachment_Type
  • Papi_Conditional_Rules
  • Papi_Container
  • Papi_Core_Autoload
  • Papi_Core_Conditional
  • Papi_Core_Conditional_Rule
  • Papi_Core_Data_Handler
  • Papi_Core_Page
  • Papi_Core_Property
  • Papi_Core_Type
  • Papi_Loader
  • Papi_Option_Page
  • Papi_Option_Type
  • Papi_Page_Type
  • Papi_Page_Type_Meta
  • Papi_Porter
  • Papi_Porter_Driver
  • Papi_Porter_Driver_Core
  • Papi_Post_Page
  • Papi_Property
  • Papi_Property_Bool
  • Papi_Property_Checkbox
  • Papi_Property_Color
  • Papi_Property_Datetime
  • Papi_Property_Divider
  • Papi_Property_Dropdown
  • Papi_Property_Editor
  • Papi_Property_Email
  • Papi_Property_File
  • Papi_Property_Flexible
  • Papi_Property_Gallery
  • Papi_Property_Hidden
  • Papi_Property_Html
  • Papi_Property_Image
  • Papi_Property_Link
  • Papi_Property_Number
  • Papi_Property_Post
  • Papi_Property_Radio
  • Papi_Property_Reference
  • Papi_Property_Relationship
  • Papi_Property_Repeater
  • Papi_Property_String
  • Papi_Property_Term
  • Papi_Property_Text
  • Papi_Property_Url
  • Papi_Property_User

Functions

  • current_page
  • papi
  • papi_action_delete_value
  • papi_action_include
  • papi_append_post_type_query
  • papi_body_class
  • papi_cache_delete
  • papi_cache_get
  • papi_cache_key
  • papi_cache_set
  • papi_camel_case
  • papi_cast_string_value
  • papi_convert_to_string
  • papi_current_user_is_allowed
  • papi_dashify
  • papi_delete_field
  • papi_delete_option
  • papi_delete_property_meta_value
  • papi_display_page_type
  • papi_doing_ajax
  • papi_esc_html
  • papi_f
  • papi_field
  • papi_field_shortcode
  • papi_field_value
  • papi_fields
  • papi_filter_conditional_rule_allowed
  • papi_filter_core_load_one_type_on
  • papi_filter_format_value
  • papi_filter_load_value
  • papi_filter_settings_directories
  • papi_filter_settings_only_page_type
  • papi_filter_settings_page_type_column_title
  • papi_filter_settings_show_page_type
  • papi_filter_settings_show_standard_page_type
  • papi_filter_settings_show_standard_page_type_in_filter
  • papi_filter_settings_sort_order
  • papi_filter_settings_standard_page_description
  • papi_filter_settings_standard_page_name
  • papi_filter_settings_standard_page_thumbnail
  • papi_filter_update_value
  • papi_from_property_array_slugs
  • papi_get_all_files_in_directory
  • papi_get_all_page_type_files
  • papi_get_all_page_types
  • papi_get_box_property
  • papi_get_class_name
  • papi_get_field
  • papi_get_file_path
  • papi_get_number_of_pages
  • papi_get_only_objects
  • papi_get_option
  • papi_get_options_and_properties
  • papi_get_or_post
  • papi_get_page
  • papi_get_page_new_url
  • papi_get_page_query_strings
  • papi_get_page_type
  • papi_get_page_type_base_path
  • papi_get_page_type_by_id
  • papi_get_page_type_by_post_id
  • papi_get_page_type_id
  • papi_get_page_type_key
  • papi_get_page_type_meta_value
  • papi_get_page_type_name
  • papi_get_page_type_template
  • papi_get_parent_post_id
  • papi_get_post_id
  • papi_get_post_type
  • papi_get_post_type_label
  • papi_get_post_types
  • papi_get_property_class_name
  • papi_get_property_meta_value
  • papi_get_property_options
  • papi_get_property_type
  • papi_get_property_type_key
  • papi_get_property_type_key_f
  • papi_get_qs
  • papi_get_sanitized_post
  • papi_get_slugs
  • papi_get_tab_options
  • papi_html_name
  • papi_html_tag
  • papi_include_template
  • papi_is_empty
  • papi_is_json
  • papi_is_method
  • papi_is_option_page
  • papi_is_option_type
  • papi_is_page_type
  • papi_is_property
  • papi_is_property_type_key
  • papi_is_rule
  • papi_management_page_type_render_box
  • papi_maybe_convert_to_array
  • papi_maybe_convert_to_object
  • papi_maybe_get_callable_value
  • papi_maybe_json_decode
  • papi_maybe_json_encode
  • papi_nl2br
  • papi_option_shortcode
  • papi_option_type_exists
  • papi_page_type_exists
  • papi_populate_properties
  • papi_property
  • papi_remove_papi
  • papi_remove_trailing_quotes
  • papi_render_html_tag
  • papi_render_properties
  • papi_render_property
  • papi_require_text
  • papi_required_html
  • papi_rule
  • papi_santize_data
  • papi_set_page_type_id
  • papi_setup_tabs
  • papi_slugify
  • papi_sort_order
  • papi_tab
  • papi_template
  • papi_template_include
  • papi_to_array
  • papi_to_property_array_slugs
  • papi_translate_keys
  • papi_underscorify
  • papi_update_field
  • papi_update_option
  • papi_update_property_meta_value
  • papi_with
  • papify
  • the_papi_field
  • the_papi_option
  • the_papi_page_type_name
  • Overview
  • Class
  1: <?php
  2: 
  3: // Load Papi Container.
  4: require_once __DIR__ . '/container/class-papi-container.php';
  5: 
  6: /**
  7:  * Papi loader class that handle the loading
  8:  * of the plugin.
  9:  */
 10: final class Papi_Loader extends Papi_Container {
 11: 
 12:     /**
 13:      * The instance of Papi loader class.
 14:      *
 15:      * @var Papi_Loader
 16:      */
 17:     private static $instance;
 18: 
 19:     /**
 20:      * The plugin name.
 21:      *
 22:      * @var string
 23:      */
 24:     public $name = 'Papi';
 25: 
 26:     /**
 27:      * Papi loader instance.
 28:      *
 29:      * @return Papi_Loader
 30:      */
 31:     public static function instance() {
 32:         if ( ! isset( self::$instance ) ) {
 33:             self::$instance = new self;
 34:         }
 35: 
 36:         return self::$instance;
 37:     }
 38: 
 39:     /**
 40:      * Call function in the container.
 41:      *
 42:      * @param  string $name
 43:      * @param  array  $arguments
 44:      *
 45:      * @return mixed
 46:      */
 47:     public function __call( $name, $arguments ) {
 48:         return $this->make( $name, $arguments );
 49:     }
 50: 
 51:     /**
 52:      * The constructor.
 53:      */
 54:     private function __construct() {
 55:         $this->constants();
 56:         $this->setup_actions();
 57:         $this->load_textdomain();
 58:         $this->require_files();
 59:         $this->setup_container();
 60:         papi_action_include();
 61:     }
 62: 
 63:     /**
 64:      * Cloning is forbidden.
 65:      *
 66:      * @codeCoverageIgnore
 67:      */
 68:     public function __clone() {
 69:         _doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?', 'papi' ), '2.4.2' );
 70:     }
 71: 
 72:     /**
 73:      * Unserializing instances of this class is forbidden.
 74:      *
 75:      * @codeCoverageIgnore
 76:      */
 77:     public function __wakeup() {
 78:         _doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?', 'papi' ), '2.4.2' );
 79:     }
 80: 
 81:     /**
 82:      * Bootstrap constants
 83:      */
 84:     private function constants() {
 85:         // Path to Papi plugin directory
 86:         if ( ! defined( 'PAPI_PLUGIN_DIR' ) ) {
 87:             $mu_dir = trailingslashit( sprintf( '%s/%s/src',
 88:                 WPMU_PLUGIN_DIR,
 89:                 basename( dirname( __DIR__ ) )
 90:             ) );
 91: 
 92:             if ( is_dir( $mu_dir ) ) {
 93:                 define( 'PAPI_PLUGIN_DIR', $mu_dir );
 94:             } else {
 95:                 define( 'PAPI_PLUGIN_DIR', trailingslashit( __DIR__ ) );
 96:             }
 97:         }
 98: 
 99:         // URL to Papi plugin directory
100:         if ( ! defined( 'PAPI_PLUGIN_URL' ) ) {
101:             $plugin_url = plugin_dir_url( __FILE__ );
102: 
103:             if ( is_ssl() ) {
104:                 $plugin_url = str_replace( 'http://', 'https://', $plugin_url );
105:             }
106: 
107:             define( 'PAPI_PLUGIN_URL', $plugin_url );
108:         }
109: 
110:         // The meta key that page type value is using
111:         if ( ! defined( 'PAPI_PAGE_TYPE_KEY' ) ) {
112:             define( 'PAPI_PAGE_TYPE_KEY', '_papi_page_type' );
113:         }
114:     }
115: 
116:     /**
117:      * Load Localisation files.
118:      *
119:      * Locales found in:
120:      * - WP_LANG_DIR/papi/papi-LOCALE.mo
121:      * - WP_CONTENT_DIR/[mu-]plugins/papi/languages/papi-LOCALE.mo
122:      */
123:     private function load_textdomain() {
124:         $locale = apply_filters( 'plugin_locale', get_locale(), 'papi' );
125:         load_textdomain( 'papi', WP_LANG_DIR . '/papi/papi-' . $locale . '.mo' );
126:         load_textdomain( 'papi', PAPI_PLUGIN_DIR . '../languages/papi-' . $locale . '.mo' );
127:     }
128: 
129:     /**
130:      * Require files.
131:      */
132:     private function require_files() {
133:         // Require the autoload class.
134:         require_once __DIR__ . '/core/class-papi-core-autoload.php';
135: 
136:         $lib_path     = __DIR__ . '/lib/';
137:         $lib_includes = [
138:             'utilities.php',
139:             'actions.php',
140:             'cache.php',
141:             'filters.php',
142:             'url.php',
143:             'post.php',
144:             'page.php',
145:             'property.php',
146:             'tabs.php',
147:             'io.php',
148:             'field.php',
149:             'template.php',
150:             'option.php',
151:             'deprecated.php',
152:             'conditional.php'
153:         ];
154: 
155:         // Require function files.
156:         foreach ( $lib_includes as $file ) {
157:             if ( file_exists( $lib_path . $file ) ) {
158:                 require_once $lib_path . $file;
159:             }
160:         }
161: 
162:         unset( $file );
163: 
164:         // Require admin classes that should not be loaded by the autoload.
165:         require_once __DIR__ . '/admin/class-papi-admin.php';
166:         require_once __DIR__ . '/admin/class-papi-admin-assets.php';
167:         require_once __DIR__ . '/admin/class-papi-admin-menu.php';
168: 
169:         // Require conditional rules that should not be loaded by the autoload.
170:         require_once __DIR__ . '/conditional/class-papi-conditional-rules.php';
171:     }
172: 
173:     /**
174:      * Deactivate Papi if the WordPress version is lower then 4.0.
175:      */
176:     public static function deactivate() {
177:         // Remove Papi from plugins_loaded action.
178:         remove_action( 'plugins_loaded', 'papi' );
179: 
180:         // Load is_plugin_active and deactivate_plugins.
181:         if ( ! function_exists( 'is_plugin_active' ) ) {
182:             include_once ABSPATH . 'wp-admin/includes/plugin.php';
183:         }
184: 
185:         $plugin_path = plugin_basename( __DIR__ . '/../' . basename( __FILE__ ) );
186: 
187:         // If the plugin is active then deactivate it.
188:         if ( is_plugin_active( $plugin_path ) ) {
189:             deactivate_plugins( $plugin_path );
190:         }
191: 
192:         wp_die( __( 'WordPress 4.0 and higher required to run Papi! The plugin has now disabled itself.', 'papi' ) );
193:     }
194: 
195:     /**
196:      * Setup actions.
197:      */
198:     private function setup_actions() {
199:         add_action( 'after_setup_theme', 'papi_action_include' );
200:     }
201: 
202:     /**
203:      * Setup container.
204:      */
205:     private function setup_container() {
206:         $this->singleton( 'porter', new Papi_Porter );
207:     }
208: }
209: 
210: /**
211:  * Return the instance of Papi to everyone.
212:  *
213:  * @return Papi_Loader
214:  */
215: function papi() {
216:     if ( version_compare( get_bloginfo( 'version' ), '4.0', '<' ) ) {
217:         Papi_Loader::deactivate();
218:     }
219: 
220:     return Papi_Loader::instance();
221: }
222: 
223: add_action( 'plugins_loaded', 'papi' );
224: 
API documentation generated by ApiGen