_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
33
8k
language
stringclasses
1 value
meta_information
dict
q256800
Papi_Property_String.get_value
test
public function get_value() { $value = $this->format_value( parent::get_value(),
php
{ "resource": "" }
q256801
Papi_Core_Data_Handler.decode_property
test
protected function decode_property( $key, $value ) { if ( papi_is_property_type_key( $key )
php
{ "resource": "" }
q256802
Papi_Core_Data_Handler.get_post_data
test
protected function get_post_data( $pattern = '/^papi\_.*/' ) { $data = []; $keys = preg_grep( $pattern, array_keys( $_POST ) ); foreach ( $keys as $key ) { // Remove page type keys with suffix. This should not be saved. if ( strpos( $key, papi_get_page_type_key() ) === 0 && strlen( papi_get_pag...
php
{ "resource": "" }
q256803
Papi_Core_Data_Handler.get_pre_deep_keys_value
test
protected function get_pre_deep_keys_value( array $arr ) { $keys = []; $value = null; foreach ( $arr as $key => $v ) { if ( is_array( $v ) ) { $keys[] = $key; list( $ks, $val ) = $this->get_pre_deep_keys_value( $v );
php
{ "resource": "" }
q256804
Papi_Core_Data_Handler.prepare_post_data
test
protected function prepare_post_data( $data ) { if ( ! is_array( $data ) ) { return $data; } foreach ( $data as $key => $value ) { if ( is_array( $value ) ) { $data[$key]
php
{ "resource": "" }
q256805
Papi_Core_Data_Handler.prepare_properties_data
test
protected function prepare_properties_data( array $data = [], $post_id = 0 ) { // Since we are storing witch property it is in the `$data` array // we need to remove that and set the property type to the property // and make a array of the property type and the value. foreach ( $data as $key => $value ) { if...
php
{ "resource": "" }
q256806
Papi_Core_Data_Handler.santize_data
test
protected function santize_data( $value ) { if ( is_array( $value ) ) { foreach ( $value as $k => $v ) { if ( is_string( $v ) ) { $value[$k] = $this->santize_data( $v );
php
{ "resource": "" }
q256807
Papi_Core_Data.delete
test
public function delete( $id, $slug ) { $fn = $this->get_function( 'delete' ); // Check so the function is callable before using it. if ( ! is_callable( $fn ) ) { return false; } // Delete cached value. papi_cache_delete( $slug, $id, $this->type );
php
{ "resource": "" }
q256808
Papi_Core_Data.get_function
test
public function get_function( $context = 'get' ) { switch ( $this->type ) { case 'option': return sprintf( '%s_option', $context ); case 'site': case 'network': return sprintf( '%s_site_option',
php
{ "resource": "" }
q256809
Papi_Core_Data.get
test
public function get( $id, $slug ) { $fn = $this->get_function( 'get' ); if ( ! is_callable( $fn ) ) { return; } if ( $this->id ) { $value = call_user_func_array( $fn, [$this->type, $id, unpapify( $slug ), true] ); } else {
php
{ "resource": "" }
q256810
Papi_Core_Data.update
test
public function update( $id, $slug, $value ) { $save_value = true; // Get right update function to use. $fn = $this->get_function( 'update' ); if ( ! is_callable( $fn ) ) { return false; } // Check for string keys in the array if any. foreach ( array_keys( papi_to_array( $value ) ) as $key ) { if...
php
{ "resource": "" }
q256811
Papi_Core_Data.update_clear_cache
test
public function update_clear_cache( $id, $value ) { $value = is_array( $value ) ? $value : []; foreach ( $value as $child_key => $child_value ) { papi_cache_delete( $child_key, $id, $this->type ); if (
php
{ "resource": "" }
q256812
Papi_Admin_Entry_Post.get_revision_ui_diff
test
public function get_revision_ui_diff( $return, $compare_from, $compare_to ) { $meta = get_post_meta( $compare_from->ID ); $meta = is_array( $meta ) ? $meta : []; foreach ( $meta as $key => $value ) { if ( $key[0] === '_' && $key !== papi_get_page_type_key() ) { continue; } $content_from = papi_data...
php
{ "resource": "" }
q256813
Papi_Admin_Entry_Post.hidden_meta_boxes
test
public function hidden_meta_boxes() { global $_wp_post_type_features; if ( isset( $_wp_post_type_features[$this->post_type]['editor'] ) ) { return;
php
{ "resource": "" }
q256814
Papi_Admin_Entry_Post.load_post_new
test
public function load_post_new() { $request_uri = $_SERVER['REQUEST_URI']; $post_types = papi_get_post_types(); if ( in_array( $this->post_type, $post_types, true ) && strpos( $request_uri, 'page_type=' ) === false ) { $parsed_url = parse_url( $request_uri ); $only_page_type = papi_filter_settings_only_pa...
php
{ "resource": "" }
q256815
Papi_Admin_Entry_Post.redirect_post_location
test
public function redirect_post_location( $location ) { if ( ! isset( $_SERVER['HTTP_REFERER'] ) ) { return $location; } $referer = $_SERVER['HTTP_REFERER'];
php
{ "resource": "" }
q256816
Papi_Admin_Entry_Post.setup
test
public function setup() { // Preload all page types. foreach ( papi_get_post_types() as $post_type ) { papi_get_all_entry_types( [ 'args' => $post_type ]
php
{ "resource": "" }
q256817
Papi_CLI_Post_Command.rename
test
public function rename( $args, $assoc_args ) { $type = $args[0]; $old_key = $args[1]; $new_key = $args[2]; $posts = ( new Papi_Query( [ 'entry_type' => $type, 'fields' => 'ids' ] ) )->get_result(); if ( empty( $posts ) ) { WP_CLI::error( 'No posts found' ); } foreach ( $posts as $post...
php
{ "resource": "" }
q256818
Papi_Core_Conditional_Rule.get_field_slug
test
public function get_field_slug() { if ( preg_match( '/\[|\]/', $this->slug ) ) { $slug = preg_replace( '/\[|\]/', '.', $this->slug ); $slug =
php
{ "resource": "" }
q256819
Papi_Core_Conditional_Rule.get_source
test
public function get_source() { if ( is_callable( $this->source ) ) { return call_user_func_array( $this->source, [$this->slug] ); } if ( is_string( $this->source ) && strpos( $this->source, '#' ) !== false ) { $source = explode( '#', $this->source ); if ( empty( $source[0] ) || empty( $source[1] ) ) { ...
php
{ "resource": "" }
q256820
Papi_Core_Conditional_Rule.setup_source
test
public function setup_source( $value ) { if ( is_array( $value ) && count( $value ) === 2 && is_object( $value[0] ) && is_string( $value[1] ) ) { return sprintf( '%s#%s', get_class( $value[0]
php
{ "resource": "" }
q256821
Papi_Core_Conditional_Rule.setup
test
protected function setup( array $rule ) { foreach ( $rule as $key => $value ) { if ( $key === 'operator' ) { $value = strtoupper( $value );
php
{ "resource": "" }
q256822
Papi_Admin.admin_init
test
public function admin_init() { $meta_type = papi_get_meta_type(); $meta_type = ucfirst( $meta_type ); $class_name = 'Papi_Admin_Entry_' . $meta_type; // A custom class is not required, e.g
php
{ "resource": "" }
q256823
Papi_Admin.admin_body_class
test
public function admin_body_class( $classes ) { if ( $entry_type = $this->get_entry_type() ) { $classes .= sprintf( ' papi-body papi-meta-type-%s', papi_get_meta_type() ); // Add custom css classes from entry type. $arr = $entry_type->get_body_classes(); $arr = is_string( $arr ) ? [ $arr ] : $arr; $arr...
php
{ "resource": "" }
q256824
Papi_Admin.edit_form_after_title
test
public function edit_form_after_title() { wp_nonce_field( 'papi_save_data', 'papi_meta_nonce' ); if ( $value = esc_attr( papi_get_entry_type_id() ) ) { papi_render_html_tag( 'input', [
php
{ "resource": "" }
q256825
Papi_Admin.get_entry_type
test
protected function get_entry_type() { if ( $this->entry_type instanceof Papi_Entry_Type ) { return $this->entry_type; } $entry_type_id = papi_get_entry_type_id(); // If the entry type id is empty try to load // the entry type id from `page` query string. // // Example: // /wp-admin/options-genera...
php
{ "resource": "" }
q256826
Papi_Admin.plugin_row_meta
test
public function plugin_row_meta( array $links, $file ) { if ( $file === PAPI_PLUGIN_BASENAME ) { return array_merge( $links, [ 'docs' => '<a href="' . esc_url( 'https://wp-papi.github.io/docs/' ) . '"
php
{ "resource": "" }
q256827
Papi_Admin.update_front_page
test
public function update_front_page( $value, $option ) { if ( $option !== 'page_on_front' ) { return $value; } $front_pages = papi_get_all_entry_types( [ 'types' => ['front-page'], ] ); if ( count( $front_pages ) === 0 ) { return $value; } $old_page_type_id = papi_get_page_type_id( $value ); $...
php
{ "resource": "" }
q256828
Papi_Admin.wp_link_query
test
public function wp_link_query( array $results ) { foreach ( $results as $index => $value ) { $post_type = papi_get_post_type( $value['ID'] ); $name = papi_get_page_type_name( $value['ID'] ); if ( empty( $name )
php
{ "resource": "" }
q256829
Papi_Property_Module.get_templates
test
protected function get_templates( $id ) { if ( empty( $id ) && ! is_numeric( $id ) ) { return []; } if ( $data = papi_get_entry_type_by_meta_id( $id ) ) {
php
{ "resource": "" }
q256830
Papi_Post_Store.prepare_load_value
test
protected function prepare_load_value( Papi_Core_Property $property, $value ) { if ( $property->overwrite ) { // Clear post cache to solve issue with cached post objects // when selecting post field. clean_post_cache( $this->id );
php
{ "resource": "" }
q256831
Papi_Admin_Option_Handler.save_properties
test
public function save_properties() { if ( $_SERVER ['REQUEST_METHOD'] !== 'POST' || papi_get_meta_type() !== 'option' ) { return; } // Check if our nonce is vailed. if ( ! wp_verify_nonce( papi_get_sanitized_post( 'papi_meta_nonce' ), 'papi_save_data' ) ) { return; } // Get properties data. $data =...
php
{ "resource": "" }
q256832
Papi_Admin_Page_Type_Switcher.metabox
test
public function metabox() { $post_type = papi_get_post_type(); $page_type = papi_get_entry_type_by_id( papi_get_page_type_id() ); $page_type_key = papi_get_page_type_key( 'switch' ); $page_types = papi_get_all_page_types( $post_type ); $show_standard = papi_filter_settings_show_standard_page_type( ...
php
{ "resource": "" }
q256833
Papi_Admin_Page_Type_Switcher.save_post
test
public function save_post( $post_id, $post ) { // Check if post id and post object is empty or not. if ( empty( $post_id ) || empty( $post ) ) { return false; } // Check if our nonce is vailed. if ( ! wp_verify_nonce( papi_get_sanitized_post( 'papi_meta_nonce' ), 'papi_save_data' ) ) { return false; ...
php
{ "resource": "" }
q256834
Papi_Admin_Meta_Handler.overwrite_post_data
test
protected function overwrite_post_data( $post_id ) { global $wpdb; if ( empty( $post_id ) || empty( $this->overwrite ) ) { return; } $wpdb->update( $wpdb->posts, $this->overwrite, [
php
{ "resource": "" }
q256835
Papi_Admin_Meta_Handler.pre_save
test
protected function pre_save( $id ) { if ( empty( $id ) ) { return; } $data = $this->get_pre_data(); foreach ( $data as $key => $value ) { if ( empty( $value ) ) { continue; } if ( is_array( $value ) ) { list( $keys, $value ) = $this->get_pre_deep_keys_value( $value );
php
{ "resource": "" }
q256836
Papi_Admin_Meta_Handler.save_meta_boxes
test
public function save_meta_boxes( $id, $post = null ) { // Check if there was a multisite switch before. if ( is_multisite() && ms_is_switched() ) { return; } // Can't proceed without a id. if ( empty( $id ) ) { return; } // Check if our nonce is vailed. if ( ! wp_verify_nonce( papi_get_sanitized...
php
{ "resource": "" }
q256837
Papi_Admin_Meta_Handler.save_revision
test
public function save_revision( $revision_id ) { // Check if our nonce is vailed. if ( ! wp_verify_nonce( papi_get_sanitized_post( 'papi_meta_nonce' ), 'papi_save_data' ) ) { return; } // Fetch parent id from revision. if ( ! $parent_id = wp_is_post_revision( $revision_id ) ) { return; } // Bail if...
php
{ "resource": "" }
q256838
Papi_Admin_Meta_Handler.save_properties
test
public function save_properties( $id ) { // Pre save page template, page type and some others dynamic values. $this->pre_save( $id ); // Get properties data. $data = $this->get_post_data(); // Prepare properties data. $data = $this->prepare_properties_data( $data, $id ); // Get meta type. $meta_type ...
php
{ "resource": "" }
q256839
Papi_Admin_Meta_Handler.restore_post_revision
test
public function restore_post_revision( $post_id, $revision_id ) { if ( papi_is_empty( papi_get_entry_type_by_meta_id( $post_id, 'post' ) ) ) { return; } $meta = get_post_meta( $revision_id ); foreach ( $meta as $key => $value
php
{ "resource": "" }
q256840
Papi_Admin_Meta_Handler.valid_post_id
test
protected function valid_post_id( $post_id ) { $key = papi_get_sanitized_post( 'action' ) === 'save-attachment-compat' ? 'id' : 'post_ID'; $val = papi_get_sanitized_post( $key ); // When autosave is in place the post id is located deeper in the post data array, the ids should not match. if ( isset( $_POST['dat...
php
{ "resource": "" }
q256841
Papi_Core_Conditional.display
test
public function display( array $rules, $property = null ) { if ( empty( $rules ) ) { return true; } $rules = $this->prepare_rules( $rules, $property ); if ( in_array(
php
{ "resource": "" }
q256842
Papi_Core_Conditional.display_by_relation
test
protected function display_by_relation( array $rules ) { if ( $rules['relation'] === 'AND' ) { $display = true; foreach ( $rules as $rule ) { if ( ! $display ) { break; } if ( papi_is_rule( $rule ) ) { /** * Modify rule allowed. * * @param bool $result * @param ...
php
{ "resource": "" }
q256843
Papi_Core_Conditional.get_rule_slug
test
protected function get_rule_slug( $rule, $property ) { $arr_reg = '/\[\d+\](\[\w+\])$/'; $slug = $property->get_slug(); $page_type = papi_get_entry_type_by_meta_id(); if ( $page_type instanceof Papi_Page_Type === false ) { return $rule->slug; } if ( preg_match( $arr_reg, $slug, $out ) ) { $slug ...
php
{ "resource": "" }
q256844
Papi_Core_Conditional.prepare_rules
test
public function prepare_rules( array $rules, $property = null ) { if ( ! isset( $rules['relation'] ) ) { $rules['relation'] = 'OR'; } else { $rules['relation'] = strtoupper( $rules['relation'] ); } foreach ( $rules as $index => $value ) { if ( is_string( $index ) ) { continue; } if ( is_arr...
php
{ "resource": "" }
q256845
Papi_Page_Type.allowed
test
public function allowed() { $args = func_get_args(); if ( empty( $args ) ) { return parent::allowed(); } return papi_current_user_is_allowed( $this->capabilities
php
{ "resource": "" }
q256846
Papi_Page_Type.get_body_classes
test
public function get_body_classes() { $classes = parent::get_body_classes(); if ( ! $this->show_permalink )
php
{ "resource": "" }
q256847
Papi_Page_Type.get_child_types
test
public function get_child_types() { $child_types = []; foreach ( papi_to_array( $this->child_types ) as $id ) {
php
{ "resource": "" }
q256848
Papi_Page_Type.get_labels
test
public function get_labels() { if ( ! $this->fill_labels ) { return $this->labels; } return array_merge( $this->labels, [ 'add_new_item' => sprintf( '%s %s', __( 'Add New', 'papi' ), $this->name ), 'edit_item'
php
{ "resource": "" }
q256849
Papi_Page_Type.get_post_type_supports
test
protected function get_post_type_supports() { $supports = ['custom-fields']; if ( method_exists( $this, 'remove' ) ) { $output = $this->remove(); $output = is_string( $output ) ? [$output] : $output; $output = is_array( $output ) ? $output : []; $output = array_filter( $output, 'is_string' ); ...
php
{ "resource": "" }
q256850
Papi_Page_Type.remove_post_type_support
test
public function remove_post_type_support() { global $_wp_post_type_features; $post_type = $this->get_post_type(); if ( empty( $post_type ) ) { return; } $post_type_supports = $this->get_post_type_supports(); foreach ( $post_type_supports as $key => $value ) { if ( is_numeric( $key ) ) { $key =...
php
{ "resource": "" }
q256851
Papi_Page_Type.remove_meta_boxes
test
public function remove_meta_boxes() { global $wp_meta_boxes; $post_type = $this->get_post_type(); $context = []; foreach ( $this->remove_meta_boxes as $item ) { if ( $item[0] !== $item[1] ) { remove_meta_box( $item[0], $post_type, $item[1] ); continue; } $context = $item[0]; // Our speci...
php
{ "resource": "" }
q256852
Papi_Page_Type.setup
test
public function setup() { parent::setup(); // Remove post type support and meta boxes. $this->remove_post_type_support(); // Add support for displaying information in publish box from a page type. if ( method_exists( $this, 'publish_box' ) ) { add_action( 'post_submitbox_misc_actions', [$this, 'publish_b...
php
{ "resource": "" }
q256853
Papi_Page_Type.setup_post_types
test
protected function setup_post_types() { $this->post_type = papi_to_array( $this->post_type ); // Set a default value to post types array // if we don't have a array or a empty array. if ( empty( $this->post_type ) ) { $this->post_type = ['page'];
php
{ "resource": "" }
q256854
Papi_Page_Type.setup_page_templates
test
protected function setup_page_templates() { if ( ! is_array( $this->template ) || ! $this->has_post_type( papi_get_post_type() ) ) { return; } $this->show_page_template = true; foreach ( $this->post_type as $post_type ) { // Can't use `theme_templates` filter since
php
{ "resource": "" }
q256855
Papi_Property_Editor.add_mce_buttons
test
protected function add_mce_buttons() { for ( $i = 0; $i < 4; $i++ ) { $num = $i === 0 ? '' : '_' . ( $i + 1 );
php
{ "resource": "" }
q256856
Papi_Property_Editor.reove_mce_buttons
test
protected function reove_mce_buttons() { for ( $i = 0; $i < 4; $i++ ) { $num = $i === 0 ? '' : '_' . ( $i + 1 );
php
{ "resource": "" }
q256857
Papi_Property_Repeater.get_row_results
test
protected function get_row_results( $dbresults ) { $results = []; $is_option = $this->get_meta_type() === 'option'; foreach ( $dbresults as $meta ) { if ( $is_option ) { preg_match( '/^[^\d]*(\d+)/', $meta->option_name, $matches ); } else { preg_match( '/^[^\d]*(\d+)/', $meta->meta_key, $matches ...
php
{ "resource": "" }
q256858
Papi_Property_Repeater.load_value
test
public function load_value( $value, $repeater_slug, $post_id ) { if ( is_array( $value ) ) { return $value; } list( $results, $trash ) = $this->get_results( $value, $repeater_slug, $post_id ); // Will not need this array. unset( $trash );
php
{ "resource": "" }
q256859
Papi_Property_Repeater.prepare_properties
test
protected function prepare_properties( $items ) { $key = isset( $this->layout_key ) && $this->layout_key === '_layout' ? 'flexible' : 'repeater'; $items = array_map( 'papi_property', $items ); $exclude_properties = $this->exclude_properties; $exclude_properties = array_merge( $exclude_properties, apply_fil...
php
{ "resource": "" }
q256860
Papi_Property_Repeater.prepare_property_for_json
test
protected function prepare_property_for_json( $property ) { // Only real property objects and not properties that are disabled. if ( ! papi_is_property( $property ) || $property->disabled() ) { return false; } $options = clone $property->get_options(); if ( isset( $options->settings->items ) ) { forea...
php
{ "resource": "" }
q256861
Papi_Property_Repeater.remove_repeater_rows
test
protected function remove_repeater_rows( $post_id, $repeater_slug ) { global $wpdb; $is_option = $this->get_meta_type() === 'option'; $repeater_slug = $repeater_slug . '_%'; if ( $is_option ) { $table = $wpdb->prefix . 'options'; // @codingStandardsIgnoreStart $query = $wpdb->prepare( "SELEC...
php
{ "resource": "" }
q256862
Papi_Property_Repeater.render_json_template
test
protected function render_json_template( $slug ) { $options = $this->get_options(); $options->settings->items = papi_to_array( $options->settings->items ); foreach ( $options->settings->items as $key => $value ) { $property = $this->prepare_property_for_json( papi_property( $value ) ); if ( $property ===...
php
{ "resource": "" }
q256863
Papi_Property_Repeater.render_repeater_head
test
protected function render_repeater_head() { $properties = $this->get_settings_properties(); ?> <thead> <?php if ( ! $this->layout( 'row' ) ): ?> <tr> <th></th> <?php foreach ( $properties as $property ): // Don't show the property if it's disabled. if ( $property->disabled() ) { c...
php
{ "resource": "" }
q256864
Papi_Property_Repeater.render_repeater_rows
test
protected function render_repeater_rows() { $items = $this->get_settings_properties(); $values = $this->get_value(); $values = is_array( $values ) ? $values : []; $slugs = wp_list_pluck( $items, 'slug' ); // Remove values that don't exists in the slugs array. foreach ( $values as $index => $value ) { ...
php
{ "resource": "" }
q256865
Papi_REST_API_Settings.register
test
public function register() { // Fetch all options entries. $this->entries = papi_get_all_entry_types( [ 'types' => 'option' ] ); foreach ( $this->entries as $entry ) {
php
{ "resource": "" }
q256866
Papi_REST_API_Settings.get_setting
test
public function get_setting( $key, $value ) { $property = null; foreach ( (array) $this->entries as $entry ) { if ( $property = $entry->get_property(
php
{ "resource": "" }
q256867
Papi_REST_API_Settings.prepare_response
test
public function prepare_response( $response ) { $response = (array) $response; foreach ( $response as $key => $value ) { $setting = $this->get_setting( $key, $value ); if
php
{ "resource": "" }
q256868
Papi_Property_User.get_value
test
public function get_value() { $user = parent::get_value(); if ( is_object( $user ) && isset(
php
{ "resource": "" }
q256869
Papi_Property_User.get_items
test
public function get_items() { $capabilities = papi_to_array( $this->get_setting( 'capabilities' ) ); $users = get_users(); $items = []; foreach ( $users as $user ) { $allcaps = $user->allcaps;
php
{ "resource": "" }
q256870
Papi_Loader.init
test
protected function init() { // Fires the before init action. did_action( 'papi/before_init' ) || do_action( 'papi/before_init' ); // Set up localisation. $this->load_textdomain(); // Load all required files. $this->require_files(); //
php
{ "resource": "" }
q256871
Papi_Loader.load_textdomain
test
protected function load_textdomain() { $locale = function_exists( 'get_user_local' ) ? get_user_local() : get_locale(); $locale = apply_filters( 'plugin_locale', $locale, 'papi' ); load_textdomain( 'papi',
php
{ "resource": "" }
q256872
Papi_Loader.require_files
test
protected function require_files() { // Require the autoload class. require_once __DIR__ . '/core/class-papi-core-autoload.php'; $lib_path = __DIR__ . '/lib/'; $lib_includes = [ 'core/cache.php', 'core/conditional.php', 'core/data.php', 'core/deprecated.php', 'core/meta.php', 'core/store....
php
{ "resource": "" }
q256873
Papi_Loader.deactivate
test
public static function deactivate() { // Remove Papi from plugins_loaded action. remove_action( 'plugins_loaded', 'papi' ); // Load deactivate_plugins if it don't exists. if ( ! function_exists( 'deactivate_plugins' ) ) { include_once ABSPATH . 'wp-admin/includes/plugin.php'; } deactivate_plugins( PAPI...
php
{ "resource": "" }
q256874
Papi_Property_Dropdown.is_string_items
test
public function is_string_items() { $items = $this->get_items(); if ( empty( $items
php
{ "resource": "" }
q256875
Papi_Property_Group.prepare_properties
test
protected function prepare_properties( $properties ) { $result = []; $value = $this->get_value(); $value = is_array( $value ) ? $value : []; foreach ( $properties as $property ) { $render_property = clone $property->get_options();
php
{ "resource": "" }
q256876
Papi_Property_File.get_file
test
public function get_file( $value ) { $meta_key = $this->get_setting( 'meta_key' ); if ( empty( $meta_key ) ) { if ( is_numeric( $value ) && intval( $value ) !== 0 ) { $post = get_post( $value ); } } else if ( ! empty( $value ) ) { $args = [ 'fields'
php
{ "resource": "" }
q256877
Papi_Property_File.get_file_value
test
protected function get_file_value( $value ) { $meta_key = $this->get_setting( 'meta_key' ); if ( ! is_object( $value ) ) {
php
{ "resource": "" }
q256878
Papi_Property_File.update_value
test
public function update_value( $values, $slug, $post_id ) { if ( ! is_array( $values ) ) { $values = $this->get_file_value( (object) [ 'id' => $values ] ); if ( empty( $values ) ) { return; } return $values; } foreach ( $values as $index => $value ) {
php
{ "resource": "" }
q256879
Papi_Core_Container.bind
test
public function bind( $id, $value = null, $singleton = false ) { if ( is_string( $id ) && $this->is_singleton( $id ) ) { throw new Exception( sprintf( 'Identifier `%s` is a singleton and cannot be rebind', $id ) ); } if ( is_object( $id ) && get_class( $id ) !== false )
php
{ "resource": "" }
q256880
Papi_Core_Container.call_closure
test
protected function call_closure( $closure, array $parameters = [] ) { if ( $closure instanceof Closure ) { $rc = new ReflectionFunction( $closure ); $args = $rc->getParameters(); $params = $parameters; $classes = [ $this->get_class_prefix( get_class( $this ) ), get_class( $this ), get...
php
{ "resource": "" }
q256881
Papi_Core_Container.get_class_prefix
test
protected function get_class_prefix( $id, $check = true ) { if ( strpos( $id, '\\' ) !== false && $id[0] !== '\\' ) { $class = '\\' . $id; if ( $check
php
{ "resource": "" }
q256882
Papi_Core_Container.is_singleton
test
public function is_singleton( $id ) { if ( ! is_string( $id ) ) { throw new InvalidArgumentException( 'Invalid argument. Must be string.' ); } if ( ! $this->exists( $id ) ) {
php
{ "resource": "" }
q256883
Papi_Core_Container.once
test
public function once( $key, $callback ) { if ( ! is_string( $key ) && ! is_callable( $callback ) ) { return; } if ( ! $this->exists( $key ) ) {
php
{ "resource": "" }
q256884
Papi_Core_Container.remove
test
public function remove( $id ) { $id = $this->get_class_prefix( $id );
php
{ "resource": "" }
q256885
Papi_Admin_Menu.override_labels
test
protected function override_labels( Papi_Entry_Type $entry_type ) { global $wp_post_types, $wp_taxonomies; if ( $entry_type->get_type() === 'taxonomy' ) { $meta_type_value = papi_get_taxonomy(); } else { $meta_type_value = papi_get_post_type(); } if ( empty( $meta_type_value ) || ( ! isset( $wp_post_t...
php
{ "resource": "" }
q256886
Papi_Admin_Menu.page_items_menu
test
public function page_items_menu() { $entry_types = papi_get_all_entry_types( [ 'mode' => 'exclude', 'types' => 'page' ] ); foreach ( $entry_types as $entry_type ) { if ( empty( $entry_type->get_menu() ) || empty( $entry_type->name ) ) { continue; } $slug = sprintf( 'papi/%s/%s', $ent...
php
{ "resource": "" }
q256887
Papi_Admin_Menu.post_types_menu
test
public function post_types_menu() { global $submenu; $post_types = papi_get_post_types(); foreach ( $post_types as $post_type ) { if ( ! post_type_exists( $post_type ) ) { continue; } if ( $post_type === 'post' ) { $edit_url = 'edit.php'; } else { $edit_url = 'edit.php?post_type=' . $po...
php
{ "resource": "" }
q256888
Papi_Admin_Menu.render_view
test
public function render_view() { if ( strpos( papi_get_qs( 'page' ), 'papi' ) !== false ) { $page = str_replace( 'papi-', '', papi_get_qs( 'page' ) ); $res = preg_replace( '/\,.*/', '', $page ); if ( is_string( $res ) ) { $page_view = $res; } } if ( ! isset( $page_view
php
{ "resource": "" }
q256889
Papi_Core_Autoload.autoload
test
public function autoload( $class ) { $class = strtolower( $class ); $file = 'class-' . str_replace( '_', '-', strtolower( $class ) ) . '.php'; $path = PAPI_PLUGIN_DIR; if ( strpos( $class, 'papi_admin' ) === 0 ) { $path .= 'admin/'; } else if ( strpos( $class, 'papi_core_' ) === 0 ) { $path .= 'core/...
php
{ "resource": "" }
q256890
Papi_Property_Sidebar.get_items
test
public function get_items() { global $wp_registered_sidebars; $items = []; foreach ( $wp_registered_sidebars as $item ) {
php
{ "resource": "" }
q256891
Papi_Property_Post.get_labels
test
protected function get_labels() { $results = []; foreach ( $this->get_post_types() as $post_type ) { if ( post_type_exists( $post_type ) ) { $post_type_object = get_post_type_object( $post_type );
php
{ "resource": "" }
q256892
Papi_Query.parse_args
test
public function parse_args( array $args ) { $args = array_merge( $this->default_args, $args ); // Since a page type has defined post types we should use them. // With a fallback on `post_type` args or `any` value. if ( $this->type === 'post' )
php
{ "resource": "" }
q256893
Papi_Query.parse_post_args
test
protected function parse_post_args( array $args ) { if ( isset( $args['page_type'] ) ) { $args['entry_type'] = $args['page_type']; unset( $args['page_type'] ); } $entry_type = papi_get_entry_type_by_id( $args['entry_type'] ); if ( $entry_type instanceof Papi_Page_Type ) { $args['post_type']
php
{ "resource": "" }
q256894
Papi_Query.parse_term_args
test
protected function parse_term_args( array $args ) { if ( isset( $args['taxonomy_type'] ) ) { $args['entry_type'] = $args['taxonomy_type']; unset( $args['taxonomy_type'] ); } $entry_type = papi_get_entry_type_by_id( $args['entry_type'] ); if ( $entry_type instanceof Papi_Taxonomy_Type ) { $args['taxo...
php
{ "resource": "" }
q256895
Papi_Query.get_query_args
test
public function get_query_args() { $args = $this->args; if ( empty( $args['meta_query'] ) ) { // Add new meta key/value if `meta_key` or `meta_value` is empty. if ( empty( $args['meta_key'] ) || empty( $args['meta_value'] ) ) { $args['meta_key'] = papi_get_page_type_key(); $args['meta_value'] = $ar...
php
{ "resource": "" }
q256896
Papi_Query.get_result
test
public function get_result() { if ( ! method_exists( $this->query, 'query' ) ) {
php
{ "resource": "" }
q256897
Papi_Entry_Type.add_help_tabs
test
public function add_help_tabs() { $help = $this->help(); $screen = get_current_screen(); // No screen available. if ( $screen instanceof WP_Screen === false ) { return; } // Clean up all existing tabs. if ( ! $this->show_help_tabs || ! empty( $help ) ) { $screen->remove_help_tabs(); } // No...
php
{ "resource": "" }
q256898
Papi_Entry_Type.box
test
protected function box( $file_or_options = [], $properties = [] ) { if ( ! is_string( $file_or_options ) && ! is_array( $file_or_options ) && ! is_object( $file_or_options ) ) { return; } list( $options, $properties ) = papi_get_options_and_properties( $file_or_options, $properties, true ); // C...
php
{ "resource": "" }
q256899
Papi_Entry_Type.call_parent_register
test
protected function call_parent_register() { $parent_class = get_parent_class( $this ); if ( ! method_exists( $parent_class, 'register' ) ) { return; } $rc = new ReflectionClass( $parent_class ); // Bail if
php
{ "resource": "" }