repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1
value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
pods-framework/pods | classes/fields/oembed.php | PodsField_OEmbed.admin_ajax_oembed_update_preview | public function admin_ajax_oembed_update_preview() {
// Sanitize input.
// @codingStandardsIgnoreLine
$params = pods_unslash( (array) $_POST );
if ( ! empty( $params['_nonce_pods_oembed'] ) && ! empty( $params['pods_field_oembed_value'] ) && wp_verify_nonce( $params['_nonce_pods_oembed'], 'pods_field_oembed_preview' ) ) {
$value = $this->strip_html( $params['pods_field_oembed_value'] );
$name = '';
$options = array();
if ( ! empty( $params['pods_field_oembed_name'] ) ) {
$name = $this->strip_html( $params['pods_field_oembed_name'] );
}
if ( ! empty( $params['pods_field_oembed_options'] ) ) {
$options = $params['pods_field_oembed_options'];
}
// Load the field to get it's options.
$options = pods_api()->load_field( (object) $options );
// Field options are stored here, if not, just stay with the full options array.
if ( ! empty( $options['options'] ) ) {
$options = $options['options'];
}
// Run display function to run oEmbed.
$value = $this->display( $value, $name, $options );
if ( empty( $value ) ) {
$value = __( 'Please choose a valid oEmbed URL.', 'pods' );
wp_send_json_error( $value );
} else {
wp_send_json_success( $value );
}
}//end if
wp_send_json_error( __( 'Unauthorized request', 'pods' ) );
die();
// Kill it!
} | php | public function admin_ajax_oembed_update_preview() {
// Sanitize input.
// @codingStandardsIgnoreLine
$params = pods_unslash( (array) $_POST );
if ( ! empty( $params['_nonce_pods_oembed'] ) && ! empty( $params['pods_field_oembed_value'] ) && wp_verify_nonce( $params['_nonce_pods_oembed'], 'pods_field_oembed_preview' ) ) {
$value = $this->strip_html( $params['pods_field_oembed_value'] );
$name = '';
$options = array();
if ( ! empty( $params['pods_field_oembed_name'] ) ) {
$name = $this->strip_html( $params['pods_field_oembed_name'] );
}
if ( ! empty( $params['pods_field_oembed_options'] ) ) {
$options = $params['pods_field_oembed_options'];
}
// Load the field to get it's options.
$options = pods_api()->load_field( (object) $options );
// Field options are stored here, if not, just stay with the full options array.
if ( ! empty( $options['options'] ) ) {
$options = $options['options'];
}
// Run display function to run oEmbed.
$value = $this->display( $value, $name, $options );
if ( empty( $value ) ) {
$value = __( 'Please choose a valid oEmbed URL.', 'pods' );
wp_send_json_error( $value );
} else {
wp_send_json_success( $value );
}
}//end if
wp_send_json_error( __( 'Unauthorized request', 'pods' ) );
die();
// Kill it!
} | [
"public",
"function",
"admin_ajax_oembed_update_preview",
"(",
")",
"{",
"// Sanitize input.",
"// @codingStandardsIgnoreLine",
"$",
"params",
"=",
"pods_unslash",
"(",
"(",
"array",
")",
"$",
"_POST",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"params",
"[",
... | Handle update preview AJAX.
@since 2.7.0 | [
"Handle",
"update",
"preview",
"AJAX",
"."
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/fields/oembed.php#L482-L524 | train |
pods-framework/pods | classes/PodsAdmin.php | PodsAdmin.admin_init | public function admin_init() {
// Fix for plugins that *don't do it right* so we don't cause issues for users
// @codingStandardsIgnoreLine
if ( defined( 'DOING_AJAX' ) && ! empty( $_POST ) ) {
$pods_admin_ajax_actions = array(
'pods_admin',
'pods_relationship',
'pods_upload',
'pods_admin_components',
);
/**
* Admin AJAX Callbacks
*
* @since unknown
*
* @param array $pods_admin_ajax_actions Array of actions to handle.
*/
$pods_admin_ajax_actions = apply_filters( 'pods_admin_ajax_actions', $pods_admin_ajax_actions );
if ( in_array( pods_v( 'action' ), $pods_admin_ajax_actions, true ) || in_array( pods_v( 'action', 'post' ), $pods_admin_ajax_actions, true ) ) {
// @codingStandardsIgnoreLine
foreach ( $_POST as $key => $value ) {
if ( 'action' === $key || 0 === strpos( $key, '_podsfix_' ) ) {
continue;
}
// @codingStandardsIgnoreLine
unset( $_POST[ $key ] );
// @codingStandardsIgnoreLine
$_POST[ '_podsfix_' . $key ] = $value;
}
}
}//end if
} | php | public function admin_init() {
// Fix for plugins that *don't do it right* so we don't cause issues for users
// @codingStandardsIgnoreLine
if ( defined( 'DOING_AJAX' ) && ! empty( $_POST ) ) {
$pods_admin_ajax_actions = array(
'pods_admin',
'pods_relationship',
'pods_upload',
'pods_admin_components',
);
/**
* Admin AJAX Callbacks
*
* @since unknown
*
* @param array $pods_admin_ajax_actions Array of actions to handle.
*/
$pods_admin_ajax_actions = apply_filters( 'pods_admin_ajax_actions', $pods_admin_ajax_actions );
if ( in_array( pods_v( 'action' ), $pods_admin_ajax_actions, true ) || in_array( pods_v( 'action', 'post' ), $pods_admin_ajax_actions, true ) ) {
// @codingStandardsIgnoreLine
foreach ( $_POST as $key => $value ) {
if ( 'action' === $key || 0 === strpos( $key, '_podsfix_' ) ) {
continue;
}
// @codingStandardsIgnoreLine
unset( $_POST[ $key ] );
// @codingStandardsIgnoreLine
$_POST[ '_podsfix_' . $key ] = $value;
}
}
}//end if
} | [
"public",
"function",
"admin_init",
"(",
")",
"{",
"// Fix for plugins that *don't do it right* so we don't cause issues for users",
"// @codingStandardsIgnoreLine",
"if",
"(",
"defined",
"(",
"'DOING_AJAX'",
")",
"&&",
"!",
"empty",
"(",
"$",
"_POST",
")",
")",
"{",
"$... | Init the admin area
@since 2.0.0 | [
"Init",
"the",
"admin",
"area"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsAdmin.php#L69-L105 | train |
pods-framework/pods | classes/PodsAdmin.php | PodsAdmin.admin_head | public function admin_head() {
wp_register_script( 'pods-floatmenu', PODS_URL . 'ui/js/floatmenu.js', array(), PODS_VERSION );
wp_register_script( 'pods-admin-importer', PODS_URL . 'ui/js/admin-importer.js', array(), PODS_VERSION );
wp_register_script( 'pods-upgrade', PODS_URL . 'ui/js/jquery.pods.upgrade.js', array(), PODS_VERSION );
wp_register_script( 'pods-migrate', PODS_URL . 'ui/js/jquery.pods.migrate.js', array(), PODS_VERSION );
// @codingStandardsIgnoreLine
if ( isset( $_GET['page'] ) ) {
// @codingStandardsIgnoreLine
$page = $_GET['page'];
if ( 'pods' === $page || ( false !== strpos( $page, 'pods-' ) && 0 === strpos( $page, 'pods-' ) ) ) {
?>
<script type="text/javascript">
var PODS_URL = "<?php echo esc_js( PODS_URL ); ?>";
</script>
<?php
wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'jquery-ui-core' );
wp_enqueue_script( 'jquery-ui-sortable' );
wp_enqueue_script( 'pods-floatmenu' );
wp_enqueue_script( 'jquery-qtip2' );
wp_enqueue_script( 'pods-qtip-init' );
wp_enqueue_script( 'pods' );
if ( 0 === strpos( $page, 'pods-manage-' ) || 0 === strpos( $page, 'pods-add-new-' ) ) {
wp_enqueue_script( 'post' );
} elseif ( 0 === strpos( $page, 'pods-settings-' ) ) {
wp_enqueue_script( 'post' );
}
if ( 'pods-advanced' === $page ) {
wp_register_script( 'pods-advanced', PODS_URL . 'ui/js/advanced.js', array(), PODS_VERSION );
wp_enqueue_script( 'jquery-ui-effects-core', PODS_URL . 'ui/js/jquery-ui/jquery.effects.core.js', array( 'jquery' ), '1.8.8' );
wp_enqueue_script( 'jquery-ui-effects-fade', PODS_URL . 'ui/js/jquery-ui/jquery.effects.fade.js', array( 'jquery' ), '1.8.8' );
wp_enqueue_script( 'jquery-ui-dialog' );
wp_enqueue_script( 'pods-advanced' );
} elseif ( 'pods-packages' === $page ) {
wp_enqueue_style( 'pods-wizard' );
} elseif ( 'pods-wizard' === $page || 'pods-upgrade' === $page || ( in_array(
$page, array(
'pods',
'pods-add-new',
), true
) && in_array(
pods_v( 'action', 'get', 'manage' ), array(
'add',
'manage',
), true
) ) ) {
wp_enqueue_style( 'pods-wizard' );
if ( 'pods-upgrade' === $page ) {
wp_enqueue_script( 'pods-upgrade' );
}
}//end if
}//end if
}//end if
/**
* Filter to disable default loading of the DFV script. By default, Pods
* will always enqueue the DFV script if is_admin()
*
* Example: add_filter( 'pods_default_enqueue_dfv', '__return_false');
*
* @param bool Whether or not to enqueue by default
*
* @since 2.7.10
*/
if ( apply_filters( 'pods_default_enqueue_dfv', true ) ) {
wp_enqueue_script( 'pods-dfv' );
}
// New Styles Enqueue
wp_enqueue_style( 'pods-styles' );
} | php | public function admin_head() {
wp_register_script( 'pods-floatmenu', PODS_URL . 'ui/js/floatmenu.js', array(), PODS_VERSION );
wp_register_script( 'pods-admin-importer', PODS_URL . 'ui/js/admin-importer.js', array(), PODS_VERSION );
wp_register_script( 'pods-upgrade', PODS_URL . 'ui/js/jquery.pods.upgrade.js', array(), PODS_VERSION );
wp_register_script( 'pods-migrate', PODS_URL . 'ui/js/jquery.pods.migrate.js', array(), PODS_VERSION );
// @codingStandardsIgnoreLine
if ( isset( $_GET['page'] ) ) {
// @codingStandardsIgnoreLine
$page = $_GET['page'];
if ( 'pods' === $page || ( false !== strpos( $page, 'pods-' ) && 0 === strpos( $page, 'pods-' ) ) ) {
?>
<script type="text/javascript">
var PODS_URL = "<?php echo esc_js( PODS_URL ); ?>";
</script>
<?php
wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'jquery-ui-core' );
wp_enqueue_script( 'jquery-ui-sortable' );
wp_enqueue_script( 'pods-floatmenu' );
wp_enqueue_script( 'jquery-qtip2' );
wp_enqueue_script( 'pods-qtip-init' );
wp_enqueue_script( 'pods' );
if ( 0 === strpos( $page, 'pods-manage-' ) || 0 === strpos( $page, 'pods-add-new-' ) ) {
wp_enqueue_script( 'post' );
} elseif ( 0 === strpos( $page, 'pods-settings-' ) ) {
wp_enqueue_script( 'post' );
}
if ( 'pods-advanced' === $page ) {
wp_register_script( 'pods-advanced', PODS_URL . 'ui/js/advanced.js', array(), PODS_VERSION );
wp_enqueue_script( 'jquery-ui-effects-core', PODS_URL . 'ui/js/jquery-ui/jquery.effects.core.js', array( 'jquery' ), '1.8.8' );
wp_enqueue_script( 'jquery-ui-effects-fade', PODS_URL . 'ui/js/jquery-ui/jquery.effects.fade.js', array( 'jquery' ), '1.8.8' );
wp_enqueue_script( 'jquery-ui-dialog' );
wp_enqueue_script( 'pods-advanced' );
} elseif ( 'pods-packages' === $page ) {
wp_enqueue_style( 'pods-wizard' );
} elseif ( 'pods-wizard' === $page || 'pods-upgrade' === $page || ( in_array(
$page, array(
'pods',
'pods-add-new',
), true
) && in_array(
pods_v( 'action', 'get', 'manage' ), array(
'add',
'manage',
), true
) ) ) {
wp_enqueue_style( 'pods-wizard' );
if ( 'pods-upgrade' === $page ) {
wp_enqueue_script( 'pods-upgrade' );
}
}//end if
}//end if
}//end if
/**
* Filter to disable default loading of the DFV script. By default, Pods
* will always enqueue the DFV script if is_admin()
*
* Example: add_filter( 'pods_default_enqueue_dfv', '__return_false');
*
* @param bool Whether or not to enqueue by default
*
* @since 2.7.10
*/
if ( apply_filters( 'pods_default_enqueue_dfv', true ) ) {
wp_enqueue_script( 'pods-dfv' );
}
// New Styles Enqueue
wp_enqueue_style( 'pods-styles' );
} | [
"public",
"function",
"admin_head",
"(",
")",
"{",
"wp_register_script",
"(",
"'pods-floatmenu'",
",",
"PODS_URL",
".",
"'ui/js/floatmenu.js'",
",",
"array",
"(",
")",
",",
"PODS_VERSION",
")",
";",
"wp_register_script",
"(",
"'pods-admin-importer'",
",",
"PODS_URL"... | Attach requirements to admin header
@since 2.0.0 | [
"Attach",
"requirements",
"to",
"admin",
"header"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsAdmin.php#L112-L193 | train |
pods-framework/pods | classes/PodsAdmin.php | PodsAdmin.parent_file | public function parent_file( $parent_file ) {
global $current_screen;
if ( isset( $current_screen ) && ! empty( $current_screen->taxonomy ) ) {
$taxonomies = PodsMeta::$taxonomies;
if ( ! empty( $taxonomies ) ) {
foreach ( (array) $taxonomies as $pod ) {
if ( $current_screen->taxonomy !== $pod['name'] ) {
continue;
}
$menu_slug = 'edit-tags.php?taxonomy=' . $pod['name'];
$menu_location = pods_v( 'menu_location', $pod['options'], 'default' );
$menu_location_custom = pods_v( 'menu_location_custom', $pod['options'], '' );
if ( 'settings' === $menu_location ) {
$parent_file = 'options-general.php';
} elseif ( 'appearances' === $menu_location ) {
$parent_file = 'themes.php';
} elseif ( 'objects' === $menu_location ) {
$parent_file = $menu_slug;
} elseif ( 'top' === $menu_location ) {
$parent_file = $menu_slug;
} elseif ( 'submenu' === $menu_location && ! empty( $menu_location_custom ) ) {
$parent_file = $menu_location_custom;
}
break;
}//end foreach
}//end if
}//end if
if ( isset( $current_screen ) && ! empty( $current_screen->post_type ) && is_object( PodsInit::$components ) ) {
global $submenu_file;
$components = PodsInit::$components->components;
foreach ( $components as $component => $component_data ) {
if ( ! empty( $component_data['MenuPage'] ) && $parent_file === $component_data['MenuPage'] ) {
$parent_file = 'pods';
// @codingStandardsIgnoreLine
$submenu_file = $component_data['MenuPage'];
}
}
}
return $parent_file;
} | php | public function parent_file( $parent_file ) {
global $current_screen;
if ( isset( $current_screen ) && ! empty( $current_screen->taxonomy ) ) {
$taxonomies = PodsMeta::$taxonomies;
if ( ! empty( $taxonomies ) ) {
foreach ( (array) $taxonomies as $pod ) {
if ( $current_screen->taxonomy !== $pod['name'] ) {
continue;
}
$menu_slug = 'edit-tags.php?taxonomy=' . $pod['name'];
$menu_location = pods_v( 'menu_location', $pod['options'], 'default' );
$menu_location_custom = pods_v( 'menu_location_custom', $pod['options'], '' );
if ( 'settings' === $menu_location ) {
$parent_file = 'options-general.php';
} elseif ( 'appearances' === $menu_location ) {
$parent_file = 'themes.php';
} elseif ( 'objects' === $menu_location ) {
$parent_file = $menu_slug;
} elseif ( 'top' === $menu_location ) {
$parent_file = $menu_slug;
} elseif ( 'submenu' === $menu_location && ! empty( $menu_location_custom ) ) {
$parent_file = $menu_location_custom;
}
break;
}//end foreach
}//end if
}//end if
if ( isset( $current_screen ) && ! empty( $current_screen->post_type ) && is_object( PodsInit::$components ) ) {
global $submenu_file;
$components = PodsInit::$components->components;
foreach ( $components as $component => $component_data ) {
if ( ! empty( $component_data['MenuPage'] ) && $parent_file === $component_data['MenuPage'] ) {
$parent_file = 'pods';
// @codingStandardsIgnoreLine
$submenu_file = $component_data['MenuPage'];
}
}
}
return $parent_file;
} | [
"public",
"function",
"parent_file",
"(",
"$",
"parent_file",
")",
"{",
"global",
"$",
"current_screen",
";",
"if",
"(",
"isset",
"(",
"$",
"current_screen",
")",
"&&",
"!",
"empty",
"(",
"$",
"current_screen",
"->",
"taxonomy",
")",
")",
"{",
"$",
"taxo... | Set the correct parent_file to highlight the correct top level menu
@param string $parent_file The parent file.
@return mixed|string
@since unknown | [
"Set",
"the",
"correct",
"parent_file",
"to",
"highlight",
"the",
"correct",
"top",
"level",
"menu"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsAdmin.php#L685-L734 | train |
pods-framework/pods | classes/PodsAdmin.php | PodsAdmin.admin_content | public function admin_content() {
// @codingStandardsIgnoreLine
$pod_name = str_replace( array( 'pods-manage-', 'pods-add-new-' ), '', $_GET['page'] );
$pod = pods( $pod_name, pods_v( 'id', 'get', null, true ) );
// @codingStandardsIgnoreLine
if ( false !== strpos( $_GET['page'], 'pods-add-new-' ) ) {
// @codingStandardsIgnoreLine
$_GET['action'] = pods_v( 'action', 'get', 'add' );
}
$pod->ui();
} | php | public function admin_content() {
// @codingStandardsIgnoreLine
$pod_name = str_replace( array( 'pods-manage-', 'pods-add-new-' ), '', $_GET['page'] );
$pod = pods( $pod_name, pods_v( 'id', 'get', null, true ) );
// @codingStandardsIgnoreLine
if ( false !== strpos( $_GET['page'], 'pods-add-new-' ) ) {
// @codingStandardsIgnoreLine
$_GET['action'] = pods_v( 'action', 'get', 'add' );
}
$pod->ui();
} | [
"public",
"function",
"admin_content",
"(",
")",
"{",
"// @codingStandardsIgnoreLine",
"$",
"pod_name",
"=",
"str_replace",
"(",
"array",
"(",
"'pods-manage-'",
",",
"'pods-add-new-'",
")",
",",
"''",
",",
"$",
"_GET",
"[",
"'page'",
"]",
")",
";",
"$",
"pod... | Create PodsUI content for the administration pages | [
"Create",
"PodsUI",
"content",
"for",
"the",
"administration",
"pages"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsAdmin.php#L750-L764 | train |
pods-framework/pods | classes/PodsAdmin.php | PodsAdmin.admin_content_settings | public function admin_content_settings() {
// @codingStandardsIgnoreLine
$pod_name = str_replace( 'pods-settings-', '', $_GET['page'] );
$pod = pods( $pod_name );
if ( 'custom' !== pods_v( 'ui_style', $pod->pod_data['options'], 'settings', true ) ) {
$actions_disabled = array(
'manage' => 'manage',
'add' => 'add',
'delete' => 'delete',
'duplicate' => 'duplicate',
'view' => 'view',
'export' => 'export',
);
// @codingStandardsIgnoreLine
$_GET['action'] = 'edit';
$page_title = pods_v( 'label', $pod->pod_data, ucwords( str_replace( '_', ' ', $pod->pod_data['name'] ) ), true );
$page_title = apply_filters( 'pods_admin_menu_page_title', $page_title, $pod->pod_data );
$ui = array(
'pod' => $pod,
'fields' => array(
'edit' => $pod->pod_data['fields'],
),
'header' => array(
'edit' => $page_title,
),
'label' => array(
'edit' => __( 'Save Changes', 'pods' ),
),
'style' => pods_v( 'ui_style', $pod->pod_data['options'], 'settings', true ),
'icon' => pods_evaluate_tags( pods_v( 'menu_icon', $pod->pod_data['options'] ), true ),
'actions_disabled' => $actions_disabled,
);
$pod_pod_name = $pod->pod;
$ui = apply_filters( "pods_admin_ui_{$pod_pod_name}", apply_filters( 'pods_admin_ui', $ui, $pod->pod, $pod ), $pod->pod, $pod );
// Force disabled actions, do not pass go, do not collect $two_hundred
$ui['actions_disabled'] = $actions_disabled;
pods_ui( $ui );
} else {
$pod_pod_name = $pod->pod;
do_action( 'pods_admin_ui_custom', $pod );
do_action( "pods_admin_ui_custom_{$pod_pod_name}", $pod );
}//end if
} | php | public function admin_content_settings() {
// @codingStandardsIgnoreLine
$pod_name = str_replace( 'pods-settings-', '', $_GET['page'] );
$pod = pods( $pod_name );
if ( 'custom' !== pods_v( 'ui_style', $pod->pod_data['options'], 'settings', true ) ) {
$actions_disabled = array(
'manage' => 'manage',
'add' => 'add',
'delete' => 'delete',
'duplicate' => 'duplicate',
'view' => 'view',
'export' => 'export',
);
// @codingStandardsIgnoreLine
$_GET['action'] = 'edit';
$page_title = pods_v( 'label', $pod->pod_data, ucwords( str_replace( '_', ' ', $pod->pod_data['name'] ) ), true );
$page_title = apply_filters( 'pods_admin_menu_page_title', $page_title, $pod->pod_data );
$ui = array(
'pod' => $pod,
'fields' => array(
'edit' => $pod->pod_data['fields'],
),
'header' => array(
'edit' => $page_title,
),
'label' => array(
'edit' => __( 'Save Changes', 'pods' ),
),
'style' => pods_v( 'ui_style', $pod->pod_data['options'], 'settings', true ),
'icon' => pods_evaluate_tags( pods_v( 'menu_icon', $pod->pod_data['options'] ), true ),
'actions_disabled' => $actions_disabled,
);
$pod_pod_name = $pod->pod;
$ui = apply_filters( "pods_admin_ui_{$pod_pod_name}", apply_filters( 'pods_admin_ui', $ui, $pod->pod, $pod ), $pod->pod, $pod );
// Force disabled actions, do not pass go, do not collect $two_hundred
$ui['actions_disabled'] = $actions_disabled;
pods_ui( $ui );
} else {
$pod_pod_name = $pod->pod;
do_action( 'pods_admin_ui_custom', $pod );
do_action( "pods_admin_ui_custom_{$pod_pod_name}", $pod );
}//end if
} | [
"public",
"function",
"admin_content_settings",
"(",
")",
"{",
"// @codingStandardsIgnoreLine",
"$",
"pod_name",
"=",
"str_replace",
"(",
"'pods-settings-'",
",",
"''",
",",
"$",
"_GET",
"[",
"'page'",
"]",
")",
";",
"$",
"pod",
"=",
"pods",
"(",
"$",
"pod_n... | Create PodsUI content for the settings administration pages | [
"Create",
"PodsUI",
"content",
"for",
"the",
"settings",
"administration",
"pages"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsAdmin.php#L769-L821 | train |
pods-framework/pods | classes/PodsAdmin.php | PodsAdmin.media_button | public function media_button( $context = null ) {
// If shortcodes are disabled don't show the button
if ( defined( 'PODS_DISABLE_SHORTCODE' ) && PODS_DISABLE_SHORTCODE ) {
return '';
}
/**
* Filter to remove Pods shortcode button from the post editor.
*
* @param bool $show_button Set to false to block the shortcode button from appearing.
* @param string $context Media button context.
*
* @since 2.3.19
*/
if ( ! apply_filters( 'pods_admin_media_button', true, $context ) ) {
return '';
}
$current_page = basename( $_SERVER['PHP_SELF'] );
$current_page = explode( '?', $current_page );
$current_page = explode( '#', $current_page[0] );
$current_page = $current_page[0];
// Only show the button on post type pages
if ( ! in_array(
$current_page, array(
'post-new.php',
'post.php',
), true
) ) {
return '';
}
add_action( 'admin_footer', array( $this, 'mce_popup' ) );
echo '<a href="#TB_inline?width=640&inlineId=pods_shortcode_form" class="thickbox button" id="add_pod_button" title="Pods Shortcode"><img style="padding: 0px 6px 0px 0px; margin: -3px 0px 0px;" src="' . esc_url( PODS_URL . 'ui/images/icon16.png' ) . '" alt="' . esc_attr__( 'Pods Shortcode', 'pods' ) . '" />' . esc_html__( 'Pods Shortcode', 'pods' ) . '</a>';
} | php | public function media_button( $context = null ) {
// If shortcodes are disabled don't show the button
if ( defined( 'PODS_DISABLE_SHORTCODE' ) && PODS_DISABLE_SHORTCODE ) {
return '';
}
/**
* Filter to remove Pods shortcode button from the post editor.
*
* @param bool $show_button Set to false to block the shortcode button from appearing.
* @param string $context Media button context.
*
* @since 2.3.19
*/
if ( ! apply_filters( 'pods_admin_media_button', true, $context ) ) {
return '';
}
$current_page = basename( $_SERVER['PHP_SELF'] );
$current_page = explode( '?', $current_page );
$current_page = explode( '#', $current_page[0] );
$current_page = $current_page[0];
// Only show the button on post type pages
if ( ! in_array(
$current_page, array(
'post-new.php',
'post.php',
), true
) ) {
return '';
}
add_action( 'admin_footer', array( $this, 'mce_popup' ) );
echo '<a href="#TB_inline?width=640&inlineId=pods_shortcode_form" class="thickbox button" id="add_pod_button" title="Pods Shortcode"><img style="padding: 0px 6px 0px 0px; margin: -3px 0px 0px;" src="' . esc_url( PODS_URL . 'ui/images/icon16.png' ) . '" alt="' . esc_attr__( 'Pods Shortcode', 'pods' ) . '" />' . esc_html__( 'Pods Shortcode', 'pods' ) . '</a>';
} | [
"public",
"function",
"media_button",
"(",
"$",
"context",
"=",
"null",
")",
"{",
"// If shortcodes are disabled don't show the button",
"if",
"(",
"defined",
"(",
"'PODS_DISABLE_SHORTCODE'",
")",
"&&",
"PODS_DISABLE_SHORTCODE",
")",
"{",
"return",
"''",
";",
"}",
"... | Add media button for Pods shortcode
@param string $context Media button context.
@return string | [
"Add",
"media",
"button",
"for",
"Pods",
"shortcode"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsAdmin.php#L830-L867 | train |
pods-framework/pods | classes/PodsAdmin.php | PodsAdmin.admin_setup_edit_tabs | public function admin_setup_edit_tabs( $pod ) {
$fields = true;
$labels = false;
$admin_ui = false;
$advanced = false;
if ( 'post_type' === pods_v( 'type', $pod ) && '' === pods_v( 'object', $pod ) ) {
$labels = true;
$admin_ui = true;
$advanced = true;
} elseif ( 'taxonomy' === pods_v( 'type', $pod ) && '' === pods_v( 'object', $pod ) ) {
$labels = true;
$admin_ui = true;
$advanced = true;
} elseif ( 'pod' === pods_v( 'type', $pod ) ) {
$labels = true;
$admin_ui = true;
$advanced = true;
} elseif ( 'settings' === pods_v( 'type', $pod ) ) {
$labels = true;
$admin_ui = true;
}
if ( ! function_exists( 'get_term_meta' ) && 'none' === pods_v( 'storage', $pod, 'none', true ) && 'taxonomy' === pods_v( 'type', $pod ) ) {
$fields = false;
}
$tabs = array();
if ( $fields ) {
$tabs['manage-fields'] = __( 'Manage Fields', 'pods' );
}
if ( $labels ) {
$tabs['labels'] = __( 'Labels', 'pods' );
}
if ( $admin_ui ) {
$tabs['admin-ui'] = __( 'Admin UI', 'pods' );
}
if ( $advanced ) {
$tabs['advanced'] = __( 'Advanced Options', 'pods' );
}
if ( 'taxonomy' === pods_v( 'type', $pod ) && ! $fields ) {
$tabs['extra-fields'] = __( 'Extra Fields', 'pods' );
}
$addtl_args = compact( array( 'fields', 'labels', 'admin_ui', 'advanced' ) );
$pod_type = $pod['type'];
$pod_name = $pod['name'];
/**
* Add or modify tabs in Pods editor for a specific Pod
*
* @param array $tabs Tabs to set.
* @param object $pod Current Pods object.
* @param array $addtl_args Additional args.
*
* @since unknown
*/
$tabs = apply_filters( "pods_admin_setup_edit_tabs_{$pod_type}_{$pod_name}", $tabs, $pod, $addtl_args );
/**
* Add or modify tabs for any Pod in Pods editor of a specific post type.
*/
$tabs = apply_filters( "pods_admin_setup_edit_tabs_{$pod_type}", $tabs, $pod, $addtl_args );
/**
* Add or modify tabs in Pods editor for all pods.
*/
$tabs = apply_filters( 'pods_admin_setup_edit_tabs', $tabs, $pod, $addtl_args );
return $tabs;
} | php | public function admin_setup_edit_tabs( $pod ) {
$fields = true;
$labels = false;
$admin_ui = false;
$advanced = false;
if ( 'post_type' === pods_v( 'type', $pod ) && '' === pods_v( 'object', $pod ) ) {
$labels = true;
$admin_ui = true;
$advanced = true;
} elseif ( 'taxonomy' === pods_v( 'type', $pod ) && '' === pods_v( 'object', $pod ) ) {
$labels = true;
$admin_ui = true;
$advanced = true;
} elseif ( 'pod' === pods_v( 'type', $pod ) ) {
$labels = true;
$admin_ui = true;
$advanced = true;
} elseif ( 'settings' === pods_v( 'type', $pod ) ) {
$labels = true;
$admin_ui = true;
}
if ( ! function_exists( 'get_term_meta' ) && 'none' === pods_v( 'storage', $pod, 'none', true ) && 'taxonomy' === pods_v( 'type', $pod ) ) {
$fields = false;
}
$tabs = array();
if ( $fields ) {
$tabs['manage-fields'] = __( 'Manage Fields', 'pods' );
}
if ( $labels ) {
$tabs['labels'] = __( 'Labels', 'pods' );
}
if ( $admin_ui ) {
$tabs['admin-ui'] = __( 'Admin UI', 'pods' );
}
if ( $advanced ) {
$tabs['advanced'] = __( 'Advanced Options', 'pods' );
}
if ( 'taxonomy' === pods_v( 'type', $pod ) && ! $fields ) {
$tabs['extra-fields'] = __( 'Extra Fields', 'pods' );
}
$addtl_args = compact( array( 'fields', 'labels', 'admin_ui', 'advanced' ) );
$pod_type = $pod['type'];
$pod_name = $pod['name'];
/**
* Add or modify tabs in Pods editor for a specific Pod
*
* @param array $tabs Tabs to set.
* @param object $pod Current Pods object.
* @param array $addtl_args Additional args.
*
* @since unknown
*/
$tabs = apply_filters( "pods_admin_setup_edit_tabs_{$pod_type}_{$pod_name}", $tabs, $pod, $addtl_args );
/**
* Add or modify tabs for any Pod in Pods editor of a specific post type.
*/
$tabs = apply_filters( "pods_admin_setup_edit_tabs_{$pod_type}", $tabs, $pod, $addtl_args );
/**
* Add or modify tabs in Pods editor for all pods.
*/
$tabs = apply_filters( 'pods_admin_setup_edit_tabs', $tabs, $pod, $addtl_args );
return $tabs;
} | [
"public",
"function",
"admin_setup_edit_tabs",
"(",
"$",
"pod",
")",
"{",
"$",
"fields",
"=",
"true",
";",
"$",
"labels",
"=",
"false",
";",
"$",
"admin_ui",
"=",
"false",
";",
"$",
"advanced",
"=",
"false",
";",
"if",
"(",
"'post_type'",
"===",
"pods_... | Get list of Pod option tabs
@param array $pod Pod options.
@return array | [
"Get",
"list",
"of",
"Pod",
"option",
"tabs"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsAdmin.php#L1116-L1193 | train |
pods-framework/pods | classes/PodsAdmin.php | PodsAdmin.admin_setup_edit_field_tabs | public function admin_setup_edit_field_tabs( $pod ) {
$core_tabs = array(
'basic' => __( 'Basic', 'pods' ),
'additional-field' => __( 'Additional Field Options', 'pods' ),
'advanced' => __( 'Advanced', 'pods' ),
);
/**
* Field option tabs
*
* Use to add new tabs, default tabs are added after this filter (IE you can't remove/modify them with this, kthanksbye).
*
* @since unknown
*
* @param array $tabs Tabs to add, starts empty.
* @param object|Pod $pod Current Pods object.
*/
$tabs = apply_filters( 'pods_admin_setup_edit_field_tabs', array(), $pod );
$tabs = array_merge( $core_tabs, $tabs );
return $tabs;
} | php | public function admin_setup_edit_field_tabs( $pod ) {
$core_tabs = array(
'basic' => __( 'Basic', 'pods' ),
'additional-field' => __( 'Additional Field Options', 'pods' ),
'advanced' => __( 'Advanced', 'pods' ),
);
/**
* Field option tabs
*
* Use to add new tabs, default tabs are added after this filter (IE you can't remove/modify them with this, kthanksbye).
*
* @since unknown
*
* @param array $tabs Tabs to add, starts empty.
* @param object|Pod $pod Current Pods object.
*/
$tabs = apply_filters( 'pods_admin_setup_edit_field_tabs', array(), $pod );
$tabs = array_merge( $core_tabs, $tabs );
return $tabs;
} | [
"public",
"function",
"admin_setup_edit_field_tabs",
"(",
"$",
"pod",
")",
"{",
"$",
"core_tabs",
"=",
"array",
"(",
"'basic'",
"=>",
"__",
"(",
"'Basic'",
",",
"'pods'",
")",
",",
"'additional-field'",
"=>",
"__",
"(",
"'Additional Field Options'",
",",
"'pod... | Get list of Pod field option tabs
@param array $pod Pod options.
@return array | [
"Get",
"list",
"of",
"Pod",
"field",
"option",
"tabs"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsAdmin.php#L2309-L2332 | train |
pods-framework/pods | classes/PodsAdmin.php | PodsAdmin.admin_setup_duplicate | public function admin_setup_duplicate( $obj ) {
$new_id = pods_api()->duplicate_pod( array( 'id' => $obj->id ) );
if ( 0 < $new_id ) {
pods_redirect(
pods_query_arg(
array(
'action' => 'edit',
'id' => $new_id,
'do' => 'duplicate',
)
)
);
}
} | php | public function admin_setup_duplicate( $obj ) {
$new_id = pods_api()->duplicate_pod( array( 'id' => $obj->id ) );
if ( 0 < $new_id ) {
pods_redirect(
pods_query_arg(
array(
'action' => 'edit',
'id' => $new_id,
'do' => 'duplicate',
)
)
);
}
} | [
"public",
"function",
"admin_setup_duplicate",
"(",
"$",
"obj",
")",
"{",
"$",
"new_id",
"=",
"pods_api",
"(",
")",
"->",
"duplicate_pod",
"(",
"array",
"(",
"'id'",
"=>",
"$",
"obj",
"->",
"id",
")",
")",
";",
"if",
"(",
"0",
"<",
"$",
"new_id",
"... | Duplicate a pod
@param PodsUI $obj PodsUI object. | [
"Duplicate",
"a",
"pod"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsAdmin.php#L2587-L2602 | train |
pods-framework/pods | classes/PodsAdmin.php | PodsAdmin.admin_setup_duplicate_restrict | public function admin_setup_duplicate_restrict( $restricted, $restrict, $action, $row, $obj ) {
if ( in_array(
$row['real_type'], array(
'user',
'media',
'comment',
), true
) ) {
$restricted = true;
}
return $restricted;
} | php | public function admin_setup_duplicate_restrict( $restricted, $restrict, $action, $row, $obj ) {
if ( in_array(
$row['real_type'], array(
'user',
'media',
'comment',
), true
) ) {
$restricted = true;
}
return $restricted;
} | [
"public",
"function",
"admin_setup_duplicate_restrict",
"(",
"$",
"restricted",
",",
"$",
"restrict",
",",
"$",
"action",
",",
"$",
"row",
",",
"$",
"obj",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"row",
"[",
"'real_type'",
"]",
",",
"array",
"(",
"'... | Restrict Duplicate action to custom types, not extended
@param bool $restricted Whether action is restricted.
@param array $restrict Restriction array.
@param string $action Current action.
@param array $row Item data row.
@param PodsUI $obj PodsUI object.
@since 2.3.10
@return bool | [
"Restrict",
"Duplicate",
"action",
"to",
"custom",
"types",
"not",
"extended"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsAdmin.php#L2617-L2631 | train |
pods-framework/pods | classes/PodsAdmin.php | PodsAdmin.admin_setup_reset | public function admin_setup_reset( $obj, $id ) {
$pod = pods_api()->load_pod( array( 'id' => $id ), false );
if ( empty( $pod ) ) {
return $obj->error( __( 'Pod not found.', 'pods' ) );
}
pods_api()->reset_pod( array( 'id' => $id ) );
$obj->message( __( 'Pod reset successfully.', 'pods' ) );
$obj->manage();
} | php | public function admin_setup_reset( $obj, $id ) {
$pod = pods_api()->load_pod( array( 'id' => $id ), false );
if ( empty( $pod ) ) {
return $obj->error( __( 'Pod not found.', 'pods' ) );
}
pods_api()->reset_pod( array( 'id' => $id ) );
$obj->message( __( 'Pod reset successfully.', 'pods' ) );
$obj->manage();
} | [
"public",
"function",
"admin_setup_reset",
"(",
"$",
"obj",
",",
"$",
"id",
")",
"{",
"$",
"pod",
"=",
"pods_api",
"(",
")",
"->",
"load_pod",
"(",
"array",
"(",
"'id'",
"=>",
"$",
"id",
")",
",",
"false",
")",
";",
"if",
"(",
"empty",
"(",
"$",
... | Reset a pod
@param PodsUI $obj PodsUI object.
@param int|string $id Item ID.
@return mixed | [
"Reset",
"a",
"pod"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsAdmin.php#L2641-L2654 | train |
pods-framework/pods | classes/PodsAdmin.php | PodsAdmin.admin_setup_reset_restrict | public function admin_setup_reset_restrict( $restricted, $restrict, $action, $row, $obj ) {
if ( in_array(
$row['real_type'], array(
'user',
'media',
), true
) ) {
$restricted = true;
}
return $restricted;
} | php | public function admin_setup_reset_restrict( $restricted, $restrict, $action, $row, $obj ) {
if ( in_array(
$row['real_type'], array(
'user',
'media',
), true
) ) {
$restricted = true;
}
return $restricted;
} | [
"public",
"function",
"admin_setup_reset_restrict",
"(",
"$",
"restricted",
",",
"$",
"restrict",
",",
"$",
"action",
",",
"$",
"row",
",",
"$",
"obj",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"row",
"[",
"'real_type'",
"]",
",",
"array",
"(",
"'user... | Restrict Reset action from users and media
@param bool $restricted Whether action is restricted.
@param array $restrict Restriction array.
@param string $action Current action.
@param array $row Item data row.
@param PodsUI $obj PodsUI object.
@since 2.3.10 | [
"Restrict",
"Reset",
"action",
"from",
"users",
"and",
"media"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsAdmin.php#L2667-L2680 | train |
pods-framework/pods | classes/PodsAdmin.php | PodsAdmin.admin_setup_delete | public function admin_setup_delete( $id, $obj ) {
$pod = pods_api()->load_pod( array( 'id' => $id ), false );
if ( empty( $pod ) ) {
return $obj->error( __( 'Pod not found.', 'pods' ) );
}
pods_api()->delete_pod( array( 'id' => $id ) );
unset( $obj->data[ $pod['id'] ] );
$obj->total = count( $obj->data );
$obj->total_found = count( $obj->data );
$obj->message( __( 'Pod deleted successfully.', 'pods' ) );
} | php | public function admin_setup_delete( $id, $obj ) {
$pod = pods_api()->load_pod( array( 'id' => $id ), false );
if ( empty( $pod ) ) {
return $obj->error( __( 'Pod not found.', 'pods' ) );
}
pods_api()->delete_pod( array( 'id' => $id ) );
unset( $obj->data[ $pod['id'] ] );
$obj->total = count( $obj->data );
$obj->total_found = count( $obj->data );
$obj->message( __( 'Pod deleted successfully.', 'pods' ) );
} | [
"public",
"function",
"admin_setup_delete",
"(",
"$",
"id",
",",
"$",
"obj",
")",
"{",
"$",
"pod",
"=",
"pods_api",
"(",
")",
"->",
"load_pod",
"(",
"array",
"(",
"'id'",
"=>",
"$",
"id",
")",
",",
"false",
")",
";",
"if",
"(",
"empty",
"(",
"$",... | Delete a pod
@param int|string $id Item ID.
@param PodsUI $obj PodsUI object.
@return mixed | [
"Delete",
"a",
"pod"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsAdmin.php#L2690-L2706 | train |
pods-framework/pods | classes/PodsAdmin.php | PodsAdmin.admin_upgrade | public function admin_upgrade() {
foreach ( PodsInit::$upgrades as $old_version => $new_version ) {
if ( version_compare( $old_version, PodsInit::$version_last, '<=' ) && version_compare( PodsInit::$version_last, $new_version, '<' ) ) {
$new_version = str_replace( '.', '_', $new_version );
pods_view( PODS_DIR . 'ui/admin/upgrade/upgrade_' . $new_version . '.php', compact( array_keys( get_defined_vars() ) ) );
break;
}
}
} | php | public function admin_upgrade() {
foreach ( PodsInit::$upgrades as $old_version => $new_version ) {
if ( version_compare( $old_version, PodsInit::$version_last, '<=' ) && version_compare( PodsInit::$version_last, $new_version, '<' ) ) {
$new_version = str_replace( '.', '_', $new_version );
pods_view( PODS_DIR . 'ui/admin/upgrade/upgrade_' . $new_version . '.php', compact( array_keys( get_defined_vars() ) ) );
break;
}
}
} | [
"public",
"function",
"admin_upgrade",
"(",
")",
"{",
"foreach",
"(",
"PodsInit",
"::",
"$",
"upgrades",
"as",
"$",
"old_version",
"=>",
"$",
"new_version",
")",
"{",
"if",
"(",
"version_compare",
"(",
"$",
"old_version",
",",
"PodsInit",
"::",
"$",
"versi... | Get the admin upgrade page | [
"Get",
"the",
"admin",
"upgrade",
"page"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsAdmin.php#L3037-L3048 | train |
pods-framework/pods | classes/PodsAdmin.php | PodsAdmin.configuration | public function configuration( $pod = null, $full_field_info = false ) {
$api = pods_api();
if ( null === $pod ) {
$the_pods = $api->load_pods();
} elseif ( is_array( $pod ) ) {
foreach ( $pod as $p ) {
$the_pods[] = $api->load_pod( $p );
}
} else {
$the_pods[] = $api->load_pod( $pod );
}
foreach ( $the_pods as $the_pod ) {
$configuration[ $the_pod['name'] ] = array(
'name' => $the_pod['name'],
'ID' => $the_pod['id'],
'storage' => $the_pod['storage'],
'fields' => $the_pod['fields'],
);
}
if ( ! $full_field_info ) {
foreach ( $the_pods as $the_pod ) {
$fields = $configuration[ $the_pod['name'] ]['fields'];
unset( $configuration[ $the_pod['name'] ]['fields'] );
foreach ( $fields as $field ) {
$info = array(
'name' => $field['name'],
'type' => $field['type'],
);
if ( 'pick' === $info['type'] ) {
$info['pick_object'] = $field['pick_object'];
if ( isset( $field['pick_val'] ) && '' !== $field['pick_val'] ) {
$info['pick_val'] = $field['pick_val'];
}
}
if ( is_array( $info ) ) {
$configuration[ $the_pod['name'] ]['fields'][ $field['name'] ] = $info;
}
unset( $info );
}//end foreach
}//end foreach
}//end if
if ( is_array( $configuration ) ) {
return $configuration;
}
} | php | public function configuration( $pod = null, $full_field_info = false ) {
$api = pods_api();
if ( null === $pod ) {
$the_pods = $api->load_pods();
} elseif ( is_array( $pod ) ) {
foreach ( $pod as $p ) {
$the_pods[] = $api->load_pod( $p );
}
} else {
$the_pods[] = $api->load_pod( $pod );
}
foreach ( $the_pods as $the_pod ) {
$configuration[ $the_pod['name'] ] = array(
'name' => $the_pod['name'],
'ID' => $the_pod['id'],
'storage' => $the_pod['storage'],
'fields' => $the_pod['fields'],
);
}
if ( ! $full_field_info ) {
foreach ( $the_pods as $the_pod ) {
$fields = $configuration[ $the_pod['name'] ]['fields'];
unset( $configuration[ $the_pod['name'] ]['fields'] );
foreach ( $fields as $field ) {
$info = array(
'name' => $field['name'],
'type' => $field['type'],
);
if ( 'pick' === $info['type'] ) {
$info['pick_object'] = $field['pick_object'];
if ( isset( $field['pick_val'] ) && '' !== $field['pick_val'] ) {
$info['pick_val'] = $field['pick_val'];
}
}
if ( is_array( $info ) ) {
$configuration[ $the_pod['name'] ]['fields'][ $field['name'] ] = $info;
}
unset( $info );
}//end foreach
}//end foreach
}//end if
if ( is_array( $configuration ) ) {
return $configuration;
}
} | [
"public",
"function",
"configuration",
"(",
"$",
"pod",
"=",
"null",
",",
"$",
"full_field_info",
"=",
"false",
")",
"{",
"$",
"api",
"=",
"pods_api",
"(",
")",
";",
"if",
"(",
"null",
"===",
"$",
"pod",
")",
"{",
"$",
"the_pods",
"=",
"$",
"api",
... | Profiles the Pods configuration
@param null|string|array $pod Which Pod(s) to get configuration for. Can be a the name
of one Pod, or an array of names of Pods, or null, which is the
default, to profile all Pods.
@param bool $full_field_info If true all info about each field is returned. If false,
which is the default only name and type, will be returned.
@return array
@since 2.7.0 | [
"Profiles",
"the",
"Pods",
"configuration"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsAdmin.php#L3357-L3414 | train |
pods-framework/pods | classes/PodsAdmin.php | PodsAdmin.rest_admin | protected function rest_admin() {
if ( function_exists( 'register_rest_field' ) ) {
add_filter(
'pods_admin_setup_edit_field_options', array(
$this,
'add_rest_fields_to_field_editor',
), 12, 2
);
add_filter( 'pods_admin_setup_edit_field_tabs', array( $this, 'add_rest_field_tab' ), 12 );
}
add_filter( 'pods_admin_setup_edit_tabs', array( $this, 'add_rest_settings_tab' ), 12, 2 );
add_filter( 'pods_admin_setup_edit_options', array( $this, 'add_rest_settings_tab_fields' ), 12, 2 );
} | php | protected function rest_admin() {
if ( function_exists( 'register_rest_field' ) ) {
add_filter(
'pods_admin_setup_edit_field_options', array(
$this,
'add_rest_fields_to_field_editor',
), 12, 2
);
add_filter( 'pods_admin_setup_edit_field_tabs', array( $this, 'add_rest_field_tab' ), 12 );
}
add_filter( 'pods_admin_setup_edit_tabs', array( $this, 'add_rest_settings_tab' ), 12, 2 );
add_filter( 'pods_admin_setup_edit_options', array( $this, 'add_rest_settings_tab_fields' ), 12, 2 );
} | [
"protected",
"function",
"rest_admin",
"(",
")",
"{",
"if",
"(",
"function_exists",
"(",
"'register_rest_field'",
")",
")",
"{",
"add_filter",
"(",
"'pods_admin_setup_edit_field_options'",
",",
"array",
"(",
"$",
"this",
",",
"'add_rest_fields_to_field_editor'",
",",
... | Build UI for extending REST API, if makes sense to do so.
@since 2.6.0
@access protected | [
"Build",
"UI",
"for",
"extending",
"REST",
"API",
"if",
"makes",
"sense",
"to",
"do",
"so",
"."
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsAdmin.php#L3423-L3438 | train |
pods-framework/pods | classes/PodsAdmin.php | PodsAdmin.add_rest_settings_tab_fields | public function add_rest_settings_tab_fields( $options, $pod ) {
if ( ! function_exists( 'register_rest_field' ) ) {
$options['rest-api'] = array(
'no_dependencies' => array(
'label' => sprintf( __( 'Pods REST API support requires WordPress 4.3.1 or later and the %s or later.', 'pods' ), '<a href="https://pods.io/docs/build/extending-core-wordpress-rest-api-routes-with-pods/" target="_blank">WordPress REST API 2.0-beta9</a>' ),
'help' => sprintf( __( 'See %s for more information.', 'pods' ), '<a href="https://pods.io/docs/build/extending-core-wordpress-rest-api-routes-with-pods/" target="_blank">https://pods.io/docs/build/extending-core-wordpress-rest-api-routes-with-pods/</a>' ),
'type' => 'html',
),
);
} elseif ( $this->restable_pod( $pod ) ) {
$options['rest-api'] = array(
'rest_enable' => array(
'label' => __( 'Enable', 'pods' ),
'help' => __( 'Add REST API support for this Pod.', 'pods' ),
'type' => 'boolean',
'default' => '',
'dependency' => true,
),
'rest_base' => array(
'label' => __( 'REST Base (if any)', 'pods' ),
'help' => __( 'This will form the url for the route. Default / empty value here will use the pod name.', 'pods' ),
'type' => 'text',
'default' => '',
'depends-on' => array( 'rest_enable' => true ),
),
'read_all' => array(
'label' => __( 'Show All Fields (read-only)', 'pods' ),
'help' => __( 'Show all fields in REST API. If unchecked fields must be enabled on a field by field basis.', 'pods' ),
'type' => 'boolean',
'default' => '',
'depends-on' => array( 'rest_enable' => true ),
),
'write_all' => array(
'label' => __( 'Allow All Fields To Be Updated', 'pods' ),
'help' => __( 'Allow all fields to be updated via the REST API. If unchecked fields must be enabled on a field by field basis.', 'pods' ),
'type' => 'boolean',
'default' => pods_v( 'name', $pod ),
'boolean_yes_label' => '',
'depends-on' => array( 'rest_enable' => true ),
),
);
} else {
$options['rest-api'] = array(
'not_restable' => array(
'label' => __( 'Pods REST API support covers post type, taxonomy and user Pods.', 'pods' ),
'help' => sprintf( __( 'See %s for more information.', 'pods' ), '<a href="https://pods.io/docs/build/extending-core-wordpress-rest-api-routes-with-pods/" target="_blank">https://pods.io/docs/build/extending-core-wordpress-rest-api-routes-with-pods/"</a>' ),
'type' => 'html',
),
);
}//end if
return $options;
} | php | public function add_rest_settings_tab_fields( $options, $pod ) {
if ( ! function_exists( 'register_rest_field' ) ) {
$options['rest-api'] = array(
'no_dependencies' => array(
'label' => sprintf( __( 'Pods REST API support requires WordPress 4.3.1 or later and the %s or later.', 'pods' ), '<a href="https://pods.io/docs/build/extending-core-wordpress-rest-api-routes-with-pods/" target="_blank">WordPress REST API 2.0-beta9</a>' ),
'help' => sprintf( __( 'See %s for more information.', 'pods' ), '<a href="https://pods.io/docs/build/extending-core-wordpress-rest-api-routes-with-pods/" target="_blank">https://pods.io/docs/build/extending-core-wordpress-rest-api-routes-with-pods/</a>' ),
'type' => 'html',
),
);
} elseif ( $this->restable_pod( $pod ) ) {
$options['rest-api'] = array(
'rest_enable' => array(
'label' => __( 'Enable', 'pods' ),
'help' => __( 'Add REST API support for this Pod.', 'pods' ),
'type' => 'boolean',
'default' => '',
'dependency' => true,
),
'rest_base' => array(
'label' => __( 'REST Base (if any)', 'pods' ),
'help' => __( 'This will form the url for the route. Default / empty value here will use the pod name.', 'pods' ),
'type' => 'text',
'default' => '',
'depends-on' => array( 'rest_enable' => true ),
),
'read_all' => array(
'label' => __( 'Show All Fields (read-only)', 'pods' ),
'help' => __( 'Show all fields in REST API. If unchecked fields must be enabled on a field by field basis.', 'pods' ),
'type' => 'boolean',
'default' => '',
'depends-on' => array( 'rest_enable' => true ),
),
'write_all' => array(
'label' => __( 'Allow All Fields To Be Updated', 'pods' ),
'help' => __( 'Allow all fields to be updated via the REST API. If unchecked fields must be enabled on a field by field basis.', 'pods' ),
'type' => 'boolean',
'default' => pods_v( 'name', $pod ),
'boolean_yes_label' => '',
'depends-on' => array( 'rest_enable' => true ),
),
);
} else {
$options['rest-api'] = array(
'not_restable' => array(
'label' => __( 'Pods REST API support covers post type, taxonomy and user Pods.', 'pods' ),
'help' => sprintf( __( 'See %s for more information.', 'pods' ), '<a href="https://pods.io/docs/build/extending-core-wordpress-rest-api-routes-with-pods/" target="_blank">https://pods.io/docs/build/extending-core-wordpress-rest-api-routes-with-pods/"</a>' ),
'type' => 'html',
),
);
}//end if
return $options;
} | [
"public",
"function",
"add_rest_settings_tab_fields",
"(",
"$",
"options",
",",
"$",
"pod",
")",
"{",
"if",
"(",
"!",
"function_exists",
"(",
"'register_rest_field'",
")",
")",
"{",
"$",
"options",
"[",
"'rest-api'",
"]",
"=",
"array",
"(",
"'no_dependencies'"... | Populate REST API tab.
@since 0.1.0
@param array $options Tab options.
@param array $pod Pod options.
@return array | [
"Populate",
"REST",
"API",
"tab",
"."
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsAdmin.php#L3494-L3551 | train |
pods-framework/pods | classes/PodsAdmin.php | PodsAdmin.add_rest_fields_to_field_editor | public function add_rest_fields_to_field_editor( $options, $pod ) {
if ( $this->restable_pod( $pod ) ) {
$options['rest'][ __( 'Read/ Write', 'pods' ) ] = array(
'rest_read' => array(
'label' => __( 'Read via REST API?', 'pods' ),
'help' => __( 'Should this field be readable via the REST API? You must enable REST API support for this Pod.', 'pods' ),
'type' => 'boolean',
'default' => '',
),
'rest_write' => array(
'label' => __( 'Write via REST API?', 'pods' ),
'help' => __( 'Should this field be readable via the REST API? You must enable REST API support for this Pod.', 'pods' ),
'type' => 'boolean',
'default' => '',
),
);
$options['rest'][ __( 'Relationship Field Options', 'pods' ) ] = array(
'rest_pick_response' => array(
'label' => __( 'Response Type', 'pods' ),
'help' => __( 'Should this field be readable via the REST API? You must enable REST API support for this Pod.', 'pods' ),
'type' => 'pick',
'default' => 'array',
'depends-on' => array( 'type' => 'pick' ),
'data' => array(
'array' => __( 'Full', 'pods' ),
'id' => __( 'ID only', 'pods' ),
'name' => __( 'Name', 'pods' ),
),
),
'rest_pick_depth' => array(
'label' => __( 'Depth', 'pods' ),
'help' => __( 'How far to traverse relationships in response', 'pods' ),
'type' => 'number',
'default' => '2',
'depends-on' => array( 'type' => 'pick' ),
),
);
}//end if
return $options;
} | php | public function add_rest_fields_to_field_editor( $options, $pod ) {
if ( $this->restable_pod( $pod ) ) {
$options['rest'][ __( 'Read/ Write', 'pods' ) ] = array(
'rest_read' => array(
'label' => __( 'Read via REST API?', 'pods' ),
'help' => __( 'Should this field be readable via the REST API? You must enable REST API support for this Pod.', 'pods' ),
'type' => 'boolean',
'default' => '',
),
'rest_write' => array(
'label' => __( 'Write via REST API?', 'pods' ),
'help' => __( 'Should this field be readable via the REST API? You must enable REST API support for this Pod.', 'pods' ),
'type' => 'boolean',
'default' => '',
),
);
$options['rest'][ __( 'Relationship Field Options', 'pods' ) ] = array(
'rest_pick_response' => array(
'label' => __( 'Response Type', 'pods' ),
'help' => __( 'Should this field be readable via the REST API? You must enable REST API support for this Pod.', 'pods' ),
'type' => 'pick',
'default' => 'array',
'depends-on' => array( 'type' => 'pick' ),
'data' => array(
'array' => __( 'Full', 'pods' ),
'id' => __( 'ID only', 'pods' ),
'name' => __( 'Name', 'pods' ),
),
),
'rest_pick_depth' => array(
'label' => __( 'Depth', 'pods' ),
'help' => __( 'How far to traverse relationships in response', 'pods' ),
'type' => 'number',
'default' => '2',
'depends-on' => array( 'type' => 'pick' ),
),
);
}//end if
return $options;
} | [
"public",
"function",
"add_rest_fields_to_field_editor",
"(",
"$",
"options",
",",
"$",
"pod",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"restable_pod",
"(",
"$",
"pod",
")",
")",
"{",
"$",
"options",
"[",
"'rest'",
"]",
"[",
"__",
"(",
"'Read/ Write'",
... | Add a REST API section to advanced tab of field editor.
@since 2.5.6
@param array $options Tab options.
@param array $pod Pod options.
@return array | [
"Add",
"a",
"REST",
"API",
"section",
"to",
"advanced",
"tab",
"of",
"field",
"editor",
"."
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsAdmin.php#L3563-L3609 | train |
pods-framework/pods | classes/PodsI18n.php | PodsI18n.register | private static function register( $string_key, $translation ) {
/**
* Converts string into reference object variable
* Uses the same logic as JS to create the same references
*/
$ref = '__' . $string_key;
// Add it to the strings localized
self::$strings[ $ref ] = $translation;
// Remove the old key
unset( self::$strings[ $string_key ] );
} | php | private static function register( $string_key, $translation ) {
/**
* Converts string into reference object variable
* Uses the same logic as JS to create the same references
*/
$ref = '__' . $string_key;
// Add it to the strings localized
self::$strings[ $ref ] = $translation;
// Remove the old key
unset( self::$strings[ $string_key ] );
} | [
"private",
"static",
"function",
"register",
"(",
"$",
"string_key",
",",
"$",
"translation",
")",
"{",
"/**\n\t\t * Converts string into reference object variable\n\t\t * Uses the same logic as JS to create the same references\n\t\t */",
"$",
"ref",
"=",
"'__'",
".",
"$",
"str... | Register function that creates the references and combines these with the translated strings
@param string $string_key
@param string $translation
@since 2.7.0 | [
"Register",
"function",
"that",
"creates",
"the",
"references",
"and",
"combines",
"these",
"with",
"the",
"translated",
"strings"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsI18n.php#L121-L134 | train |
pods-framework/pods | classes/PodsI18n.php | PodsI18n.default_strings | private static function default_strings() {
return array(
'%s is required.' => __( '%s is required.', 'pods' ),
'This field is required.' => __( 'This field is required.', 'pods' ),
'Add' => __( 'Add', 'pods' ),
'Add New' => __( 'Add New', 'pods' ),
'Add New Record' => __( 'Add New Record', 'pods' ),
'Added!' => __( 'Added!', 'pods' ),
'Added! Choose another or <a href="#">close this box</a>' => __( 'Added! Choose another or <a href="#">close this box</a>', 'pods' ),
'Copy' => __( 'Copy', 'pods' ),
'Reorder' => __( 'Reorder', 'pods' ),
'Remove' => __( 'Remove', 'pods' ),
'Deselect' => __( 'Deselect', 'pods' ),
'Download' => __( 'Download', 'pods' ),
'View' => __( 'View', 'pods' ),
'Edit' => __( 'Edit', 'pods' ),
'Search' => __( 'Search', 'pods' ),
'Navigating away from this page will discard any changes you have made.' => __( 'Navigating away from this page will discard any changes you have made.', 'pods' ),
'Some fields have changes that were not saved yet, please save them or cancel the changes before saving the Pod.' => __( 'Some fields have changes that were not saved yet, please save them or cancel the changes before saving the Pod.', 'pods' ),
'Unable to process request, please try again.' => __( 'Unable to process request, please try again.', 'pods' ),
'Error uploading file: ' => __( 'Error uploading file: ', 'pods' ),
'Allowed Files' => __( 'Allowed Files', 'pods' ),
'The Title' => __( 'The Title', 'pods' ),
'Select from existing' => __( 'Select from existing', 'pods' ),
'You can only select' => __( 'You can only select', 'pods' ),
'%s item' => __( '%s item', 'pods' ),
'%s items' => __( '%s items', 'pods' ),
'Icon' => __( 'Icon', 'pods' ),
);
} | php | private static function default_strings() {
return array(
'%s is required.' => __( '%s is required.', 'pods' ),
'This field is required.' => __( 'This field is required.', 'pods' ),
'Add' => __( 'Add', 'pods' ),
'Add New' => __( 'Add New', 'pods' ),
'Add New Record' => __( 'Add New Record', 'pods' ),
'Added!' => __( 'Added!', 'pods' ),
'Added! Choose another or <a href="#">close this box</a>' => __( 'Added! Choose another or <a href="#">close this box</a>', 'pods' ),
'Copy' => __( 'Copy', 'pods' ),
'Reorder' => __( 'Reorder', 'pods' ),
'Remove' => __( 'Remove', 'pods' ),
'Deselect' => __( 'Deselect', 'pods' ),
'Download' => __( 'Download', 'pods' ),
'View' => __( 'View', 'pods' ),
'Edit' => __( 'Edit', 'pods' ),
'Search' => __( 'Search', 'pods' ),
'Navigating away from this page will discard any changes you have made.' => __( 'Navigating away from this page will discard any changes you have made.', 'pods' ),
'Some fields have changes that were not saved yet, please save them or cancel the changes before saving the Pod.' => __( 'Some fields have changes that were not saved yet, please save them or cancel the changes before saving the Pod.', 'pods' ),
'Unable to process request, please try again.' => __( 'Unable to process request, please try again.', 'pods' ),
'Error uploading file: ' => __( 'Error uploading file: ', 'pods' ),
'Allowed Files' => __( 'Allowed Files', 'pods' ),
'The Title' => __( 'The Title', 'pods' ),
'Select from existing' => __( 'Select from existing', 'pods' ),
'You can only select' => __( 'You can only select', 'pods' ),
'%s item' => __( '%s item', 'pods' ),
'%s items' => __( '%s items', 'pods' ),
'Icon' => __( 'Icon', 'pods' ),
);
} | [
"private",
"static",
"function",
"default_strings",
"(",
")",
"{",
"return",
"array",
"(",
"'%s is required.'",
"=>",
"__",
"(",
"'%s is required.'",
",",
"'pods'",
")",
",",
"'This field is required.'",
"=>",
"__",
"(",
"'This field is required.'",
",",
"'pods'",
... | Register our labels to use in JS
We need to register them as normal string to convert to JS references
And we need to register the translations to attach to these references, these may not be variables!
@return array Key/value pairs with label/translation
@since 2.7.0 | [
"Register",
"our",
"labels",
"to",
"use",
"in",
"JS",
"We",
"need",
"to",
"register",
"them",
"as",
"normal",
"string",
"to",
"convert",
"to",
"JS",
"references",
"And",
"we",
"need",
"to",
"register",
"the",
"translations",
"to",
"attach",
"to",
"these",
... | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsI18n.php#L145-L203 | train |
pods-framework/pods | classes/PodsI18n.php | PodsI18n.get_current_language | public function get_current_language( $args = array() ) {
$args = wp_parse_args(
$args, array(
'refresh' => false,
)
);
if ( ! $args['refresh'] && ! empty( self::$current_language ) ) {
return self::$current_language;
}
$this->get_current_language_data( $args );
return self::$current_language;
} | php | public function get_current_language( $args = array() ) {
$args = wp_parse_args(
$args, array(
'refresh' => false,
)
);
if ( ! $args['refresh'] && ! empty( self::$current_language ) ) {
return self::$current_language;
}
$this->get_current_language_data( $args );
return self::$current_language;
} | [
"public",
"function",
"get_current_language",
"(",
"$",
"args",
"=",
"array",
"(",
")",
")",
"{",
"$",
"args",
"=",
"wp_parse_args",
"(",
"$",
"args",
",",
"array",
"(",
"'refresh'",
"=>",
"false",
",",
")",
")",
";",
"if",
"(",
"!",
"$",
"args",
"... | Get current locale information from Multilingual plugins
@since 2.7.0
@param array $args (optional) {
@type bool $refresh Rerun get_current_language() logic?
}
@return string | [
"Get",
"current",
"locale",
"information",
"from",
"Multilingual",
"plugins"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsI18n.php#L217-L232 | train |
pods-framework/pods | classes/PodsData.php | PodsData.calculate_totals | public function calculate_totals() {
/**
* @var $wpdb wpdb
*/
global $wpdb;
// Set totals.
if ( false !== $this->total_sql ) {
$total = @current( $wpdb->get_col( $this->get_sql( $this->total_sql ) ) );
} else {
$total = @current( $wpdb->get_col( 'SELECT FOUND_ROWS()' ) );
}
$total = self::do_hook( 'select_total', $total, $this );
$this->total_found = 0;
$this->total_found_calculated = true;
if ( is_numeric( $total ) ) {
$this->total_found = $total;
}
} | php | public function calculate_totals() {
/**
* @var $wpdb wpdb
*/
global $wpdb;
// Set totals.
if ( false !== $this->total_sql ) {
$total = @current( $wpdb->get_col( $this->get_sql( $this->total_sql ) ) );
} else {
$total = @current( $wpdb->get_col( 'SELECT FOUND_ROWS()' ) );
}
$total = self::do_hook( 'select_total', $total, $this );
$this->total_found = 0;
$this->total_found_calculated = true;
if ( is_numeric( $total ) ) {
$this->total_found = $total;
}
} | [
"public",
"function",
"calculate_totals",
"(",
")",
"{",
"/**\n\t\t * @var $wpdb wpdb\n\t\t */",
"global",
"$",
"wpdb",
";",
"// Set totals.",
"if",
"(",
"false",
"!==",
"$",
"this",
"->",
"total_sql",
")",
"{",
"$",
"total",
"=",
"@",
"current",
"(",
"$",
"... | Calculate total found. | [
"Calculate",
"total",
"found",
"."
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsData.php#L800-L821 | train |
pods-framework/pods | classes/PodsData.php | PodsData.table_create | public static function table_create( $table, $fields, $if_not_exists = false ) {
/**
* @var $wpdb wpdb
*/
global $wpdb;
$sql = 'CREATE TABLE';
if ( true === $if_not_exists ) {
$sql .= ' IF NOT EXISTS';
}
$sql .= " `{$wpdb->prefix}" . self::$prefix . "{$table}` ({$fields})";
if ( ! empty( $wpdb->charset ) ) {
$sql .= " DEFAULT CHARACTER SET {$wpdb->charset}";
}
if ( ! empty( $wpdb->collate ) ) {
$sql .= " COLLATE {$wpdb->collate}";
}
return self::query( $sql );
} | php | public static function table_create( $table, $fields, $if_not_exists = false ) {
/**
* @var $wpdb wpdb
*/
global $wpdb;
$sql = 'CREATE TABLE';
if ( true === $if_not_exists ) {
$sql .= ' IF NOT EXISTS';
}
$sql .= " `{$wpdb->prefix}" . self::$prefix . "{$table}` ({$fields})";
if ( ! empty( $wpdb->charset ) ) {
$sql .= " DEFAULT CHARACTER SET {$wpdb->charset}";
}
if ( ! empty( $wpdb->collate ) ) {
$sql .= " COLLATE {$wpdb->collate}";
}
return self::query( $sql );
} | [
"public",
"static",
"function",
"table_create",
"(",
"$",
"table",
",",
"$",
"fields",
",",
"$",
"if_not_exists",
"=",
"false",
")",
"{",
"/**\n\t\t * @var $wpdb wpdb\n\t\t */",
"global",
"$",
"wpdb",
";",
"$",
"sql",
"=",
"'CREATE TABLE'",
";",
"if",
"(",
"... | Create a Table
@param string $table Table name.
@param string $fields
@param boolean $if_not_exists Check if the table exists.
@return array|bool|mixed|null|void
@uses PodsData::query
@since 2.0.0 | [
"Create",
"a",
"Table"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsData.php#L1796-L1820 | train |
pods-framework/pods | classes/PodsData.php | PodsData.table_alter | public static function table_alter( $table, $changes ) {
/**
* @var $wpdb wpdb
*/
global $wpdb;
$sql = "ALTER TABLE `{$wpdb->prefix}" . self::$prefix . "{$table}` {$changes}";
return self::query( $sql );
} | php | public static function table_alter( $table, $changes ) {
/**
* @var $wpdb wpdb
*/
global $wpdb;
$sql = "ALTER TABLE `{$wpdb->prefix}" . self::$prefix . "{$table}` {$changes}";
return self::query( $sql );
} | [
"public",
"static",
"function",
"table_alter",
"(",
"$",
"table",
",",
"$",
"changes",
")",
"{",
"/**\n\t\t * @var $wpdb wpdb\n\t\t */",
"global",
"$",
"wpdb",
";",
"$",
"sql",
"=",
"\"ALTER TABLE `{$wpdb->prefix}\"",
".",
"self",
"::",
"$",
"prefix",
".",
"\"{$... | Alter a Table
@param string $table Table name.
@param string $changes
@return array|bool|mixed|null|void
@uses PodsData::query
@since 2.0.0 | [
"Alter",
"a",
"Table"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsData.php#L1834-L1844 | train |
pods-framework/pods | classes/PodsData.php | PodsData.reset | public function reset( $row = null ) {
$row = pods_absint( $row );
$this->row = false;
if ( isset( $this->data[ $row ] ) ) {
$this->row = get_object_vars( $this->data[ $row ] );
}
if ( empty( $row ) ) {
$this->row_number = - 1;
} else {
$this->row_number = $row - 1;
}
return $this->row;
} | php | public function reset( $row = null ) {
$row = pods_absint( $row );
$this->row = false;
if ( isset( $this->data[ $row ] ) ) {
$this->row = get_object_vars( $this->data[ $row ] );
}
if ( empty( $row ) ) {
$this->row_number = - 1;
} else {
$this->row_number = $row - 1;
}
return $this->row;
} | [
"public",
"function",
"reset",
"(",
"$",
"row",
"=",
"null",
")",
"{",
"$",
"row",
"=",
"pods_absint",
"(",
"$",
"row",
")",
";",
"$",
"this",
"->",
"row",
"=",
"false",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"data",
"[",
"$",
"row",
... | Reset the current data
@param int $row Row number to reset to.
@return mixed
@since 2.0.0 | [
"Reset",
"the",
"current",
"data"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsData.php#L2248-L2265 | train |
pods-framework/pods | classes/PodsData.php | PodsData.get_table_columns | public static function get_table_columns( $table ) {
global $wpdb;
self::query( "SHOW COLUMNS FROM `{$table}` " );
$table_columns = $wpdb->last_result;
$table_cols_and_types = array();
foreach ( $table_columns as $table_col ) {
// Get only the type, not the attributes.
if ( false === strpos( $table_col->Type, '(' ) ) {
$modified_type = $table_col->Type;
} else {
$modified_type = substr( $table_col->Type, 0, ( strpos( $table_col->Type, '(' ) ) );
}
$table_cols_and_types[ $table_col->Field ] = $modified_type;
}
return $table_cols_and_types;
} | php | public static function get_table_columns( $table ) {
global $wpdb;
self::query( "SHOW COLUMNS FROM `{$table}` " );
$table_columns = $wpdb->last_result;
$table_cols_and_types = array();
foreach ( $table_columns as $table_col ) {
// Get only the type, not the attributes.
if ( false === strpos( $table_col->Type, '(' ) ) {
$modified_type = $table_col->Type;
} else {
$modified_type = substr( $table_col->Type, 0, ( strpos( $table_col->Type, '(' ) ) );
}
$table_cols_and_types[ $table_col->Field ] = $modified_type;
}
return $table_cols_and_types;
} | [
"public",
"static",
"function",
"get_table_columns",
"(",
"$",
"table",
")",
"{",
"global",
"$",
"wpdb",
";",
"self",
"::",
"query",
"(",
"\"SHOW COLUMNS FROM `{$table}` \"",
")",
";",
"$",
"table_columns",
"=",
"$",
"wpdb",
"->",
"last_result",
";",
"$",
"t... | Gets column information from a table
@param string $table Table Name.
@return array
@since 2.0.0 | [
"Gets",
"column",
"information",
"from",
"a",
"table"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsData.php#L2430-L2452 | train |
pods-framework/pods | classes/PodsData.php | PodsData.get_column_data | public static function get_column_data( $column_name, $table ) {
global $wpdb;
$column_data = $wpdb->get_results( 'DESCRIBE ' . $table, ARRAY_A );
foreach ( $column_data as $single_column ) {
if ( $column_name === $single_column['Field'] ) {
return $single_column;
}
}
return $column_data;
} | php | public static function get_column_data( $column_name, $table ) {
global $wpdb;
$column_data = $wpdb->get_results( 'DESCRIBE ' . $table, ARRAY_A );
foreach ( $column_data as $single_column ) {
if ( $column_name === $single_column['Field'] ) {
return $single_column;
}
}
return $column_data;
} | [
"public",
"static",
"function",
"get_column_data",
"(",
"$",
"column_name",
",",
"$",
"table",
")",
"{",
"global",
"$",
"wpdb",
";",
"$",
"column_data",
"=",
"$",
"wpdb",
"->",
"get_results",
"(",
"'DESCRIBE '",
".",
"$",
"table",
",",
"ARRAY_A",
")",
";... | Gets column data information from a table
@param string $column_name Column name.
@param string $table Table name.
@return array
@since 2.0.0 | [
"Gets",
"column",
"data",
"information",
"from",
"a",
"table"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsData.php#L2464-L2477 | train |
pods-framework/pods | classes/PodsData.php | PodsData.prepare | public static function prepare( $sql, $data ) {
/**
* @var $wpdb wpdb
*/
global $wpdb;
list( $sql, $data ) = apply_filters( 'pods_data_prepare', array( $sql, $data ) );
return $wpdb->prepare( $sql, $data );
} | php | public static function prepare( $sql, $data ) {
/**
* @var $wpdb wpdb
*/
global $wpdb;
list( $sql, $data ) = apply_filters( 'pods_data_prepare', array( $sql, $data ) );
return $wpdb->prepare( $sql, $data );
} | [
"public",
"static",
"function",
"prepare",
"(",
"$",
"sql",
",",
"$",
"data",
")",
"{",
"/**\n\t\t * @var $wpdb wpdb\n\t\t */",
"global",
"$",
"wpdb",
";",
"list",
"(",
"$",
"sql",
",",
"$",
"data",
")",
"=",
"apply_filters",
"(",
"'pods_data_prepare'",
",",... | Prepare values for the DB
@param string $sql SQL to prepare.
@param array $data Data to add to the sql prepare statement.
@return bool|null|string
@since 2.0.0 | [
"Prepare",
"values",
"for",
"the",
"DB"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsData.php#L2489-L2498 | train |
pods-framework/pods | classes/PodsData.php | PodsData.traverse_build | public function traverse_build( $fields = null, $params = null ) {
if ( null === $fields ) {
$fields = $this->fields;
}
$feed = array();
foreach ( $fields as $field => $data ) {
if ( ! is_array( $data ) ) {
$field = $data;
}
if ( ! isset( $_GET[ 'filter_' . $field ] ) ) {
continue;
}
$field_value = pods_v( 'filter_' . $field, 'get', false, true );
if ( ! empty( $field_value ) || 0 < strlen( $field_value ) ) {
$feed[ 'traverse_' . $field ] = array( $field );
}
}
return $feed;
} | php | public function traverse_build( $fields = null, $params = null ) {
if ( null === $fields ) {
$fields = $this->fields;
}
$feed = array();
foreach ( $fields as $field => $data ) {
if ( ! is_array( $data ) ) {
$field = $data;
}
if ( ! isset( $_GET[ 'filter_' . $field ] ) ) {
continue;
}
$field_value = pods_v( 'filter_' . $field, 'get', false, true );
if ( ! empty( $field_value ) || 0 < strlen( $field_value ) ) {
$feed[ 'traverse_' . $field ] = array( $field );
}
}
return $feed;
} | [
"public",
"function",
"traverse_build",
"(",
"$",
"fields",
"=",
"null",
",",
"$",
"params",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"fields",
")",
"{",
"$",
"fields",
"=",
"$",
"this",
"->",
"fields",
";",
"}",
"$",
"feed",
"=",
"a... | Setup fields for traversal
@param array $fields Associative array of fields data.
@return array Traverse feed
@param object $params (optional) Parameters from build().
@since 2.0.0 | [
"Setup",
"fields",
"for",
"traversal"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsData.php#L2996-L3021 | train |
pods-framework/pods | classes/PodsData.php | PodsData.get_sql | public function get_sql( $sql ) {
global $wpdb;
if ( empty( $sql ) ) {
$sql = $this->sql;
}
/**
* Allow SQL query to be manipulated.
*
* @param string $sql SQL Query string.
* @param PodsData $pods_data PodsData object.
*
* @since 2.7.0
*/
$sql = apply_filters( 'pods_data_get_sql', $sql, $this );
$sql = str_replace( array( '@wp_users', '@wp_' ), array( $wpdb->users, $wpdb->prefix ), $sql );
$sql = str_replace( '{prefix}', '@wp_', $sql );
$sql = str_replace( '{/prefix/}', '{prefix}', $sql );
return $sql;
} | php | public function get_sql( $sql ) {
global $wpdb;
if ( empty( $sql ) ) {
$sql = $this->sql;
}
/**
* Allow SQL query to be manipulated.
*
* @param string $sql SQL Query string.
* @param PodsData $pods_data PodsData object.
*
* @since 2.7.0
*/
$sql = apply_filters( 'pods_data_get_sql', $sql, $this );
$sql = str_replace( array( '@wp_users', '@wp_' ), array( $wpdb->users, $wpdb->prefix ), $sql );
$sql = str_replace( '{prefix}', '@wp_', $sql );
$sql = str_replace( '{/prefix/}', '{prefix}', $sql );
return $sql;
} | [
"public",
"function",
"get_sql",
"(",
"$",
"sql",
")",
"{",
"global",
"$",
"wpdb",
";",
"if",
"(",
"empty",
"(",
"$",
"sql",
")",
")",
"{",
"$",
"sql",
"=",
"$",
"this",
"->",
"sql",
";",
"}",
"/**\n\t\t * Allow SQL query to be manipulated.\n\t\t *\n\t\t *... | Get the complete sql
@since 2.0.5 | [
"Get",
"the",
"complete",
"sql"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsData.php#L3523-L3547 | train |
pods-framework/pods | classes/PodsComponents.php | PodsComponents.options | public function options( $component, $options ) {
if ( ! isset( $this->settings['components'][ $component ] ) || ! is_array( $this->settings['components'][ $component ] ) ) {
$this->settings['components'][ $component ] = array();
}
foreach ( $options as $option => $data ) {
if ( ! isset( $this->settings['components'][ $component ][ $option ] ) && isset( $data['default'] ) ) {
$this->settings['components'][ $component ][ $option ] = $data['default'];
}
}
} | php | public function options( $component, $options ) {
if ( ! isset( $this->settings['components'][ $component ] ) || ! is_array( $this->settings['components'][ $component ] ) ) {
$this->settings['components'][ $component ] = array();
}
foreach ( $options as $option => $data ) {
if ( ! isset( $this->settings['components'][ $component ][ $option ] ) && isset( $data['default'] ) ) {
$this->settings['components'][ $component ][ $option ] = $data['default'];
}
}
} | [
"public",
"function",
"options",
"(",
"$",
"component",
",",
"$",
"options",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"settings",
"[",
"'components'",
"]",
"[",
"$",
"component",
"]",
")",
"||",
"!",
"is_array",
"(",
"$",
"this",
... | Set component options
@param string $component Component name.
@param array $options Component options.
@since 2.0.0 | [
"Set",
"component",
"options"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsComponents.php#L521-L532 | train |
pods-framework/pods | classes/PodsComponents.php | PodsComponents.admin_handler | public function admin_handler() {
$component = str_replace( 'pods-component-', '', pods_v_sanitized( 'page' ) );
if ( isset( $this->components[ $component ] ) && isset( $this->components[ $component ]['object'] ) && is_object( $this->components[ $component ]['object'] ) ) {
// Component init
if ( method_exists( $this->components[ $component ]['object'], 'init' ) ) {
$this->components[ $component ]['object']->init( $this->settings['components'][ $component ], $component );
}
if ( method_exists( $this->components[ $component ]['object'], 'admin' ) ) {
// Component Admin handler
$this->components[ $component ]['object']->admin( $this->settings['components'][ $component ], $component );
} elseif ( method_exists( $this->components[ $component ]['object'], 'options' ) ) {
// Built-in Admin Handler
$this->admin( $this->components[ $component ]['object']->options( $this->settings['components'][ $component ] ), $this->settings['components'][ $component ], $component );
}
}
} | php | public function admin_handler() {
$component = str_replace( 'pods-component-', '', pods_v_sanitized( 'page' ) );
if ( isset( $this->components[ $component ] ) && isset( $this->components[ $component ]['object'] ) && is_object( $this->components[ $component ]['object'] ) ) {
// Component init
if ( method_exists( $this->components[ $component ]['object'], 'init' ) ) {
$this->components[ $component ]['object']->init( $this->settings['components'][ $component ], $component );
}
if ( method_exists( $this->components[ $component ]['object'], 'admin' ) ) {
// Component Admin handler
$this->components[ $component ]['object']->admin( $this->settings['components'][ $component ], $component );
} elseif ( method_exists( $this->components[ $component ]['object'], 'options' ) ) {
// Built-in Admin Handler
$this->admin( $this->components[ $component ]['object']->options( $this->settings['components'][ $component ] ), $this->settings['components'][ $component ], $component );
}
}
} | [
"public",
"function",
"admin_handler",
"(",
")",
"{",
"$",
"component",
"=",
"str_replace",
"(",
"'pods-component-'",
",",
"''",
",",
"pods_v_sanitized",
"(",
"'page'",
")",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"components",
"[",
"$",
"c... | Call component specific admin functions
@since 2.0.0 | [
"Call",
"component",
"specific",
"admin",
"functions"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsComponents.php#L539-L557 | train |
pods-framework/pods | classes/PodsComponents.php | PodsComponents.admin | public function admin( $options, $settings, $component ) {
if ( ! isset( $this->components[ $component ] ) ) {
wp_die( 'Invalid Component', '', array( 'back_link' => true ) );
}
$component_label = $this->components[ $component ]['Name'];
include PODS_DIR . 'ui/admin/components-admin.php';
} | php | public function admin( $options, $settings, $component ) {
if ( ! isset( $this->components[ $component ] ) ) {
wp_die( 'Invalid Component', '', array( 'back_link' => true ) );
}
$component_label = $this->components[ $component ]['Name'];
include PODS_DIR . 'ui/admin/components-admin.php';
} | [
"public",
"function",
"admin",
"(",
"$",
"options",
",",
"$",
"settings",
",",
"$",
"component",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"components",
"[",
"$",
"component",
"]",
")",
")",
"{",
"wp_die",
"(",
"'Invalid Component'",
... | Render components admin.
@param array $options Component options.
@param array $settings Component setting values.
@param string $component Component name. | [
"Render",
"components",
"admin",
"."
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsComponents.php#L566-L575 | train |
pods-framework/pods | classes/PodsComponents.php | PodsComponents.is_component_active | public function is_component_active( $component ) {
$active = false;
if ( isset( $this->components[ $component ] ) && isset( $this->settings['components'][ $component ] ) && 0 !== $this->settings['components'][ $component ] ) {
$active = true;
}
return $active;
} | php | public function is_component_active( $component ) {
$active = false;
if ( isset( $this->components[ $component ] ) && isset( $this->settings['components'][ $component ] ) && 0 !== $this->settings['components'][ $component ] ) {
$active = true;
}
return $active;
} | [
"public",
"function",
"is_component_active",
"(",
"$",
"component",
")",
"{",
"$",
"active",
"=",
"false",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"components",
"[",
"$",
"component",
"]",
")",
"&&",
"isset",
"(",
"$",
"this",
"->",
"settings"... | Check if a component is active or not
@param string $component The component name to check if active.
@return bool
@since 2.7.0 | [
"Check",
"if",
"a",
"component",
"is",
"active",
"or",
"not"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsComponents.php#L586-L596 | train |
pods-framework/pods | classes/PodsComponents.php | PodsComponents.activate_component | public function activate_component( $component ) {
$activated = false;
if ( ! $this->is_component_active( $component ) ) {
if ( empty( $this->components ) ) {
// Setup components
PodsInit::$components->get_components();
}
if ( isset( $this->components[ $component ] ) ) {
$this->settings['components'][ $component ] = array();
$this->update_settings( $this->settings );
$activated = true;
}
} else {
$activated = true;
}//end if
return $activated;
} | php | public function activate_component( $component ) {
$activated = false;
if ( ! $this->is_component_active( $component ) ) {
if ( empty( $this->components ) ) {
// Setup components
PodsInit::$components->get_components();
}
if ( isset( $this->components[ $component ] ) ) {
$this->settings['components'][ $component ] = array();
$this->update_settings( $this->settings );
$activated = true;
}
} else {
$activated = true;
}//end if
return $activated;
} | [
"public",
"function",
"activate_component",
"(",
"$",
"component",
")",
"{",
"$",
"activated",
"=",
"false",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"is_component_active",
"(",
"$",
"component",
")",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->"... | Activate a component
@param string $component The component name to activate.
@return boolean Whether the component was activated.
@since 2.7.0 | [
"Activate",
"a",
"component"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsComponents.php#L607-L630 | train |
pods-framework/pods | classes/PodsComponents.php | PodsComponents.deactivate_component | public function deactivate_component( $component ) {
if ( $this->is_component_active( $component ) ) {
if ( isset( $this->components[ $component ] ) ) {
$this->settings['components'][ $component ] = 0;
$this->update_settings( $this->settings );
}
}
} | php | public function deactivate_component( $component ) {
if ( $this->is_component_active( $component ) ) {
if ( isset( $this->components[ $component ] ) ) {
$this->settings['components'][ $component ] = 0;
$this->update_settings( $this->settings );
}
}
} | [
"public",
"function",
"deactivate_component",
"(",
"$",
"component",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"is_component_active",
"(",
"$",
"component",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"components",
"[",
"$",
"component",
"]"... | Deactivate a component
@param string $component The component name to deactivate.
@since 2.7.0 | [
"Deactivate",
"a",
"component"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsComponents.php#L639-L649 | train |
pods-framework/pods | classes/PodsComponents.php | PodsComponents.admin_ajax | public function admin_ajax() {
if ( false === headers_sent() ) {
pods_session_start();
header( 'Content-Type: text/html; charset=' . get_bloginfo( 'charset' ) );
}
// Sanitize input @codingStandardsIgnoreLine
$params = pods_unslash( (array) $_POST );
foreach ( $params as $key => $value ) {
if ( 'action' === $key ) {
continue;
}
unset( $params[ $key ] );
$params[ str_replace( '_podsfix_', '', $key ) ] = $value;
}
$params = (object) $params;
$component = $params->component;
$method = $params->method;
if ( ! isset( $component ) || ! isset( $this->components[ $component ] ) || ! isset( $this->settings['components'][ $component ] ) ) {
pods_error( 'Invalid AJAX request', $this );
}
if ( ! isset( $params->_wpnonce ) || false === wp_verify_nonce( $params->_wpnonce, 'pods-component-' . $component . '-' . $method ) ) {
pods_error( 'Unauthorized request', $this );
}
// Cleaning up $params
unset( $params->action, $params->component, $params->method, $params->_wpnonce );
$params = (object) apply_filters( "pods_component_ajax_{$component}_{$method}", $params, $component, $method );
$output = false;
// Component init
if ( isset( $this->components[ $component ]['object'] ) && method_exists( $this->components[ $component ]['object'], 'init' ) ) {
$this->components[ $component ]['object']->init( $this->settings['components'][ $component ], $component );
}
if ( isset( $this->components[ $component ]['object'] ) && ! method_exists( $this->components[ $component ]['object'], 'ajax_' . $method ) && method_exists( $this, 'admin_ajax_' . $method ) ) {
// Handle internal methods
$output = call_user_func( array( $this, 'admin_ajax_' . $method ), $component, $params );
} elseif ( ! isset( $this->components[ $component ]['object'] ) || ! method_exists( $this->components[ $component ]['object'], 'ajax_' . $method ) ) {
// Make sure method exists
pods_error( 'API method does not exist', $this );
} else {
// Dynamically call the component method
$output = call_user_func( array( $this->components[ $component ]['object'], 'ajax_' . $method ), $params );
}
if ( ! is_bool( $output ) ) {
// @codingStandardsIgnoreLine
echo $output;
}
die();
// KBAI!
} | php | public function admin_ajax() {
if ( false === headers_sent() ) {
pods_session_start();
header( 'Content-Type: text/html; charset=' . get_bloginfo( 'charset' ) );
}
// Sanitize input @codingStandardsIgnoreLine
$params = pods_unslash( (array) $_POST );
foreach ( $params as $key => $value ) {
if ( 'action' === $key ) {
continue;
}
unset( $params[ $key ] );
$params[ str_replace( '_podsfix_', '', $key ) ] = $value;
}
$params = (object) $params;
$component = $params->component;
$method = $params->method;
if ( ! isset( $component ) || ! isset( $this->components[ $component ] ) || ! isset( $this->settings['components'][ $component ] ) ) {
pods_error( 'Invalid AJAX request', $this );
}
if ( ! isset( $params->_wpnonce ) || false === wp_verify_nonce( $params->_wpnonce, 'pods-component-' . $component . '-' . $method ) ) {
pods_error( 'Unauthorized request', $this );
}
// Cleaning up $params
unset( $params->action, $params->component, $params->method, $params->_wpnonce );
$params = (object) apply_filters( "pods_component_ajax_{$component}_{$method}", $params, $component, $method );
$output = false;
// Component init
if ( isset( $this->components[ $component ]['object'] ) && method_exists( $this->components[ $component ]['object'], 'init' ) ) {
$this->components[ $component ]['object']->init( $this->settings['components'][ $component ], $component );
}
if ( isset( $this->components[ $component ]['object'] ) && ! method_exists( $this->components[ $component ]['object'], 'ajax_' . $method ) && method_exists( $this, 'admin_ajax_' . $method ) ) {
// Handle internal methods
$output = call_user_func( array( $this, 'admin_ajax_' . $method ), $component, $params );
} elseif ( ! isset( $this->components[ $component ]['object'] ) || ! method_exists( $this->components[ $component ]['object'], 'ajax_' . $method ) ) {
// Make sure method exists
pods_error( 'API method does not exist', $this );
} else {
// Dynamically call the component method
$output = call_user_func( array( $this->components[ $component ]['object'], 'ajax_' . $method ), $params );
}
if ( ! is_bool( $output ) ) {
// @codingStandardsIgnoreLine
echo $output;
}
die();
// KBAI!
} | [
"public",
"function",
"admin_ajax",
"(",
")",
"{",
"if",
"(",
"false",
"===",
"headers_sent",
"(",
")",
")",
"{",
"pods_session_start",
"(",
")",
";",
"header",
"(",
"'Content-Type: text/html; charset='",
".",
"get_bloginfo",
"(",
"'charset'",
")",
")",
";",
... | Handle admin ajax
@since 2.0.0 | [
"Handle",
"admin",
"ajax"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsComponents.php#L726-L790 | train |
pods-framework/pods | classes/PodsComponents.php | PodsComponents.admin_ajax_settings | public function admin_ajax_settings( $component, $params ) {
if ( ! isset( $this->components[ $component ] ) ) {
wp_die( 'Invalid Component', '', array( 'back_link' => true ) );
} elseif ( ! method_exists( $this->components[ $component ]['object'], 'options' ) ) {
pods_error( 'Component options method does not exist', $this );
}
$options = $this->components[ $component ]['object']->options( $this->settings['components'][ $component ] );
if ( empty( $this->settings['components'][ $component ] ) ) {
$this->settings['components'][ $component ] = array();
}
foreach ( $options as $field_name => $field_option ) {
$field_option = PodsForm::field_setup( $field_option, null, $field_option['type'] );
if ( ! is_array( $field_option['group'] ) ) {
$field_value = pods_v( 'pods_setting_' . $field_name, $params );
$this->settings['components'][ $component ][ $field_name ] = $field_value;
} else {
foreach ( $field_option['group'] as $field_group_name => $field_group_option ) {
$field_value = pods_v( 'pods_setting_' . $field_group_name, $params );
$this->settings['components'][ $component ][ $field_group_name ] = $field_value;
}
}
}
$this->update_settings( $this->settings );
return '1';
} | php | public function admin_ajax_settings( $component, $params ) {
if ( ! isset( $this->components[ $component ] ) ) {
wp_die( 'Invalid Component', '', array( 'back_link' => true ) );
} elseif ( ! method_exists( $this->components[ $component ]['object'], 'options' ) ) {
pods_error( 'Component options method does not exist', $this );
}
$options = $this->components[ $component ]['object']->options( $this->settings['components'][ $component ] );
if ( empty( $this->settings['components'][ $component ] ) ) {
$this->settings['components'][ $component ] = array();
}
foreach ( $options as $field_name => $field_option ) {
$field_option = PodsForm::field_setup( $field_option, null, $field_option['type'] );
if ( ! is_array( $field_option['group'] ) ) {
$field_value = pods_v( 'pods_setting_' . $field_name, $params );
$this->settings['components'][ $component ][ $field_name ] = $field_value;
} else {
foreach ( $field_option['group'] as $field_group_name => $field_group_option ) {
$field_value = pods_v( 'pods_setting_' . $field_group_name, $params );
$this->settings['components'][ $component ][ $field_group_name ] = $field_value;
}
}
}
$this->update_settings( $this->settings );
return '1';
} | [
"public",
"function",
"admin_ajax_settings",
"(",
"$",
"component",
",",
"$",
"params",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"components",
"[",
"$",
"component",
"]",
")",
")",
"{",
"wp_die",
"(",
"'Invalid Component'",
",",
"''",
... | Handle admin AJAX settings saving.
@param string $component Component name.
@param array $params AJAX parameters.
@return string | [
"Handle",
"admin",
"AJAX",
"settings",
"saving",
"."
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsComponents.php#L800-L833 | train |
pods-framework/pods | classes/PodsComponents.php | PodsComponents.update_settings | public function update_settings( $settings ) {
if ( version_compare( PHP_VERSION, '5.4.0', '>=' ) ) {
$settings = wp_json_encode( $settings, JSON_UNESCAPED_UNICODE );
} else {
$settings = wp_json_encode( $settings );
}
update_option( 'pods_component_settings', $settings );
} | php | public function update_settings( $settings ) {
if ( version_compare( PHP_VERSION, '5.4.0', '>=' ) ) {
$settings = wp_json_encode( $settings, JSON_UNESCAPED_UNICODE );
} else {
$settings = wp_json_encode( $settings );
}
update_option( 'pods_component_settings', $settings );
} | [
"public",
"function",
"update_settings",
"(",
"$",
"settings",
")",
"{",
"if",
"(",
"version_compare",
"(",
"PHP_VERSION",
",",
"'5.4.0'",
",",
"'>='",
")",
")",
"{",
"$",
"settings",
"=",
"wp_json_encode",
"(",
"$",
"settings",
",",
"JSON_UNESCAPED_UNICODE",
... | Update settings.
@param array $settings Component settings. | [
"Update",
"settings",
"."
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsComponents.php#L840-L850 | train |
pods-framework/pods | classes/fields/website.php | PodsField_Website.build_url | public function build_url( $url, $options = array() ) {
$url = (array) $url;
$allow_port = (int) pods_v( static::$type . '_allow_port', $options, 0 );
// If port is not allowed, always set to empty
if ( 0 === $allow_port ) {
$url['port'] = '';
}
if ( function_exists( 'http_build_url' ) ) {
return http_build_url( $url );
}
$defaults = array(
'scheme' => 'http',
'host' => '',
'port' => '',
'path' => '/',
'query' => '',
'fragment' => '',
);
$url = array_merge( $defaults, $url );
$new_url = array();
$new_url[] = trim( $url['scheme'] . '://', ':' );
$new_url[] = $url['host'];
if ( ! empty( $url['port'] ) ) {
$new_url[] = ':' . $url['port'];
}
$new_url[] = '/' . ltrim( $url['path'], '/' );
if ( ! empty( $url['query'] ) ) {
$new_url[] = '?' . ltrim( $url['query'], '?' );
}
if ( ! empty( $url['fragment'] ) ) {
$new_url[] = '#' . ltrim( $url['fragment'], '#' );
}
// Pull all of the parts back together
$new_url = implode( '', $new_url );
return $new_url;
} | php | public function build_url( $url, $options = array() ) {
$url = (array) $url;
$allow_port = (int) pods_v( static::$type . '_allow_port', $options, 0 );
// If port is not allowed, always set to empty
if ( 0 === $allow_port ) {
$url['port'] = '';
}
if ( function_exists( 'http_build_url' ) ) {
return http_build_url( $url );
}
$defaults = array(
'scheme' => 'http',
'host' => '',
'port' => '',
'path' => '/',
'query' => '',
'fragment' => '',
);
$url = array_merge( $defaults, $url );
$new_url = array();
$new_url[] = trim( $url['scheme'] . '://', ':' );
$new_url[] = $url['host'];
if ( ! empty( $url['port'] ) ) {
$new_url[] = ':' . $url['port'];
}
$new_url[] = '/' . ltrim( $url['path'], '/' );
if ( ! empty( $url['query'] ) ) {
$new_url[] = '?' . ltrim( $url['query'], '?' );
}
if ( ! empty( $url['fragment'] ) ) {
$new_url[] = '#' . ltrim( $url['fragment'], '#' );
}
// Pull all of the parts back together
$new_url = implode( '', $new_url );
return $new_url;
} | [
"public",
"function",
"build_url",
"(",
"$",
"url",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"url",
"=",
"(",
"array",
")",
"$",
"url",
";",
"$",
"allow_port",
"=",
"(",
"int",
")",
"pods_v",
"(",
"static",
"::",
"$",
"type",
... | Build a url from url parts
@param array|string $url URL value.
@param array $options Field options.
@return string | [
"Build",
"a",
"url",
"from",
"url",
"parts"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/fields/website.php#L351-L401 | train |
pods-framework/pods | classes/PodsRESTHandlers.php | PodsRESTHandlers.get_pod | protected static function get_pod( $pod_name, $id ) {
if ( ! self::$pod || self::$pod->pod !== $pod_name ) {
self::$pod = pods( $pod_name, $id, true );
}
if ( self::$pod && (int) self::$pod->id !== (int) $id ) {
self::$pod->fetch( $id );
}
return self::$pod;
} | php | protected static function get_pod( $pod_name, $id ) {
if ( ! self::$pod || self::$pod->pod !== $pod_name ) {
self::$pod = pods( $pod_name, $id, true );
}
if ( self::$pod && (int) self::$pod->id !== (int) $id ) {
self::$pod->fetch( $id );
}
return self::$pod;
} | [
"protected",
"static",
"function",
"get_pod",
"(",
"$",
"pod_name",
",",
"$",
"id",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"$",
"pod",
"||",
"self",
"::",
"$",
"pod",
"->",
"pod",
"!==",
"$",
"pod_name",
")",
"{",
"self",
"::",
"$",
"pod",
"=",
... | Get Pod object
@since 2.5.6
@param $pod_name
@param $id
@return bool|Pods | [
"Get",
"Pod",
"object"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsRESTHandlers.php#L32-L44 | train |
pods-framework/pods | classes/PodsRESTHandlers.php | PodsRESTHandlers.save_handler | public static function save_handler( $object, $request, $creating ) {
if ( is_a( $object, 'WP_Post' ) ) {
$pod_name = $object->post_type;
if ( 'attachment' === $pod_name ) {
$pod_name = 'media';
}
$id = $object->ID;
} elseif ( is_a( $object, 'WP_Term' ) ) {
$pod_name = $object->taxonomy;
$id = $object->term_id;
} elseif ( is_a( $object, 'WP_User' ) ) {
$pod_name = 'user';
$id = $object->ID;
} elseif ( is_a( $object, 'WP_Comment' ) ) {
$pod_name = 'comment';
$id = $object->comment_ID;
} else {
// Not a supported object
return;
}//end if
$pod = self::get_pod( $pod_name, $id );
global $wp_rest_additional_fields;
$rest_enable = (boolean) pods_v( 'rest_enable', $pod->pod_data['options'], false );
if ( $pod && $rest_enable && ! empty( $wp_rest_additional_fields[ $pod_name ] ) ) {
$fields = $pod->fields();
$save_fields = array();
$params = array(
'is_new_item' => $creating,
);
foreach ( $fields as $field_name => $field ) {
if ( empty( $wp_rest_additional_fields[ $pod_name ][ $field_name ]['pods_update'] ) ) {
continue;
} elseif ( ! isset( $request[ $field_name ] ) ) {
continue;
} elseif ( ! PodsRESTFields::field_allowed_to_extend( $field_name, $pod, 'write' ) ) {
continue;
}
$save_fields[ $field_name ] = $request[ $field_name ];
}
if ( ! empty( $save_fields ) || $creating ) {
$pod->save( $save_fields, null, null, $params );
}
}//end if
} | php | public static function save_handler( $object, $request, $creating ) {
if ( is_a( $object, 'WP_Post' ) ) {
$pod_name = $object->post_type;
if ( 'attachment' === $pod_name ) {
$pod_name = 'media';
}
$id = $object->ID;
} elseif ( is_a( $object, 'WP_Term' ) ) {
$pod_name = $object->taxonomy;
$id = $object->term_id;
} elseif ( is_a( $object, 'WP_User' ) ) {
$pod_name = 'user';
$id = $object->ID;
} elseif ( is_a( $object, 'WP_Comment' ) ) {
$pod_name = 'comment';
$id = $object->comment_ID;
} else {
// Not a supported object
return;
}//end if
$pod = self::get_pod( $pod_name, $id );
global $wp_rest_additional_fields;
$rest_enable = (boolean) pods_v( 'rest_enable', $pod->pod_data['options'], false );
if ( $pod && $rest_enable && ! empty( $wp_rest_additional_fields[ $pod_name ] ) ) {
$fields = $pod->fields();
$save_fields = array();
$params = array(
'is_new_item' => $creating,
);
foreach ( $fields as $field_name => $field ) {
if ( empty( $wp_rest_additional_fields[ $pod_name ][ $field_name ]['pods_update'] ) ) {
continue;
} elseif ( ! isset( $request[ $field_name ] ) ) {
continue;
} elseif ( ! PodsRESTFields::field_allowed_to_extend( $field_name, $pod, 'write' ) ) {
continue;
}
$save_fields[ $field_name ] = $request[ $field_name ];
}
if ( ! empty( $save_fields ) || $creating ) {
$pod->save( $save_fields, null, null, $params );
}
}//end if
} | [
"public",
"static",
"function",
"save_handler",
"(",
"$",
"object",
",",
"$",
"request",
",",
"$",
"creating",
")",
"{",
"if",
"(",
"is_a",
"(",
"$",
"object",
",",
"'WP_Post'",
")",
")",
"{",
"$",
"pod_name",
"=",
"$",
"object",
"->",
"post_type",
"... | Handle saving of Pod fields from REST API write requests.
@param WP_Post|WP_Term|WP_User|WP_Comment $object Inserted or updated object.
@param WP_REST_Request $request Request object.
@param bool $creating True when creating an item, false when updating. | [
"Handle",
"saving",
"of",
"Pod",
"fields",
"from",
"REST",
"API",
"write",
"requests",
"."
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsRESTHandlers.php#L221-L280 | train |
pods-framework/pods | deprecated/classes/Pods.php | Pods_Deprecated.get_dropdown_values | public function get_dropdown_values( $params ) {
if ( Pod::$deprecated_notice ) {
pods_deprecated( 'Pods::get_dropdown_values', '2.0' );
}
global $wpdb;
$params = (object) $params;
$params->orderby = empty( $params->orderby ) ? '' : ' ORDER BY ' . $params->orderby;
$params->join = empty( $params->join ) ? '' : ' LEFT JOIN ' . $params->join;
$where = ( false !== $params->exclude ) ? "WHERE `t`.term_id NOT IN ({$params->exclude})" : '';
if ( ! empty( $params->pick_filter ) ) {
$where .= ( empty( $where ) ? ' WHERE ' : ' AND ' ) . $params->pick_filter;
}
if ( ! empty( $params->where ) ) {
$where .= ( empty( $where ) ? ' WHERE ' : ' AND ' ) . $params->where;
}
$sql = "
SELECT
`t`.`{$params->field_id}` AS `id`,
`t`.`{$params->field_name}` AS `name`
FROM `{$params->table}` AS `t`
{$params->join}
{$where}
{$params->orderby}
";
// override with custom dropdown values
$sql = apply_filters( 'pods_get_dropdown_values', $sql, $params, $this );
$val = array();
$result = pods_query( $sql );
foreach ( $result as $row ) {
$row = get_object_vars( $row );
$row['active'] = false;
if ( ! empty( $params->selected_ids ) ) {
$row['active'] = in_array( $row['id'], $params->selected_ids );
}
$val[] = $row;
}
return $val;
} | php | public function get_dropdown_values( $params ) {
if ( Pod::$deprecated_notice ) {
pods_deprecated( 'Pods::get_dropdown_values', '2.0' );
}
global $wpdb;
$params = (object) $params;
$params->orderby = empty( $params->orderby ) ? '' : ' ORDER BY ' . $params->orderby;
$params->join = empty( $params->join ) ? '' : ' LEFT JOIN ' . $params->join;
$where = ( false !== $params->exclude ) ? "WHERE `t`.term_id NOT IN ({$params->exclude})" : '';
if ( ! empty( $params->pick_filter ) ) {
$where .= ( empty( $where ) ? ' WHERE ' : ' AND ' ) . $params->pick_filter;
}
if ( ! empty( $params->where ) ) {
$where .= ( empty( $where ) ? ' WHERE ' : ' AND ' ) . $params->where;
}
$sql = "
SELECT
`t`.`{$params->field_id}` AS `id`,
`t`.`{$params->field_name}` AS `name`
FROM `{$params->table}` AS `t`
{$params->join}
{$where}
{$params->orderby}
";
// override with custom dropdown values
$sql = apply_filters( 'pods_get_dropdown_values', $sql, $params, $this );
$val = array();
$result = pods_query( $sql );
foreach ( $result as $row ) {
$row = get_object_vars( $row );
$row['active'] = false;
if ( ! empty( $params->selected_ids ) ) {
$row['active'] = in_array( $row['id'], $params->selected_ids );
}
$val[] = $row;
}
return $val;
} | [
"public",
"function",
"get_dropdown_values",
"(",
"$",
"params",
")",
"{",
"if",
"(",
"Pod",
"::",
"$",
"deprecated_notice",
")",
"{",
"pods_deprecated",
"(",
"'Pods::get_dropdown_values'",
",",
"'2.0'",
")",
";",
"}",
"global",
"$",
"wpdb",
";",
"$",
"param... | Get pod or category drop-down values
@param array $params
@return array | [
"Get",
"pod",
"or",
"category",
"drop",
"-",
"down",
"values"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/deprecated/classes/Pods.php#L316-L367 | train |
pods-framework/pods | deprecated/classes/Pods.php | Pods_Deprecated.publicForm | public function publicForm( $fields = null, $label = 'Save Changes', $thankyou_url = null ) {
if ( Pod::$deprecated_notice ) {
pods_deprecated( 'Pods::publicForm', '2.0', 'Pods::form' );
}
if ( ! empty( $fields ) ) {
// Just update field name here, form() will handle the rest
foreach ( $fields as $k => $field ) {
$name = $k;
if ( ! is_array( $field ) ) {
$name = $field;
$field = array();
} elseif ( isset( $field['name'] ) ) {
$name = $field['name'];
}
if ( in_array(
$name, array(
'created',
'modified',
'author',
), true
) && isset( $this->obj->fields[ $name . '2' ] ) ) {
$name .= '2';
}
$field['name'] = $name;
$fields[ $k ] = $field;
}//end foreach
}//end if
echo $this->obj->form( $fields, $label, $thankyou_url );
} | php | public function publicForm( $fields = null, $label = 'Save Changes', $thankyou_url = null ) {
if ( Pod::$deprecated_notice ) {
pods_deprecated( 'Pods::publicForm', '2.0', 'Pods::form' );
}
if ( ! empty( $fields ) ) {
// Just update field name here, form() will handle the rest
foreach ( $fields as $k => $field ) {
$name = $k;
if ( ! is_array( $field ) ) {
$name = $field;
$field = array();
} elseif ( isset( $field['name'] ) ) {
$name = $field['name'];
}
if ( in_array(
$name, array(
'created',
'modified',
'author',
), true
) && isset( $this->obj->fields[ $name . '2' ] ) ) {
$name .= '2';
}
$field['name'] = $name;
$fields[ $k ] = $field;
}//end foreach
}//end if
echo $this->obj->form( $fields, $label, $thankyou_url );
} | [
"public",
"function",
"publicForm",
"(",
"$",
"fields",
"=",
"null",
",",
"$",
"label",
"=",
"'Save Changes'",
",",
"$",
"thankyou_url",
"=",
"null",
")",
"{",
"if",
"(",
"Pod",
"::",
"$",
"deprecated_notice",
")",
"{",
"pods_deprecated",
"(",
"'Pods::publ... | Build public input form
@deprecated 2.0.0
@param null $fields
@param string $label
@param null $thankyou_url | [
"Build",
"public",
"input",
"form"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/deprecated/classes/Pods.php#L378-L413 | train |
pods-framework/pods | deprecated/classes/Pods.php | Pods_Deprecated.get_pod_id | public function get_pod_id() {
if ( Pod::$deprecated_notice ) {
pods_deprecated( 'Pods::get_pod_id', '2.0' );
}
if ( ! empty( $this->obj->row ) ) {
return $this->obj->row[ $this->obj->data->field_id ];
}
return false;
} | php | public function get_pod_id() {
if ( Pod::$deprecated_notice ) {
pods_deprecated( 'Pods::get_pod_id', '2.0' );
}
if ( ! empty( $this->obj->row ) ) {
return $this->obj->row[ $this->obj->data->field_id ];
}
return false;
} | [
"public",
"function",
"get_pod_id",
"(",
")",
"{",
"if",
"(",
"Pod",
"::",
"$",
"deprecated_notice",
")",
"{",
"pods_deprecated",
"(",
"'Pods::get_pod_id'",
",",
"'2.0'",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"obj",
"->",
"row... | Get the current item's pod ID from its datatype ID and tbl_row_id
@return int The ID from the wp_pod table
@since 1.2.0
@deprecated 2.0.0 | [
"Get",
"the",
"current",
"item",
"s",
"pod",
"ID",
"from",
"its",
"datatype",
"ID",
"and",
"tbl_row_id"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/deprecated/classes/Pods.php#L489-L500 | train |
pods-framework/pods | deprecated/classes/Pods.php | Pods_Deprecated.findRecords | public function findRecords( $orderby = null, $rows_per_page = 15, $where = null, $sql = null ) {
if ( Pod::$deprecated_notice ) {
pods_deprecated( 'Pods::findRecords', '2.0', 'Pods::find' );
}
$find = array(
' p.created',
'`p`.`created`',
'`p`.created',
' p.`created`',
' p.modified',
'`p`.`modified`',
'`p`.modified',
' p.`modified`',
' p.id',
'`p`.`id`',
'`p`.id',
' p.`id`',
' p.pod_id',
'`p`.`pod_id`',
'`p`.pod_id',
' p.`pod_id`',
);
$replace = array(
' t.created',
'`t`.`created`',
'`t`.created',
' t.`created`',
' t.modified',
'`t`.`modified`',
'`t`.modified',
' t.`modified`',
' t.id',
'`t`.`id`',
'`t`.id',
' t.`id`',
' t.id',
'`t`.`id`',
'`t`.id',
' t.`id`',
);
$params = array(
'where' => $where,
'orderby' => "`t`.`{$this->obj->data->field_id}` DESC",
'limit' => (int) $rows_per_page,
'page' => $this->obj->page,
'search' => $this->obj->search,
'search_across' => true,
'search_across_picks' => false,
'sql' => $sql,
);
if ( is_array( $orderby ) ) {
$params = array_merge( $params, $orderby );
} elseif ( ! empty( $orderby ) ) {
$params['orderby'] = $orderby;
}
$params['where'] = trim( str_replace( $find, $replace, ' ' . $params['where'] ) );
$params['orderby'] = trim( str_replace( $find, $replace, ' ' . $params['orderby'] ) );
$params = (object) $params;
$this->obj->limit = $params->limit;
$this->obj->page = $params->page;
$this->obj->search = $params->search;
return $this->obj->find( $params );
} | php | public function findRecords( $orderby = null, $rows_per_page = 15, $where = null, $sql = null ) {
if ( Pod::$deprecated_notice ) {
pods_deprecated( 'Pods::findRecords', '2.0', 'Pods::find' );
}
$find = array(
' p.created',
'`p`.`created`',
'`p`.created',
' p.`created`',
' p.modified',
'`p`.`modified`',
'`p`.modified',
' p.`modified`',
' p.id',
'`p`.`id`',
'`p`.id',
' p.`id`',
' p.pod_id',
'`p`.`pod_id`',
'`p`.pod_id',
' p.`pod_id`',
);
$replace = array(
' t.created',
'`t`.`created`',
'`t`.created',
' t.`created`',
' t.modified',
'`t`.`modified`',
'`t`.modified',
' t.`modified`',
' t.id',
'`t`.`id`',
'`t`.id',
' t.`id`',
' t.id',
'`t`.`id`',
'`t`.id',
' t.`id`',
);
$params = array(
'where' => $where,
'orderby' => "`t`.`{$this->obj->data->field_id}` DESC",
'limit' => (int) $rows_per_page,
'page' => $this->obj->page,
'search' => $this->obj->search,
'search_across' => true,
'search_across_picks' => false,
'sql' => $sql,
);
if ( is_array( $orderby ) ) {
$params = array_merge( $params, $orderby );
} elseif ( ! empty( $orderby ) ) {
$params['orderby'] = $orderby;
}
$params['where'] = trim( str_replace( $find, $replace, ' ' . $params['where'] ) );
$params['orderby'] = trim( str_replace( $find, $replace, ' ' . $params['orderby'] ) );
$params = (object) $params;
$this->obj->limit = $params->limit;
$this->obj->page = $params->page;
$this->obj->search = $params->search;
return $this->obj->find( $params );
} | [
"public",
"function",
"findRecords",
"(",
"$",
"orderby",
"=",
"null",
",",
"$",
"rows_per_page",
"=",
"15",
",",
"$",
"where",
"=",
"null",
",",
"$",
"sql",
"=",
"null",
")",
"{",
"if",
"(",
"Pod",
"::",
"$",
"deprecated_notice",
")",
"{",
"pods_dep... | Search and filter records
@since 1.x.x
@deprecated 2.0.0
@param null $orderby
@param int $rows_per_page
@param null $where
@param null $sql
@return | [
"Search",
"and",
"filter",
"records"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/deprecated/classes/Pods.php#L515-L586 | train |
pods-framework/pods | deprecated/classes/Pods.php | Pods_Deprecated.getFilters | public function getFilters( $filters = null, $label = 'Filter', $action = '' ) {
if ( Pod::$deprecated_notice ) {
pods_deprecated( 'Pods::getFilters', '2.0', 'Pods::filters' );
}
$params = array(
'fields' => $filters,
'label' => $label,
'action' => $action,
);
if ( is_array( $filters ) ) {
$params = array_merge( $params, $filters );
}
echo $this->obj->filters( $params );
} | php | public function getFilters( $filters = null, $label = 'Filter', $action = '' ) {
if ( Pod::$deprecated_notice ) {
pods_deprecated( 'Pods::getFilters', '2.0', 'Pods::filters' );
}
$params = array(
'fields' => $filters,
'label' => $label,
'action' => $action,
);
if ( is_array( $filters ) ) {
$params = array_merge( $params, $filters );
}
echo $this->obj->filters( $params );
} | [
"public",
"function",
"getFilters",
"(",
"$",
"filters",
"=",
"null",
",",
"$",
"label",
"=",
"'Filter'",
",",
"$",
"action",
"=",
"''",
")",
"{",
"if",
"(",
"Pod",
"::",
"$",
"deprecated_notice",
")",
"{",
"pods_deprecated",
"(",
"'Pods::getFilters'",
"... | Display the list filters
@deprecated 2.0.0
@param null $filters
@param string $label
@param string $action | [
"Display",
"the",
"list",
"filters"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/deprecated/classes/Pods.php#L669-L686 | train |
pods-framework/pods | components/Advanced-Relationships.php | Pods_Advanced_Relationships.add_related_objects | public function add_related_objects() {
PodsField_Pick::$related_objects['table'] = array(
'label' => __( 'Database Tables', 'pods' ),
'group' => __( 'Advanced Objects', 'pods' ),
);
if ( is_multisite() ) {
PodsField_Pick::$related_objects['site'] = array(
'label' => __( 'Multisite Sites', 'pods' ),
'group' => __( 'Advanced Objects', 'pods' ),
);
PodsField_Pick::$related_objects['network'] = array(
'label' => __( 'Multisite Networks', 'pods' ),
'group' => __( 'Advanced Objects', 'pods' ),
);
}
PodsField_Pick::$related_objects['theme'] = array(
'label' => __( 'Themes', 'pods' ),
'group' => __( 'Advanced Objects', 'pods' ),
'simple' => true,
'data_callback' => array( $this, 'data_themes' ),
);
PodsField_Pick::$related_objects['page-template'] = array(
'label' => __( 'Page Templates', 'pods' ),
'group' => __( 'Advanced Objects', 'pods' ),
'simple' => true,
'data_callback' => array( $this, 'data_page_templates' ),
);
PodsField_Pick::$related_objects['sidebar'] = array(
'label' => __( 'Sidebars', 'pods' ),
'group' => __( 'Advanced Objects', 'pods' ),
'simple' => true,
'data_callback' => array( $this, 'data_sidebars' ),
);
PodsField_Pick::$related_objects['post-types'] = array(
'label' => __( 'Post Type Objects', 'pods' ),
'group' => __( 'Advanced Objects', 'pods' ),
'simple' => true,
'data_callback' => array( $this, 'data_post_types' ),
);
PodsField_Pick::$related_objects['taxonomies'] = array(
'label' => __( 'Taxonomy Objects', 'pods' ),
'group' => __( 'Advanced Objects', 'pods' ),
'simple' => true,
'data_callback' => array( $this, 'data_taxonomies' ),
);
} | php | public function add_related_objects() {
PodsField_Pick::$related_objects['table'] = array(
'label' => __( 'Database Tables', 'pods' ),
'group' => __( 'Advanced Objects', 'pods' ),
);
if ( is_multisite() ) {
PodsField_Pick::$related_objects['site'] = array(
'label' => __( 'Multisite Sites', 'pods' ),
'group' => __( 'Advanced Objects', 'pods' ),
);
PodsField_Pick::$related_objects['network'] = array(
'label' => __( 'Multisite Networks', 'pods' ),
'group' => __( 'Advanced Objects', 'pods' ),
);
}
PodsField_Pick::$related_objects['theme'] = array(
'label' => __( 'Themes', 'pods' ),
'group' => __( 'Advanced Objects', 'pods' ),
'simple' => true,
'data_callback' => array( $this, 'data_themes' ),
);
PodsField_Pick::$related_objects['page-template'] = array(
'label' => __( 'Page Templates', 'pods' ),
'group' => __( 'Advanced Objects', 'pods' ),
'simple' => true,
'data_callback' => array( $this, 'data_page_templates' ),
);
PodsField_Pick::$related_objects['sidebar'] = array(
'label' => __( 'Sidebars', 'pods' ),
'group' => __( 'Advanced Objects', 'pods' ),
'simple' => true,
'data_callback' => array( $this, 'data_sidebars' ),
);
PodsField_Pick::$related_objects['post-types'] = array(
'label' => __( 'Post Type Objects', 'pods' ),
'group' => __( 'Advanced Objects', 'pods' ),
'simple' => true,
'data_callback' => array( $this, 'data_post_types' ),
);
PodsField_Pick::$related_objects['taxonomies'] = array(
'label' => __( 'Taxonomy Objects', 'pods' ),
'group' => __( 'Advanced Objects', 'pods' ),
'simple' => true,
'data_callback' => array( $this, 'data_taxonomies' ),
);
} | [
"public",
"function",
"add_related_objects",
"(",
")",
"{",
"PodsField_Pick",
"::",
"$",
"related_objects",
"[",
"'table'",
"]",
"=",
"array",
"(",
"'label'",
"=>",
"__",
"(",
"'Database Tables'",
",",
"'pods'",
")",
",",
"'group'",
"=>",
"__",
"(",
"'Advanc... | Add Advanced Related Objects
@since 2.3.0 | [
"Add",
"Advanced",
"Related",
"Objects"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/components/Advanced-Relationships.php#L40-L93 | train |
pods-framework/pods | components/Advanced-Relationships.php | Pods_Advanced_Relationships.data_themes | public function data_themes( $name = null, $value = null, $options = null, $pod = null, $id = null ) {
$data = array();
$themes = wp_get_themes( array( 'allowed' => true ) );
foreach ( $themes as $theme ) {
$data[ $theme->Template ] = $theme->Name;
}
return apply_filters( 'pods_form_ui_field_pick_data_themes', $data, $name, $value, $options, $pod, $id );
} | php | public function data_themes( $name = null, $value = null, $options = null, $pod = null, $id = null ) {
$data = array();
$themes = wp_get_themes( array( 'allowed' => true ) );
foreach ( $themes as $theme ) {
$data[ $theme->Template ] = $theme->Name;
}
return apply_filters( 'pods_form_ui_field_pick_data_themes', $data, $name, $value, $options, $pod, $id );
} | [
"public",
"function",
"data_themes",
"(",
"$",
"name",
"=",
"null",
",",
"$",
"value",
"=",
"null",
",",
"$",
"options",
"=",
"null",
",",
"$",
"pod",
"=",
"null",
",",
"$",
"id",
"=",
"null",
")",
"{",
"$",
"data",
"=",
"array",
"(",
")",
";",... | Data callback for Themes
@param string $name The name of the field
@param string|array $value The value of the field
@param array $options Field options
@param array $pod Pod data
@param int $id Item ID
@return array
@since 2.3.0 | [
"Data",
"callback",
"for",
"Themes"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/components/Advanced-Relationships.php#L108-L119 | train |
pods-framework/pods | components/Advanced-Relationships.php | Pods_Advanced_Relationships.data_page_templates | public function data_page_templates( $name = null, $value = null, $options = null, $pod = null, $id = null ) {
$data = array();
if ( ! function_exists( 'get_page_templates' ) ) {
include_once ABSPATH . 'wp-admin/includes/theme.php';
}
$page_templates = apply_filters( 'pods_page_templates', get_page_templates() );
if ( ! in_array( 'page.php', $page_templates, true ) && locate_template( array( 'page.php', false ) ) ) {
$page_templates['Page (WP Default)'] = 'page.php';
}
if ( ! in_array( 'index.php', $page_templates, true ) && locate_template( array( 'index.php', false ) ) ) {
$page_templates['Index (WP Fallback)'] = 'index.php';
}
ksort( $page_templates );
$page_templates = array_flip( $page_templates );
foreach ( $page_templates as $page_template_file => $page_template ) {
$data[ $page_template_file ] = $page_template;
}
return apply_filters( 'pods_form_ui_field_pick_data_page_templates', $data, $name, $value, $options, $pod, $id );
} | php | public function data_page_templates( $name = null, $value = null, $options = null, $pod = null, $id = null ) {
$data = array();
if ( ! function_exists( 'get_page_templates' ) ) {
include_once ABSPATH . 'wp-admin/includes/theme.php';
}
$page_templates = apply_filters( 'pods_page_templates', get_page_templates() );
if ( ! in_array( 'page.php', $page_templates, true ) && locate_template( array( 'page.php', false ) ) ) {
$page_templates['Page (WP Default)'] = 'page.php';
}
if ( ! in_array( 'index.php', $page_templates, true ) && locate_template( array( 'index.php', false ) ) ) {
$page_templates['Index (WP Fallback)'] = 'index.php';
}
ksort( $page_templates );
$page_templates = array_flip( $page_templates );
foreach ( $page_templates as $page_template_file => $page_template ) {
$data[ $page_template_file ] = $page_template;
}
return apply_filters( 'pods_form_ui_field_pick_data_page_templates', $data, $name, $value, $options, $pod, $id );
} | [
"public",
"function",
"data_page_templates",
"(",
"$",
"name",
"=",
"null",
",",
"$",
"value",
"=",
"null",
",",
"$",
"options",
"=",
"null",
",",
"$",
"pod",
"=",
"null",
",",
"$",
"id",
"=",
"null",
")",
"{",
"$",
"data",
"=",
"array",
"(",
")"... | Data callback for Page Templates
@param string $name The name of the field
@param string|array $value The value of the field
@param array $options Field options
@param array $pod Pod data
@param int $id Item ID
@return array
@since 2.3.0 | [
"Data",
"callback",
"for",
"Page",
"Templates"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/components/Advanced-Relationships.php#L134-L161 | train |
pods-framework/pods | components/Advanced-Relationships.php | Pods_Advanced_Relationships.data_sidebars | public function data_sidebars( $name = null, $value = null, $options = null, $pod = null, $id = null ) {
$data = array();
global $wp_registered_sidebars;
if ( ! empty( $wp_registered_sidebars ) ) {
foreach ( $wp_registered_sidebars as $sidebar ) {
$data[ $sidebar['id'] ] = $sidebar['name'];
}
}
return apply_filters( 'pods_form_ui_field_pick_data_sidebars', $data, $name, $value, $options, $pod, $id );
} | php | public function data_sidebars( $name = null, $value = null, $options = null, $pod = null, $id = null ) {
$data = array();
global $wp_registered_sidebars;
if ( ! empty( $wp_registered_sidebars ) ) {
foreach ( $wp_registered_sidebars as $sidebar ) {
$data[ $sidebar['id'] ] = $sidebar['name'];
}
}
return apply_filters( 'pods_form_ui_field_pick_data_sidebars', $data, $name, $value, $options, $pod, $id );
} | [
"public",
"function",
"data_sidebars",
"(",
"$",
"name",
"=",
"null",
",",
"$",
"value",
"=",
"null",
",",
"$",
"options",
"=",
"null",
",",
"$",
"pod",
"=",
"null",
",",
"$",
"id",
"=",
"null",
")",
"{",
"$",
"data",
"=",
"array",
"(",
")",
";... | Data callback for Sidebars
@param string $name The name of the field
@param string|array $value The value of the field
@param array $options Field options
@param array $pod Pod data
@param int $id Item ID
@return array
@since 2.3.0 | [
"Data",
"callback",
"for",
"Sidebars"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/components/Advanced-Relationships.php#L176-L189 | train |
pods-framework/pods | components/Advanced-Relationships.php | Pods_Advanced_Relationships.data_post_types | public function data_post_types( $name = null, $value = null, $options = null, $pod = null, $id = null ) {
$data = array();
$post_types = get_post_types( array(), 'objects' );
$ignore = array( 'revision', 'nav_menu_item' );
foreach ( $post_types as $post_type ) {
if ( in_array( $post_type->name, $ignore, true ) || 0 === strpos( $post_type->name, '_pods_' ) ) {
continue;
}
$data[ $post_type->name ] = $post_type->label;
}
return apply_filters( 'pods_form_ui_field_pick_data_post_types', $data, $name, $value, $options, $pod, $id );
} | php | public function data_post_types( $name = null, $value = null, $options = null, $pod = null, $id = null ) {
$data = array();
$post_types = get_post_types( array(), 'objects' );
$ignore = array( 'revision', 'nav_menu_item' );
foreach ( $post_types as $post_type ) {
if ( in_array( $post_type->name, $ignore, true ) || 0 === strpos( $post_type->name, '_pods_' ) ) {
continue;
}
$data[ $post_type->name ] = $post_type->label;
}
return apply_filters( 'pods_form_ui_field_pick_data_post_types', $data, $name, $value, $options, $pod, $id );
} | [
"public",
"function",
"data_post_types",
"(",
"$",
"name",
"=",
"null",
",",
"$",
"value",
"=",
"null",
",",
"$",
"options",
"=",
"null",
",",
"$",
"pod",
"=",
"null",
",",
"$",
"id",
"=",
"null",
")",
"{",
"$",
"data",
"=",
"array",
"(",
")",
... | Data callback for Post Types
@param string $name The name of the field
@param string|array $value The value of the field
@param array $options Field options
@param array $pod Pod data
@param int $id Item ID
@return array
@since 2.3.0 | [
"Data",
"callback",
"for",
"Post",
"Types"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/components/Advanced-Relationships.php#L204-L221 | train |
pods-framework/pods | components/Advanced-Relationships.php | Pods_Advanced_Relationships.data_taxonomies | public function data_taxonomies( $name = null, $value = null, $options = null, $pod = null, $id = null ) {
$data = array();
$taxonomies = get_taxonomies( array(), 'objects' );
$ignore = array( 'nav_menu', 'post_format' );
foreach ( $taxonomies as $taxonomy ) {
if ( in_array( $taxonomy->name, $ignore, true ) ) {
continue;
}
$data[ $taxonomy->name ] = $taxonomy->label;
}
return apply_filters( 'pods_form_ui_field_pick_data_taxonomies', $data, $name, $value, $options, $pod, $id );
} | php | public function data_taxonomies( $name = null, $value = null, $options = null, $pod = null, $id = null ) {
$data = array();
$taxonomies = get_taxonomies( array(), 'objects' );
$ignore = array( 'nav_menu', 'post_format' );
foreach ( $taxonomies as $taxonomy ) {
if ( in_array( $taxonomy->name, $ignore, true ) ) {
continue;
}
$data[ $taxonomy->name ] = $taxonomy->label;
}
return apply_filters( 'pods_form_ui_field_pick_data_taxonomies', $data, $name, $value, $options, $pod, $id );
} | [
"public",
"function",
"data_taxonomies",
"(",
"$",
"name",
"=",
"null",
",",
"$",
"value",
"=",
"null",
",",
"$",
"options",
"=",
"null",
",",
"$",
"pod",
"=",
"null",
",",
"$",
"id",
"=",
"null",
")",
"{",
"$",
"data",
"=",
"array",
"(",
")",
... | Data callback for Taxonomies
@param string $name The name of the field
@param string|array $value The value of the field
@param array $options Field options
@param array $pod Pod data
@param int $id Item ID
@return array
@since 2.3.0 | [
"Data",
"callback",
"for",
"Taxonomies"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/components/Advanced-Relationships.php#L236-L253 | train |
pods-framework/pods | classes/cli/Pods_CLI_Command.php | Pods_CLI_Command.add | public function add( $args, $assoc_args ) {
$pod_name = $assoc_args['pod'];
unset( $assoc_args['pod'] );
$pod = pods( $pod_name, null, false );
if ( ! $pod->valid() ) {
WP_CLI::error( sprintf( __( 'Pod "%s" does not exist.', 'pods' ), $assoc_args['pod'] ) );
}
if ( ! empty( $assoc_args ) ) {
$id = 0;
try {
$id = $pod->add( $assoc_args );
} catch ( Exception $e ) {
WP_CLI::error( sprintf( __( 'Error saving pod item: %s', 'pods' ), $e->getMessage() ) );
}
if ( 0 < $id ) {
WP_CLI::success( __( 'Pod item added.', 'pods' ) );
WP_CLI::line( sprintf( __( 'New ID: %s', 'pods' ), $id ) );
} else {
WP_CLI::error( __( 'Pod item not added.', 'pods' ) );
}
} else {
WP_CLI::error( __( 'No data sent for saving.', 'pods' ) );
}
} | php | public function add( $args, $assoc_args ) {
$pod_name = $assoc_args['pod'];
unset( $assoc_args['pod'] );
$pod = pods( $pod_name, null, false );
if ( ! $pod->valid() ) {
WP_CLI::error( sprintf( __( 'Pod "%s" does not exist.', 'pods' ), $assoc_args['pod'] ) );
}
if ( ! empty( $assoc_args ) ) {
$id = 0;
try {
$id = $pod->add( $assoc_args );
} catch ( Exception $e ) {
WP_CLI::error( sprintf( __( 'Error saving pod item: %s', 'pods' ), $e->getMessage() ) );
}
if ( 0 < $id ) {
WP_CLI::success( __( 'Pod item added.', 'pods' ) );
WP_CLI::line( sprintf( __( 'New ID: %s', 'pods' ), $id ) );
} else {
WP_CLI::error( __( 'Pod item not added.', 'pods' ) );
}
} else {
WP_CLI::error( __( 'No data sent for saving.', 'pods' ) );
}
} | [
"public",
"function",
"add",
"(",
"$",
"args",
",",
"$",
"assoc_args",
")",
"{",
"$",
"pod_name",
"=",
"$",
"assoc_args",
"[",
"'pod'",
"]",
";",
"unset",
"(",
"$",
"assoc_args",
"[",
"'pod'",
"]",
")",
";",
"$",
"pod",
"=",
"pods",
"(",
"$",
"po... | Add a pod item.
## OPTIONS
--pod=<pod>
: The pod name.
--<field>=<value>
: The field => value pair(s) to save.
## EXAMPLES
wp pods add --pod=my_pod --my_field_name1=Value --my_field_name2="Another Value"
@param $args
@param $assoc_args | [
"Add",
"a",
"pod",
"item",
"."
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/cli/Pods_CLI_Command.php#L26-L57 | train |
pods-framework/pods | classes/cli/Pods_CLI_Command.php | Pods_CLI_Command.save | public function save( $args, $assoc_args ) {
$pod_name = $assoc_args['pod'];
$item = pods_v( 'item', $assoc_args );
unset( $assoc_args['pod'] );
if ( null !== $item ) {
unset( $assoc_args['item'] );
}
$pod = pods( $pod_name, $item, false );
if ( ! $pod->valid() ) {
WP_CLI::error( sprintf( __( 'Pod "%s" does not exist.', 'pods' ), $assoc_args['pod'] ) );
}
if ( null !== $item && ! $pod->exists() ) {
WP_CLI::error( sprintf( __( 'Pod "%1$s" item "%2$s" does not exist.', 'pods' ), $assoc_args['pod'], $assoc_args['item'] ) );
}
if ( ! empty( $assoc_args ) ) {
$id = 0;
try {
$id = $pod->save( $assoc_args );
} catch ( Exception $e ) {
WP_CLI::error( sprintf( __( 'Error saving pod item: %s', 'pods' ), $e->getMessage() ) );
}
if ( 0 < $id ) {
WP_CLI::success( __( 'Pod item saved.', 'pods' ) );
WP_CLI::line( sprintf( __( 'ID: %s', 'pods' ), $id ) );
} else {
WP_CLI::error( __( 'Pod item not saved.', 'pods' ) );
}
} else {
WP_CLI::error( __( 'No data sent for saving.', 'pods' ) );
}
} | php | public function save( $args, $assoc_args ) {
$pod_name = $assoc_args['pod'];
$item = pods_v( 'item', $assoc_args );
unset( $assoc_args['pod'] );
if ( null !== $item ) {
unset( $assoc_args['item'] );
}
$pod = pods( $pod_name, $item, false );
if ( ! $pod->valid() ) {
WP_CLI::error( sprintf( __( 'Pod "%s" does not exist.', 'pods' ), $assoc_args['pod'] ) );
}
if ( null !== $item && ! $pod->exists() ) {
WP_CLI::error( sprintf( __( 'Pod "%1$s" item "%2$s" does not exist.', 'pods' ), $assoc_args['pod'], $assoc_args['item'] ) );
}
if ( ! empty( $assoc_args ) ) {
$id = 0;
try {
$id = $pod->save( $assoc_args );
} catch ( Exception $e ) {
WP_CLI::error( sprintf( __( 'Error saving pod item: %s', 'pods' ), $e->getMessage() ) );
}
if ( 0 < $id ) {
WP_CLI::success( __( 'Pod item saved.', 'pods' ) );
WP_CLI::line( sprintf( __( 'ID: %s', 'pods' ), $id ) );
} else {
WP_CLI::error( __( 'Pod item not saved.', 'pods' ) );
}
} else {
WP_CLI::error( __( 'No data sent for saving.', 'pods' ) );
}
} | [
"public",
"function",
"save",
"(",
"$",
"args",
",",
"$",
"assoc_args",
")",
"{",
"$",
"pod_name",
"=",
"$",
"assoc_args",
"[",
"'pod'",
"]",
";",
"$",
"item",
"=",
"pods_v",
"(",
"'item'",
",",
"$",
"assoc_args",
")",
";",
"unset",
"(",
"$",
"asso... | Save a pod item.
## OPTIONS
--pod=<pod>
: The pod name.
[--item=<item>]
: The item to save for, it is not used for a settings pod.
--<field>=<value>
: The field => value pair(s) to save.
## EXAMPLES
wp pods save --pod=my_pod --item=123 --my_field_name1=Value2 --my_field_name2="Another Value2"
wp pods save --pod=my_settings_pod --my_option_field_name1=Value --my_option_field_name2="Another Value2"
@param $args
@param $assoc_args | [
"Save",
"a",
"pod",
"item",
"."
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/cli/Pods_CLI_Command.php#L81-L121 | train |
pods-framework/pods | classes/cli/Pods_CLI_Command.php | Pods_CLI_Command.duplicate | public function duplicate( $args, $assoc_args ) {
$pod = pods( $assoc_args['pod'], $assoc_args['item'], false );
if ( ! $pod->valid() ) {
WP_CLI::error( sprintf( __( 'Pod "%s" does not exist.', 'pods' ), $assoc_args['pod'] ) );
}
if ( ! $pod->exists() ) {
WP_CLI::error( sprintf( __( 'Pod "%1$s" item "%2$s" does not exist.', 'pods' ), $assoc_args['pod'], $assoc_args['item'] ) );
}
$id = 0;
try {
$id = $pod->duplicate( $assoc_args );
} catch ( Exception $e ) {
WP_CLI::error( sprintf( __( 'Error saving pod item: %s', 'pods' ), $e->getMessage() ) );
}
if ( 0 < $id ) {
WP_CLI::success( __( 'Pod item duplicated.', 'pods' ) );
WP_CLI::line( sprintf( __( 'New ID: %s', 'pods' ), $id ) );
} else {
WP_CLI::error( __( 'Pod item not duplicated.', 'pods' ) );
}
} | php | public function duplicate( $args, $assoc_args ) {
$pod = pods( $assoc_args['pod'], $assoc_args['item'], false );
if ( ! $pod->valid() ) {
WP_CLI::error( sprintf( __( 'Pod "%s" does not exist.', 'pods' ), $assoc_args['pod'] ) );
}
if ( ! $pod->exists() ) {
WP_CLI::error( sprintf( __( 'Pod "%1$s" item "%2$s" does not exist.', 'pods' ), $assoc_args['pod'], $assoc_args['item'] ) );
}
$id = 0;
try {
$id = $pod->duplicate( $assoc_args );
} catch ( Exception $e ) {
WP_CLI::error( sprintf( __( 'Error saving pod item: %s', 'pods' ), $e->getMessage() ) );
}
if ( 0 < $id ) {
WP_CLI::success( __( 'Pod item duplicated.', 'pods' ) );
WP_CLI::line( sprintf( __( 'New ID: %s', 'pods' ), $id ) );
} else {
WP_CLI::error( __( 'Pod item not duplicated.', 'pods' ) );
}
} | [
"public",
"function",
"duplicate",
"(",
"$",
"args",
",",
"$",
"assoc_args",
")",
"{",
"$",
"pod",
"=",
"pods",
"(",
"$",
"assoc_args",
"[",
"'pod'",
"]",
",",
"$",
"assoc_args",
"[",
"'item'",
"]",
",",
"false",
")",
";",
"if",
"(",
"!",
"$",
"p... | Duplicate a pod item.
## OPTIONS
--pod=<pod>
: The pod name.
--item=<item>
: The pod item to delete.
## EXAMPLES
wp pods duplicate --pod=my_pod --item=123
@param $args
@param $assoc_args | [
"Duplicate",
"a",
"pod",
"item",
"."
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/cli/Pods_CLI_Command.php#L141-L168 | train |
pods-framework/pods | classes/cli/Pods_CLI_Command.php | Pods_CLI_Command.delete | public function delete( $args, $assoc_args ) {
$pod = pods( $assoc_args['pod'], $assoc_args['item'], false );
if ( ! $pod->valid() ) {
WP_CLI::error( sprintf( __( 'Pod "%s" does not exist.', 'pods' ), $assoc_args['pod'] ) );
}
if ( ! $pod->exists() ) {
WP_CLI::error( sprintf( __( 'Pod "%1$s" item "%2$s" does not exist.', 'pods' ), $assoc_args['pod'], $assoc_args['item'] ) );
}
$deleted = false;
try {
$deleted = $pod->delete();
} catch ( Exception $e ) {
WP_CLI::error( sprintf( __( 'Error saving pod item: %s', 'pods' ), $e->getMessage() ) );
}
if ( $deleted ) {
WP_CLI::success( __( 'Pod item deleted.', 'pods' ) );
} else {
WP_CLI::error( __( 'Pod item not deleted.', 'pods' ) );
}
} | php | public function delete( $args, $assoc_args ) {
$pod = pods( $assoc_args['pod'], $assoc_args['item'], false );
if ( ! $pod->valid() ) {
WP_CLI::error( sprintf( __( 'Pod "%s" does not exist.', 'pods' ), $assoc_args['pod'] ) );
}
if ( ! $pod->exists() ) {
WP_CLI::error( sprintf( __( 'Pod "%1$s" item "%2$s" does not exist.', 'pods' ), $assoc_args['pod'], $assoc_args['item'] ) );
}
$deleted = false;
try {
$deleted = $pod->delete();
} catch ( Exception $e ) {
WP_CLI::error( sprintf( __( 'Error saving pod item: %s', 'pods' ), $e->getMessage() ) );
}
if ( $deleted ) {
WP_CLI::success( __( 'Pod item deleted.', 'pods' ) );
} else {
WP_CLI::error( __( 'Pod item not deleted.', 'pods' ) );
}
} | [
"public",
"function",
"delete",
"(",
"$",
"args",
",",
"$",
"assoc_args",
")",
"{",
"$",
"pod",
"=",
"pods",
"(",
"$",
"assoc_args",
"[",
"'pod'",
"]",
",",
"$",
"assoc_args",
"[",
"'item'",
"]",
",",
"false",
")",
";",
"if",
"(",
"!",
"$",
"pod"... | Delete a pod item.
## OPTIONS
--pod=<pod>
: The pod name.
--item=<item>
: The pod item to delete.
## EXAMPLES
wp pods delete --pod=my_pod --item=123
@param $args
@param $assoc_args | [
"Delete",
"a",
"pod",
"item",
"."
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/cli/Pods_CLI_Command.php#L188-L214 | train |
pods-framework/pods | classes/cli/Pods_CLI_Command.php | Pods_CLI_Command.export_item | public function export_item( $args, $assoc_args ) {
$pod_name = $assoc_args['pod'];
$item = pods_v( 'item', $assoc_args );
unset( $assoc_args['pod'] );
if ( null !== $item ) {
unset( $assoc_args['item'] );
}
$pod = pods( $pod_name, $item, false );
if ( ! $pod->valid() ) {
WP_CLI::error( sprintf( __( 'Pod "%s" does not exist.', 'pods' ), $assoc_args['pod'] ) );
}
if ( null !== $item && ! $pod->exists() ) {
WP_CLI::error( sprintf( __( 'Pod "%1$s" item "%2$s" does not exist.', 'pods' ), $assoc_args['pod'], $assoc_args['item'] ) );
}
$params = array(
'fields' => pods_v( 'fields', $assoc_args, null, true ),
'depth' => (int) pods_v( 'depth', $assoc_args, 1, true ),
);
$data = false;
try {
$data = $pod->export( $params );
} catch ( Exception $e ) {
WP_CLI::error( sprintf( __( 'Error exporting pod item: %s', 'pods' ), $e->getMessage() ) );
}
if ( ! empty( $data ) ) {
// Load PodsMigrate class file for use.
pods_migrate();
$file = $assoc_args['file'];
$export_file = PodsMigrate::export_data_to_file( $file, $data, true );
if ( $export_file ) {
WP_CLI::success( sprintf( __( 'Pod item exported: %s', 'pods' ), $export_file ) );
} else {
WP_CLI::error( __( 'Pod item not exported.', 'pods' ) );
}
} else {
WP_CLI::error( __( 'No export data found.', 'pods' ) );
}
} | php | public function export_item( $args, $assoc_args ) {
$pod_name = $assoc_args['pod'];
$item = pods_v( 'item', $assoc_args );
unset( $assoc_args['pod'] );
if ( null !== $item ) {
unset( $assoc_args['item'] );
}
$pod = pods( $pod_name, $item, false );
if ( ! $pod->valid() ) {
WP_CLI::error( sprintf( __( 'Pod "%s" does not exist.', 'pods' ), $assoc_args['pod'] ) );
}
if ( null !== $item && ! $pod->exists() ) {
WP_CLI::error( sprintf( __( 'Pod "%1$s" item "%2$s" does not exist.', 'pods' ), $assoc_args['pod'], $assoc_args['item'] ) );
}
$params = array(
'fields' => pods_v( 'fields', $assoc_args, null, true ),
'depth' => (int) pods_v( 'depth', $assoc_args, 1, true ),
);
$data = false;
try {
$data = $pod->export( $params );
} catch ( Exception $e ) {
WP_CLI::error( sprintf( __( 'Error exporting pod item: %s', 'pods' ), $e->getMessage() ) );
}
if ( ! empty( $data ) ) {
// Load PodsMigrate class file for use.
pods_migrate();
$file = $assoc_args['file'];
$export_file = PodsMigrate::export_data_to_file( $file, $data, true );
if ( $export_file ) {
WP_CLI::success( sprintf( __( 'Pod item exported: %s', 'pods' ), $export_file ) );
} else {
WP_CLI::error( __( 'Pod item not exported.', 'pods' ) );
}
} else {
WP_CLI::error( __( 'No export data found.', 'pods' ) );
}
} | [
"public",
"function",
"export_item",
"(",
"$",
"args",
",",
"$",
"assoc_args",
")",
"{",
"$",
"pod_name",
"=",
"$",
"assoc_args",
"[",
"'pod'",
"]",
";",
"$",
"item",
"=",
"pods_v",
"(",
"'item'",
",",
"$",
"assoc_args",
")",
";",
"unset",
"(",
"$",
... | Export a single pod item to a file.
## OPTIONS
--pod=<pod>
: The pod name.
--file=<file>
: The file to save to including path (defaults to current path).
[--item=<item>]
: The item to save for, it is not used for a settings pod.
[--fields=<fields>]
: The comma-separated list of fields to export (defaults to all fields).
[--depth=<depth>]
: The depth of related objects to recursively export (default is 1 level deep, only returns IDs for related objects).
## EXAMPLES
wp pods export-item --pod=my_pod --item=123 --file="item-data.json"
wp pods export-item --pod=my_pod --item=123 --file="/path/to/item-data.json"
wp pods export-item --pod=my_pod --item=123 --file="item-data.json" --fields="ID,post_title,post_content,my_field_name1,my_field_name2"
wp pods export-item --pod=my_pod --item=123 --file="item-data.json" --depth=2
@subcommand export-item | [
"Export",
"a",
"single",
"pod",
"item",
"to",
"a",
"file",
"."
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/cli/Pods_CLI_Command.php#L245-L296 | train |
pods-framework/pods | classes/cli/Pods_CLI_Command.php | Pods_CLI_Command.export | public function export( $args, $assoc_args ) {
$pod_name = $assoc_args['pod'];
unset( $assoc_args['pod'] );
$pod = pods( $pod_name, null, false );
if ( ! $pod->valid() ) {
WP_CLI::error( sprintf( __( 'Pod "%s" does not exist.', 'pods' ), $assoc_args['pod'] ) );
}
$params = array(
'fields' => pods_v( 'fields', $assoc_args, null, true ),
'depth' => (int) pods_v( 'depth', $assoc_args, 1, true ),
);
// Handle custom find() params.
$find_params = pods_v( 'params', $assoc_args, null, true );
if ( is_string( $find_params ) ) {
$params['params'] = array();
if ( false !== strpos( $params['params'], '{' ) ) {
// Pull the find params from JSON format.
$params['params'] = json_decode( $params['params'], true );
} else {
// Pull the find params from string argument format.
wp_parse_str( $find_params, $params['params'] );
}
}
$data = false;
try {
$data = $pod->export_data( $params );
} catch ( Exception $e ) {
WP_CLI::error( sprintf( __( 'Error exporting pod items: %s', 'pods' ), $e->getMessage() ) );
}
if ( ! empty( $data ) ) {
// Load PodsMigrate class file for use.
pods_migrate();
$file = $assoc_args['file'];
$export_file = PodsMigrate::export_data_to_file( $file, $data );
if ( $export_file ) {
WP_CLI::success( sprintf( __( 'Pod items exported: %s', 'pods' ), $export_file ) );
} else {
WP_CLI::error( __( 'Pod items not exported.', 'pods' ) );
}
} else {
WP_CLI::error( __( 'No pod item export data found.', 'pods' ) );
}
} | php | public function export( $args, $assoc_args ) {
$pod_name = $assoc_args['pod'];
unset( $assoc_args['pod'] );
$pod = pods( $pod_name, null, false );
if ( ! $pod->valid() ) {
WP_CLI::error( sprintf( __( 'Pod "%s" does not exist.', 'pods' ), $assoc_args['pod'] ) );
}
$params = array(
'fields' => pods_v( 'fields', $assoc_args, null, true ),
'depth' => (int) pods_v( 'depth', $assoc_args, 1, true ),
);
// Handle custom find() params.
$find_params = pods_v( 'params', $assoc_args, null, true );
if ( is_string( $find_params ) ) {
$params['params'] = array();
if ( false !== strpos( $params['params'], '{' ) ) {
// Pull the find params from JSON format.
$params['params'] = json_decode( $params['params'], true );
} else {
// Pull the find params from string argument format.
wp_parse_str( $find_params, $params['params'] );
}
}
$data = false;
try {
$data = $pod->export_data( $params );
} catch ( Exception $e ) {
WP_CLI::error( sprintf( __( 'Error exporting pod items: %s', 'pods' ), $e->getMessage() ) );
}
if ( ! empty( $data ) ) {
// Load PodsMigrate class file for use.
pods_migrate();
$file = $assoc_args['file'];
$export_file = PodsMigrate::export_data_to_file( $file, $data );
if ( $export_file ) {
WP_CLI::success( sprintf( __( 'Pod items exported: %s', 'pods' ), $export_file ) );
} else {
WP_CLI::error( __( 'Pod items not exported.', 'pods' ) );
}
} else {
WP_CLI::error( __( 'No pod item export data found.', 'pods' ) );
}
} | [
"public",
"function",
"export",
"(",
"$",
"args",
",",
"$",
"assoc_args",
")",
"{",
"$",
"pod_name",
"=",
"$",
"assoc_args",
"[",
"'pod'",
"]",
";",
"unset",
"(",
"$",
"assoc_args",
"[",
"'pod'",
"]",
")",
";",
"$",
"pod",
"=",
"pods",
"(",
"$",
... | Export all pod items to a file.
## OPTIONS
--pod=<pod>
: The pod name.
--file=<file>
: The file to save to including path (defaults to current path).
[--fields=<fields>]
: The comma-separated list of fields to export (defaults to all fields).
[--depth=<depth>]
: The depth of related objects to recursively export (default is 1 level deep, only returns IDs for related objects).
[--params=<params>]
: The params to pass into the Pods::find() call, provided in arg1=A&arg2=B or JSON format (default is limit=-1).
## EXAMPLES
wp pods export --pod=my_pod --file="items.json"
wp pods export --pod=my_pod --file="/path/to/items.json"
wp pods export --pod=my_pod --file="items.json" --fields="ID,post_title,post_content,my_field_name1,my_field_name2"
wp pods export --pod=my_pod --file="items.json" --depth=2
wp pods export --pod=my_pod --file="items.json" --params="{\"limit\":10,\"orderby\":\"t.ID DESC\"}"
wp pods export --pod=my_pod --file="items.json" --params="limit=10&orderby=t.ID DESC" | [
"Export",
"all",
"pod",
"items",
"to",
"a",
"file",
"."
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/cli/Pods_CLI_Command.php#L327-L384 | train |
pods-framework/pods | classes/PodsInit.php | PodsInit.core | public function core() {
if ( empty( self::$version ) ) {
return;
}
// Session start
pods_session_start();
add_shortcode( 'pods', 'pods_shortcode' );
add_shortcode( 'pods-form', 'pods_shortcode_form' );
$security_settings = array(
'pods_disable_file_browser' => 0,
'pods_files_require_login' => 1,
'pods_files_require_login_cap' => '',
'pods_disable_file_upload' => 0,
'pods_upload_require_login' => 1,
'pods_upload_require_login_cap' => '',
);
foreach ( $security_settings as $security_setting => $setting ) {
$setting = get_option( $security_setting );
if ( ! empty( $setting ) ) {
$security_settings[ $security_setting ] = $setting;
}
}
foreach ( $security_settings as $security_setting => $setting ) {
if ( 0 === (int) $setting ) {
$setting = false;
} elseif ( 1 === (int) $setting ) {
$setting = true;
}
if ( in_array(
$security_setting, array(
'pods_files_require_login',
'pods_upload_require_login',
), true
) ) {
if ( 0 < strlen( $security_settings[ $security_setting . '_cap' ] ) ) {
$setting = $security_settings[ $security_setting . '_cap' ];
}
} elseif ( in_array(
$security_setting, array(
'pods_files_require_login_cap',
'pods_upload_require_login_cap',
), true
) ) {
continue;
}
if ( ! defined( strtoupper( $security_setting ) ) ) {
define( strtoupper( $security_setting ), $setting );
}
}//end foreach
$this->register_pods();
$avatar = PodsForm::field_loader( 'avatar' );
if ( method_exists( $avatar, 'get_avatar' ) ) {
add_filter( 'get_avatar', array( $avatar, 'get_avatar' ), 10, 4 );
}
} | php | public function core() {
if ( empty( self::$version ) ) {
return;
}
// Session start
pods_session_start();
add_shortcode( 'pods', 'pods_shortcode' );
add_shortcode( 'pods-form', 'pods_shortcode_form' );
$security_settings = array(
'pods_disable_file_browser' => 0,
'pods_files_require_login' => 1,
'pods_files_require_login_cap' => '',
'pods_disable_file_upload' => 0,
'pods_upload_require_login' => 1,
'pods_upload_require_login_cap' => '',
);
foreach ( $security_settings as $security_setting => $setting ) {
$setting = get_option( $security_setting );
if ( ! empty( $setting ) ) {
$security_settings[ $security_setting ] = $setting;
}
}
foreach ( $security_settings as $security_setting => $setting ) {
if ( 0 === (int) $setting ) {
$setting = false;
} elseif ( 1 === (int) $setting ) {
$setting = true;
}
if ( in_array(
$security_setting, array(
'pods_files_require_login',
'pods_upload_require_login',
), true
) ) {
if ( 0 < strlen( $security_settings[ $security_setting . '_cap' ] ) ) {
$setting = $security_settings[ $security_setting . '_cap' ];
}
} elseif ( in_array(
$security_setting, array(
'pods_files_require_login_cap',
'pods_upload_require_login_cap',
), true
) ) {
continue;
}
if ( ! defined( strtoupper( $security_setting ) ) ) {
define( strtoupper( $security_setting ), $setting );
}
}//end foreach
$this->register_pods();
$avatar = PodsForm::field_loader( 'avatar' );
if ( method_exists( $avatar, 'get_avatar' ) ) {
add_filter( 'get_avatar', array( $avatar, 'get_avatar' ), 10, 4 );
}
} | [
"public",
"function",
"core",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"self",
"::",
"$",
"version",
")",
")",
"{",
"return",
";",
"}",
"// Session start",
"pods_session_start",
"(",
")",
";",
"add_shortcode",
"(",
"'pods'",
",",
"'pods_shortcode'",
")",
... | Set up the Pods core | [
"Set",
"up",
"the",
"Pods",
"core"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsInit.php#L189-L254 | train |
pods-framework/pods | classes/PodsInit.php | PodsInit.maybe_register_handlebars | private function maybe_register_handlebars() {
$register_handlebars = apply_filters( 'pods_script_register_handlebars', true );
if ( is_admin() && function_exists( 'get_current_screen' ) ) {
$screen = get_current_screen();
// Deregister the outdated Pods handlebars script on TEC event screen
if ( $screen && 'tribe_events' === $screen->post_type ) {
$register_handlebars = false;
}
}
if ( $register_handlebars ) {
wp_register_script( 'pods-handlebars', PODS_URL . 'ui/js/handlebars.js', array(), '1.0.0.beta.6' );
}
} | php | private function maybe_register_handlebars() {
$register_handlebars = apply_filters( 'pods_script_register_handlebars', true );
if ( is_admin() && function_exists( 'get_current_screen' ) ) {
$screen = get_current_screen();
// Deregister the outdated Pods handlebars script on TEC event screen
if ( $screen && 'tribe_events' === $screen->post_type ) {
$register_handlebars = false;
}
}
if ( $register_handlebars ) {
wp_register_script( 'pods-handlebars', PODS_URL . 'ui/js/handlebars.js', array(), '1.0.0.beta.6' );
}
} | [
"private",
"function",
"maybe_register_handlebars",
"(",
")",
"{",
"$",
"register_handlebars",
"=",
"apply_filters",
"(",
"'pods_script_register_handlebars'",
",",
"true",
")",
";",
"if",
"(",
"is_admin",
"(",
")",
"&&",
"function_exists",
"(",
"'get_current_screen'",... | Register handlebars where needed
@since 2.7.2 | [
"Register",
"handlebars",
"where",
"needed"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsInit.php#L384-L400 | train |
pods-framework/pods | classes/PodsInit.php | PodsInit.register_pods | public function register_pods() {
$args = array(
'label' => 'Pods',
'labels' => array( 'singular_name' => 'Pod' ),
'public' => false,
'can_export' => false,
'query_var' => false,
'rewrite' => false,
'capability_type' => 'pods_pod',
'has_archive' => false,
'hierarchical' => false,
'supports' => array( 'title', 'author' ),
'menu_icon' => 'dashicons-pods',
);
$args = self::object_label_fix( $args, 'post_type' );
register_post_type( '_pods_pod', apply_filters( 'pods_internal_register_post_type_pod', $args ) );
$args = array(
'label' => 'Pod Fields',
'labels' => array( 'singular_name' => 'Pod Field' ),
'public' => false,
'can_export' => false,
'query_var' => false,
'rewrite' => false,
'capability_type' => 'pods_pod',
'has_archive' => false,
'hierarchical' => true,
'supports' => array( 'title', 'editor', 'author' ),
'menu_icon' => 'dashicons-pods',
);
$args = self::object_label_fix( $args, 'post_type' );
register_post_type( '_pods_field', apply_filters( 'pods_internal_register_post_type_field', $args ) );
} | php | public function register_pods() {
$args = array(
'label' => 'Pods',
'labels' => array( 'singular_name' => 'Pod' ),
'public' => false,
'can_export' => false,
'query_var' => false,
'rewrite' => false,
'capability_type' => 'pods_pod',
'has_archive' => false,
'hierarchical' => false,
'supports' => array( 'title', 'author' ),
'menu_icon' => 'dashicons-pods',
);
$args = self::object_label_fix( $args, 'post_type' );
register_post_type( '_pods_pod', apply_filters( 'pods_internal_register_post_type_pod', $args ) );
$args = array(
'label' => 'Pod Fields',
'labels' => array( 'singular_name' => 'Pod Field' ),
'public' => false,
'can_export' => false,
'query_var' => false,
'rewrite' => false,
'capability_type' => 'pods_pod',
'has_archive' => false,
'hierarchical' => true,
'supports' => array( 'title', 'editor', 'author' ),
'menu_icon' => 'dashicons-pods',
);
$args = self::object_label_fix( $args, 'post_type' );
register_post_type( '_pods_field', apply_filters( 'pods_internal_register_post_type_field', $args ) );
} | [
"public",
"function",
"register_pods",
"(",
")",
"{",
"$",
"args",
"=",
"array",
"(",
"'label'",
"=>",
"'Pods'",
",",
"'labels'",
"=>",
"array",
"(",
"'singular_name'",
"=>",
"'Pod'",
")",
",",
"'public'",
"=>",
"false",
",",
"'can_export'",
"=>",
"false",... | Register internal Post Types | [
"Register",
"internal",
"Post",
"Types"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsInit.php#L417-L454 | train |
pods-framework/pods | classes/PodsInit.php | PodsInit.flush_rewrite_rules | public function flush_rewrite_rules() {
// Only run $wp_rewrite->flush_rules() in an admin context.
if ( ! is_admin() ) {
return;
}
$flush = (int) pods_transient_get( 'pods_flush_rewrites' );
if ( 1 === $flush ) {
/**
* @var $wp_rewrite WP_Rewrite
*/
global $wp_rewrite;
$wp_rewrite->flush_rules();
$wp_rewrite->init();
pods_transient_set( 'pods_flush_rewrites', 0 );
}
} | php | public function flush_rewrite_rules() {
// Only run $wp_rewrite->flush_rules() in an admin context.
if ( ! is_admin() ) {
return;
}
$flush = (int) pods_transient_get( 'pods_flush_rewrites' );
if ( 1 === $flush ) {
/**
* @var $wp_rewrite WP_Rewrite
*/
global $wp_rewrite;
$wp_rewrite->flush_rules();
$wp_rewrite->init();
pods_transient_set( 'pods_flush_rewrites', 0 );
}
} | [
"public",
"function",
"flush_rewrite_rules",
"(",
")",
"{",
"// Only run $wp_rewrite->flush_rules() in an admin context.",
"if",
"(",
"!",
"is_admin",
"(",
")",
")",
"{",
"return",
";",
"}",
"$",
"flush",
"=",
"(",
"int",
")",
"pods_transient_get",
"(",
"'pods_flu... | Check if we need to flush WordPress rewrite rules
This gets run during 'init' action late in the game to give other plugins time to register their rewrite rules | [
"Check",
"if",
"we",
"need",
"to",
"flush",
"WordPress",
"rewrite",
"rules",
"This",
"gets",
"run",
"during",
"init",
"action",
"late",
"in",
"the",
"game",
"to",
"give",
"other",
"plugins",
"time",
"to",
"register",
"their",
"rewrite",
"rules"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsInit.php#L1151-L1170 | train |
pods-framework/pods | classes/PodsInit.php | PodsInit.activate_install | public function activate_install() {
register_activation_hook( PODS_DIR . 'init.php', array( $this, 'activate' ) );
register_deactivation_hook( PODS_DIR . 'init.php', array( $this, 'deactivate' ) );
add_action( 'wpmu_new_blog', array( $this, 'new_blog' ), 10, 6 );
if ( empty( self::$version ) || version_compare( self::$version, PODS_VERSION, '<' ) || version_compare( self::$version, PODS_DB_VERSION, '<=' ) || self::$upgrade_needed ) {
$this->setup();
} elseif ( self::$version !== PODS_VERSION ) {
delete_option( 'pods_framework_version' );
add_option( 'pods_framework_version', PODS_VERSION, '', 'yes' );
self::$version = PODS_VERSION;
pods_api()->cache_flush_pods();
}
} | php | public function activate_install() {
register_activation_hook( PODS_DIR . 'init.php', array( $this, 'activate' ) );
register_deactivation_hook( PODS_DIR . 'init.php', array( $this, 'deactivate' ) );
add_action( 'wpmu_new_blog', array( $this, 'new_blog' ), 10, 6 );
if ( empty( self::$version ) || version_compare( self::$version, PODS_VERSION, '<' ) || version_compare( self::$version, PODS_DB_VERSION, '<=' ) || self::$upgrade_needed ) {
$this->setup();
} elseif ( self::$version !== PODS_VERSION ) {
delete_option( 'pods_framework_version' );
add_option( 'pods_framework_version', PODS_VERSION, '', 'yes' );
self::$version = PODS_VERSION;
pods_api()->cache_flush_pods();
}
} | [
"public",
"function",
"activate_install",
"(",
")",
"{",
"register_activation_hook",
"(",
"PODS_DIR",
".",
"'init.php'",
",",
"array",
"(",
"$",
"this",
",",
"'activate'",
")",
")",
";",
"register_deactivation_hook",
"(",
"PODS_DIR",
".",
"'init.php'",
",",
"arr... | Activate and Install | [
"Activate",
"and",
"Install"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsInit.php#L1331-L1349 | train |
pods-framework/pods | classes/PodsInit.php | PodsInit.delete_attachment | public function delete_attachment( $_ID ) {
global $wpdb;
$_ID = (int) $_ID;
do_action( 'pods_delete_attachment', $_ID );
$file_types = "'" . implode( "', '", PodsForm::file_field_types() ) . "'";
if ( ! pods_tableless() ) {
$sql = "
DELETE `rel`
FROM `@wp_podsrel` AS `rel`
LEFT JOIN `{$wpdb->posts}` AS `p`
ON
`p`.`post_type` = '_pods_field'
AND ( `p`.`ID` = `rel`.`field_id` OR `p`.`ID` = `rel`.`related_field_id` )
LEFT JOIN `{$wpdb->postmeta}` AS `pm`
ON
`pm`.`post_id` = `p`.`ID`
AND `pm`.`meta_key` = 'type'
AND `pm`.`meta_value` IN ( {$file_types} )
WHERE
`p`.`ID` IS NOT NULL
AND `pm`.`meta_id` IS NOT NULL
AND `rel`.`item_id` = {$_ID}";
pods_query( $sql, false );
}
// Post Meta
if ( ! empty( PodsMeta::$post_types ) ) {
$sql = "
DELETE `rel`
FROM `@wp_postmeta` AS `rel`
LEFT JOIN `{$wpdb->posts}` AS `p`
ON
`p`.`post_type` = '_pods_field'
LEFT JOIN `{$wpdb->postmeta}` AS `pm`
ON
`pm`.`post_id` = `p`.`ID`
AND `pm`.`meta_key` = 'type'
AND `pm`.`meta_value` IN ( {$file_types} )
WHERE
`p`.`ID` IS NOT NULL
AND `pm`.`meta_id` IS NOT NULL
AND `rel`.`meta_key` = `p`.`post_name`
AND `rel`.`meta_value` = '{$_ID}'";
pods_query( $sql, false );
}
// User Meta
if ( ! empty( PodsMeta::$user ) ) {
$sql = "
DELETE `rel`
FROM `@wp_usermeta` AS `rel`
LEFT JOIN `{$wpdb->posts}` AS `p`
ON
`p`.`post_type` = '_pods_field'
LEFT JOIN `{$wpdb->postmeta}` AS `pm`
ON
`pm`.`post_id` = `p`.`ID`
AND `pm`.`meta_key` = 'type'
AND `pm`.`meta_value` IN ( {$file_types} )
WHERE
`p`.`ID` IS NOT NULL
AND `pm`.`meta_id` IS NOT NULL
AND `rel`.`meta_key` = `p`.`post_name`
AND `rel`.`meta_value` = '{$_ID}'";
pods_query( $sql, false );
}
// Comment Meta
if ( ! empty( PodsMeta::$comment ) ) {
$sql = "
DELETE `rel`
FROM `@wp_commentmeta` AS `rel`
LEFT JOIN `{$wpdb->posts}` AS `p`
ON
`p`.`post_type` = '_pods_field'
LEFT JOIN `{$wpdb->postmeta}` AS `pm`
ON
`pm`.`post_id` = `p`.`ID`
AND `pm`.`meta_key` = 'type'
AND `pm`.`meta_value` IN ( {$file_types} )
WHERE
`p`.`ID` IS NOT NULL
AND `pm`.`meta_id` IS NOT NULL
AND `rel`.`meta_key` = `p`.`post_name`
AND `rel`.`meta_value` = '{$_ID}'";
pods_query( $sql, false );
}
} | php | public function delete_attachment( $_ID ) {
global $wpdb;
$_ID = (int) $_ID;
do_action( 'pods_delete_attachment', $_ID );
$file_types = "'" . implode( "', '", PodsForm::file_field_types() ) . "'";
if ( ! pods_tableless() ) {
$sql = "
DELETE `rel`
FROM `@wp_podsrel` AS `rel`
LEFT JOIN `{$wpdb->posts}` AS `p`
ON
`p`.`post_type` = '_pods_field'
AND ( `p`.`ID` = `rel`.`field_id` OR `p`.`ID` = `rel`.`related_field_id` )
LEFT JOIN `{$wpdb->postmeta}` AS `pm`
ON
`pm`.`post_id` = `p`.`ID`
AND `pm`.`meta_key` = 'type'
AND `pm`.`meta_value` IN ( {$file_types} )
WHERE
`p`.`ID` IS NOT NULL
AND `pm`.`meta_id` IS NOT NULL
AND `rel`.`item_id` = {$_ID}";
pods_query( $sql, false );
}
// Post Meta
if ( ! empty( PodsMeta::$post_types ) ) {
$sql = "
DELETE `rel`
FROM `@wp_postmeta` AS `rel`
LEFT JOIN `{$wpdb->posts}` AS `p`
ON
`p`.`post_type` = '_pods_field'
LEFT JOIN `{$wpdb->postmeta}` AS `pm`
ON
`pm`.`post_id` = `p`.`ID`
AND `pm`.`meta_key` = 'type'
AND `pm`.`meta_value` IN ( {$file_types} )
WHERE
`p`.`ID` IS NOT NULL
AND `pm`.`meta_id` IS NOT NULL
AND `rel`.`meta_key` = `p`.`post_name`
AND `rel`.`meta_value` = '{$_ID}'";
pods_query( $sql, false );
}
// User Meta
if ( ! empty( PodsMeta::$user ) ) {
$sql = "
DELETE `rel`
FROM `@wp_usermeta` AS `rel`
LEFT JOIN `{$wpdb->posts}` AS `p`
ON
`p`.`post_type` = '_pods_field'
LEFT JOIN `{$wpdb->postmeta}` AS `pm`
ON
`pm`.`post_id` = `p`.`ID`
AND `pm`.`meta_key` = 'type'
AND `pm`.`meta_value` IN ( {$file_types} )
WHERE
`p`.`ID` IS NOT NULL
AND `pm`.`meta_id` IS NOT NULL
AND `rel`.`meta_key` = `p`.`post_name`
AND `rel`.`meta_value` = '{$_ID}'";
pods_query( $sql, false );
}
// Comment Meta
if ( ! empty( PodsMeta::$comment ) ) {
$sql = "
DELETE `rel`
FROM `@wp_commentmeta` AS `rel`
LEFT JOIN `{$wpdb->posts}` AS `p`
ON
`p`.`post_type` = '_pods_field'
LEFT JOIN `{$wpdb->postmeta}` AS `pm`
ON
`pm`.`post_id` = `p`.`ID`
AND `pm`.`meta_key` = 'type'
AND `pm`.`meta_value` IN ( {$file_types} )
WHERE
`p`.`ID` IS NOT NULL
AND `pm`.`meta_id` IS NOT NULL
AND `rel`.`meta_key` = `p`.`post_name`
AND `rel`.`meta_value` = '{$_ID}'";
pods_query( $sql, false );
}
} | [
"public",
"function",
"delete_attachment",
"(",
"$",
"_ID",
")",
"{",
"global",
"$",
"wpdb",
";",
"$",
"_ID",
"=",
"(",
"int",
")",
"$",
"_ID",
";",
"do_action",
"(",
"'pods_delete_attachment'",
",",
"$",
"_ID",
")",
";",
"$",
"file_types",
"=",
"\"'\"... | Delete Attachments from relationships
@param int $_ID | [
"Delete",
"Attachments",
"from",
"relationships"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsInit.php#L1667-L1763 | train |
pods-framework/pods | classes/PodsInit.php | PodsInit.register_widgets | public function register_widgets() {
$widgets = array(
'PodsWidgetSingle',
'PodsWidgetList',
'PodsWidgetField',
'PodsWidgetForm',
'PodsWidgetView',
);
foreach ( $widgets as $widget ) {
if ( ! file_exists( PODS_DIR . 'classes/widgets/' . $widget . '.php' ) ) {
continue;
}
require_once PODS_DIR . 'classes/widgets/' . $widget . '.php';
register_widget( $widget );
}
} | php | public function register_widgets() {
$widgets = array(
'PodsWidgetSingle',
'PodsWidgetList',
'PodsWidgetField',
'PodsWidgetForm',
'PodsWidgetView',
);
foreach ( $widgets as $widget ) {
if ( ! file_exists( PODS_DIR . 'classes/widgets/' . $widget . '.php' ) ) {
continue;
}
require_once PODS_DIR . 'classes/widgets/' . $widget . '.php';
register_widget( $widget );
}
} | [
"public",
"function",
"register_widgets",
"(",
")",
"{",
"$",
"widgets",
"=",
"array",
"(",
"'PodsWidgetSingle'",
",",
"'PodsWidgetList'",
",",
"'PodsWidgetField'",
",",
"'PodsWidgetForm'",
",",
"'PodsWidgetView'",
",",
")",
";",
"foreach",
"(",
"$",
"widgets",
... | Register widgets for Pods | [
"Register",
"widgets",
"for",
"Pods"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsInit.php#L1768-L1787 | train |
pods-framework/pods | classes/PodsInit.php | PodsInit.admin_bar_links | public function admin_bar_links() {
global $wp_admin_bar, $pods;
if ( ! is_user_logged_in() || ! is_admin_bar_showing() ) {
return;
}
$all_pods = pods_api()->load_pods(
array(
'type' => 'pod',
'fields' => false,
'table_info' => false,
)
);
// Add New item links for all pods
foreach ( $all_pods as $pod ) {
if ( 0 === (int) $pod['options']['show_in_menu'] ) {
continue;
}
if ( ! pods_is_admin( array( 'pods', 'pods_content', 'pods_add_' . $pod['name'] ) ) ) {
continue;
}
$singular_label = pods_v( 'label_singular', $pod['options'], pods_v( 'label', $pod, ucwords( str_replace( '_', ' ', $pod['name'] ) ), true ), true );
$wp_admin_bar->add_node(
array(
'id' => 'new-pod-' . $pod['name'],
'title' => $singular_label,
'parent' => 'new-content',
'href' => admin_url( 'admin.php?page=pods-manage-' . $pod['name'] . '&action=add' ),
)
);
}
// Add edit link if we're on a pods page
if ( is_object( $pods ) && ! is_wp_error( $pods ) && ! empty( $pods->id ) && isset( $pods->pod_data ) && ! empty( $pods->pod_data ) && 'pod' === $pods->pod_data['type'] ) {
$pod = $pods->pod_data;
if ( pods_is_admin( array( 'pods', 'pods_content', 'pods_edit_' . $pod['name'] ) ) ) {
$singular_label = pods_v( 'label_singular', $pod['options'], pods_v( 'label', $pod, ucwords( str_replace( '_', ' ', $pod['name'] ) ), true ), true );
$wp_admin_bar->add_node(
array(
'title' => sprintf( __( 'Edit %s', 'pods' ), $singular_label ),
'id' => 'edit-pod',
'href' => admin_url( 'admin.php?page=pods-manage-' . $pod['name'] . '&action=edit&id=' . $pods->id() ),
)
);
}
}
} | php | public function admin_bar_links() {
global $wp_admin_bar, $pods;
if ( ! is_user_logged_in() || ! is_admin_bar_showing() ) {
return;
}
$all_pods = pods_api()->load_pods(
array(
'type' => 'pod',
'fields' => false,
'table_info' => false,
)
);
// Add New item links for all pods
foreach ( $all_pods as $pod ) {
if ( 0 === (int) $pod['options']['show_in_menu'] ) {
continue;
}
if ( ! pods_is_admin( array( 'pods', 'pods_content', 'pods_add_' . $pod['name'] ) ) ) {
continue;
}
$singular_label = pods_v( 'label_singular', $pod['options'], pods_v( 'label', $pod, ucwords( str_replace( '_', ' ', $pod['name'] ) ), true ), true );
$wp_admin_bar->add_node(
array(
'id' => 'new-pod-' . $pod['name'],
'title' => $singular_label,
'parent' => 'new-content',
'href' => admin_url( 'admin.php?page=pods-manage-' . $pod['name'] . '&action=add' ),
)
);
}
// Add edit link if we're on a pods page
if ( is_object( $pods ) && ! is_wp_error( $pods ) && ! empty( $pods->id ) && isset( $pods->pod_data ) && ! empty( $pods->pod_data ) && 'pod' === $pods->pod_data['type'] ) {
$pod = $pods->pod_data;
if ( pods_is_admin( array( 'pods', 'pods_content', 'pods_edit_' . $pod['name'] ) ) ) {
$singular_label = pods_v( 'label_singular', $pod['options'], pods_v( 'label', $pod, ucwords( str_replace( '_', ' ', $pod['name'] ) ), true ), true );
$wp_admin_bar->add_node(
array(
'title' => sprintf( __( 'Edit %s', 'pods' ), $singular_label ),
'id' => 'edit-pod',
'href' => admin_url( 'admin.php?page=pods-manage-' . $pod['name'] . '&action=edit&id=' . $pods->id() ),
)
);
}
}
} | [
"public",
"function",
"admin_bar_links",
"(",
")",
"{",
"global",
"$",
"wp_admin_bar",
",",
"$",
"pods",
";",
"if",
"(",
"!",
"is_user_logged_in",
"(",
")",
"||",
"!",
"is_admin_bar_showing",
"(",
")",
")",
"{",
"return",
";",
"}",
"$",
"all_pods",
"=",
... | Add Admin Bar links | [
"Add",
"Admin",
"Bar",
"links"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsInit.php#L1792-L1847 | train |
pods-framework/pods | classes/fields/number.php | PodsField_Number.get_number_format_args | public function get_number_format_args( $options ) {
global $wp_locale;
if ( '9.999,99' === pods_v( static::$type . '_format', $options ) ) {
$thousands = '.';
$dot = ',';
} elseif ( '9,999.99' === pods_v( static::$type . '_format', $options ) ) {
$thousands = ',';
$dot = '.';
} elseif ( '9\'999.99' === pods_v( static::$type . '_format', $options ) ) {
$thousands = '\'';
$dot = '.';
} elseif ( '9 999,99' === pods_v( static::$type . '_format', $options ) ) {
$thousands = ' ';
$dot = ',';
} elseif ( '9999.99' === pods_v( static::$type . '_format', $options ) ) {
$thousands = '';
$dot = '.';
} elseif ( '9999,99' === pods_v( static::$type . '_format', $options ) ) {
$thousands = '';
$dot = ',';
} else {
$thousands = $wp_locale->number_format['thousands_sep'];
$dot = $wp_locale->number_format['decimal_point'];
}//end if
$decimals = $this->get_max_decimals( $options );
return array(
'thousands' => $thousands,
'dot' => $dot,
'decimals' => $decimals,
);
} | php | public function get_number_format_args( $options ) {
global $wp_locale;
if ( '9.999,99' === pods_v( static::$type . '_format', $options ) ) {
$thousands = '.';
$dot = ',';
} elseif ( '9,999.99' === pods_v( static::$type . '_format', $options ) ) {
$thousands = ',';
$dot = '.';
} elseif ( '9\'999.99' === pods_v( static::$type . '_format', $options ) ) {
$thousands = '\'';
$dot = '.';
} elseif ( '9 999,99' === pods_v( static::$type . '_format', $options ) ) {
$thousands = ' ';
$dot = ',';
} elseif ( '9999.99' === pods_v( static::$type . '_format', $options ) ) {
$thousands = '';
$dot = '.';
} elseif ( '9999,99' === pods_v( static::$type . '_format', $options ) ) {
$thousands = '';
$dot = ',';
} else {
$thousands = $wp_locale->number_format['thousands_sep'];
$dot = $wp_locale->number_format['decimal_point'];
}//end if
$decimals = $this->get_max_decimals( $options );
return array(
'thousands' => $thousands,
'dot' => $dot,
'decimals' => $decimals,
);
} | [
"public",
"function",
"get_number_format_args",
"(",
"$",
"options",
")",
"{",
"global",
"$",
"wp_locale",
";",
"if",
"(",
"'9.999,99'",
"===",
"pods_v",
"(",
"static",
"::",
"$",
"type",
".",
"'_format'",
",",
"$",
"options",
")",
")",
"{",
"$",
"thousa... | Get the formatting arguments for numbers.
@since 2.7.0
@param array $options Field options.
@return array {
@type string $thousands
@type string $dot
@type int $decimals
} | [
"Get",
"the",
"formatting",
"arguments",
"for",
"numbers",
"."
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/fields/number.php#L339-L373 | train |
pods-framework/pods | classes/PodsAPI.php | PodsAPI.save_wp_object | public function save_wp_object( $object_type, $data, $meta = array(), $strict = false, $sanitized = false, $fields = array() ) {
if ( in_array( $object_type, array( 'post_type', 'media' ) ) ) {
$object_type = 'post';
}
if ( 'taxonomy' === $object_type ) {
$object_type = 'term';
}
if ( $sanitized ) {
$data = pods_unsanitize( $data );
$meta = pods_unsanitize( $meta );
}
if ( in_array( $object_type, array( 'post', 'term', 'user', 'comment' ) ) ) {
return call_user_func( array( $this, 'save_' . $object_type ), $data, $meta, $strict, false, $fields );
} elseif ( 'settings' === $object_type ) {
// Nothing to save
if ( empty( $meta ) ) {
return true;
}
return $this->save_setting( pods_var( 'option_id', $data ), $meta, false );
}
return false;
} | php | public function save_wp_object( $object_type, $data, $meta = array(), $strict = false, $sanitized = false, $fields = array() ) {
if ( in_array( $object_type, array( 'post_type', 'media' ) ) ) {
$object_type = 'post';
}
if ( 'taxonomy' === $object_type ) {
$object_type = 'term';
}
if ( $sanitized ) {
$data = pods_unsanitize( $data );
$meta = pods_unsanitize( $meta );
}
if ( in_array( $object_type, array( 'post', 'term', 'user', 'comment' ) ) ) {
return call_user_func( array( $this, 'save_' . $object_type ), $data, $meta, $strict, false, $fields );
} elseif ( 'settings' === $object_type ) {
// Nothing to save
if ( empty( $meta ) ) {
return true;
}
return $this->save_setting( pods_var( 'option_id', $data ), $meta, false );
}
return false;
} | [
"public",
"function",
"save_wp_object",
"(",
"$",
"object_type",
",",
"$",
"data",
",",
"$",
"meta",
"=",
"array",
"(",
")",
",",
"$",
"strict",
"=",
"false",
",",
"$",
"sanitized",
"=",
"false",
",",
"$",
"fields",
"=",
"array",
"(",
")",
")",
"{"... | Save a WP object and its meta
@param string $object_type Object type: post|taxonomy|user|comment|setting
@param array $data All post data to be saved
@param array $meta (optional) Associative array of meta keys and values
@param bool $strict (optional) Decides whether the previous saved meta should be deleted or not
@param bool $sanitized (optional) Will unsanitize the data, should be passed if the data is sanitized before
sending.
@param array $fields (optional) The array of fields and their options, for further processing with
@return bool|mixed
@since 2.0.0 | [
"Save",
"a",
"WP",
"object",
"and",
"its",
"meta"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsAPI.php#L148-L175 | train |
pods-framework/pods | classes/PodsAPI.php | PodsAPI.delete_wp_object | public function delete_wp_object( $object_type, $id, $force_delete = true ) {
if ( in_array( $object_type, array( 'post_type', 'media' ) ) ) {
$object_type = 'post';
}
if ( 'taxonomy' === $object_type ) {
$object_type = 'term';
}
if ( empty( $id ) ) {
return false;
}
if ( in_array( $object_type, array( 'post' ) ) ) {
return wp_delete_post( $id, $force_delete );
}
if ( function_exists( 'wp_delete_' . $object_type ) ) {
return call_user_func( 'wp_delete_' . $object_type, $id );
}
return false;
} | php | public function delete_wp_object( $object_type, $id, $force_delete = true ) {
if ( in_array( $object_type, array( 'post_type', 'media' ) ) ) {
$object_type = 'post';
}
if ( 'taxonomy' === $object_type ) {
$object_type = 'term';
}
if ( empty( $id ) ) {
return false;
}
if ( in_array( $object_type, array( 'post' ) ) ) {
return wp_delete_post( $id, $force_delete );
}
if ( function_exists( 'wp_delete_' . $object_type ) ) {
return call_user_func( 'wp_delete_' . $object_type, $id );
}
return false;
} | [
"public",
"function",
"delete_wp_object",
"(",
"$",
"object_type",
",",
"$",
"id",
",",
"$",
"force_delete",
"=",
"true",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"object_type",
",",
"array",
"(",
"'post_type'",
",",
"'media'",
")",
")",
")",
"{",
"$... | Delete a WP object
@param string $object_type Object type: post|user|comment
@param int $id Object ID
@param bool $force_delete (optional) Force deletion instead of trashing (post types only)
@return bool|mixed
@since 2.0.0 | [
"Delete",
"a",
"WP",
"object"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsAPI.php#L188-L211 | train |
pods-framework/pods | classes/PodsAPI.php | PodsAPI.save_post | public function save_post( $post_data, $post_meta = null, $strict = false, $sanitized = false, $fields = array() ) {
$conflicted = pods_no_conflict_check( 'post' );
if ( ! $conflicted ) {
pods_no_conflict_on( 'post' );
}
if ( ! is_array( $post_data ) || empty( $post_data ) ) {
$post_data = array( 'post_title' => '' );
}
if ( ! is_array( $post_meta ) ) {
$post_meta = array();
}
if ( $sanitized ) {
$post_data = pods_unsanitize( $post_data );
$post_meta = pods_unsanitize( $post_meta );
}
if ( ! isset( $post_data['ID'] ) || empty( $post_data['ID'] ) ) {
$post_data['ID'] = wp_insert_post( $post_data, true );
} elseif ( 2 < count( $post_data ) || ! isset( $post_data['post_type'] ) ) {
$post_data['ID'] = wp_update_post( $post_data, true );
}
if ( is_wp_error( $post_data['ID'] ) ) {
if ( ! $conflicted ) {
pods_no_conflict_off( 'post' );
}
/**
* @var $post_error WP_Error
*/
$post_error = $post_data['ID'];
return pods_error( $post_error->get_error_message(), $this );
}
$this->save_post_meta( $post_data['ID'], $post_meta, $strict, $fields );
if ( ! $conflicted ) {
pods_no_conflict_off( 'post' );
}
return $post_data['ID'];
} | php | public function save_post( $post_data, $post_meta = null, $strict = false, $sanitized = false, $fields = array() ) {
$conflicted = pods_no_conflict_check( 'post' );
if ( ! $conflicted ) {
pods_no_conflict_on( 'post' );
}
if ( ! is_array( $post_data ) || empty( $post_data ) ) {
$post_data = array( 'post_title' => '' );
}
if ( ! is_array( $post_meta ) ) {
$post_meta = array();
}
if ( $sanitized ) {
$post_data = pods_unsanitize( $post_data );
$post_meta = pods_unsanitize( $post_meta );
}
if ( ! isset( $post_data['ID'] ) || empty( $post_data['ID'] ) ) {
$post_data['ID'] = wp_insert_post( $post_data, true );
} elseif ( 2 < count( $post_data ) || ! isset( $post_data['post_type'] ) ) {
$post_data['ID'] = wp_update_post( $post_data, true );
}
if ( is_wp_error( $post_data['ID'] ) ) {
if ( ! $conflicted ) {
pods_no_conflict_off( 'post' );
}
/**
* @var $post_error WP_Error
*/
$post_error = $post_data['ID'];
return pods_error( $post_error->get_error_message(), $this );
}
$this->save_post_meta( $post_data['ID'], $post_meta, $strict, $fields );
if ( ! $conflicted ) {
pods_no_conflict_off( 'post' );
}
return $post_data['ID'];
} | [
"public",
"function",
"save_post",
"(",
"$",
"post_data",
",",
"$",
"post_meta",
"=",
"null",
",",
"$",
"strict",
"=",
"false",
",",
"$",
"sanitized",
"=",
"false",
",",
"$",
"fields",
"=",
"array",
"(",
")",
")",
"{",
"$",
"conflicted",
"=",
"pods_n... | Save a post and it's meta
@param array $post_data All post data to be saved (using wp_insert_post / wp_update_post)
@param array $post_meta (optional) All meta to be saved (set value to null to delete)
@param bool $strict (optional) Whether to delete previously saved meta not in $post_meta
@param bool $sanitized (optional) Will unsanitize the data, should be passed if the data is sanitized before
sending.
@param array $fields (optional) The array of fields and their options, for further processing with
@return mixed|void
@since 2.0.0 | [
"Save",
"a",
"post",
"and",
"it",
"s",
"meta"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsAPI.php#L227-L274 | train |
pods-framework/pods | classes/PodsAPI.php | PodsAPI.save_post_meta | public function save_post_meta( $id, $post_meta = null, $strict = false, $fields = array() ) {
$simple_tableless_objects = PodsForm::simple_tableless_objects();
$conflicted = pods_no_conflict_check( 'post' );
if ( ! $conflicted ) {
pods_no_conflict_on( 'post' );
}
if ( ! is_array( $post_meta ) ) {
$post_meta = array();
}
$id = (int) $id;
$meta = get_post_meta( $id );
foreach ( $meta as $k => $value ) {
if ( is_array( $value ) && 1 == count( $value ) ) {
$meta[ $k ] = current( $value );
}
}
foreach ( $post_meta as $meta_key => $meta_value ) {
if ( null === $meta_value || ( $strict && '' === $post_meta[ $meta_key ] ) ) {
$old_meta_value = '';
if ( isset( $meta[ $meta_key ] ) ) {
$old_meta_value = $meta[ $meta_key ];
}
delete_post_meta( $id, $meta_key, $old_meta_value );
} else {
$simple = false;
if ( isset( $fields[ $meta_key ] ) ) {
$field_data = $fields[ $meta_key ];
$simple = ( 'pick' === $field_data['type'] && in_array( pods_var( 'pick_object', $field_data ), $simple_tableless_objects ) );
}
if ( $simple ) {
delete_post_meta( $id, $meta_key );
update_post_meta( $id, '_pods_' . $meta_key, $meta_value );
if ( ! is_array( $meta_value ) ) {
$meta_value = array( $meta_value );
}
foreach ( $meta_value as $value ) {
add_post_meta( $id, $meta_key, $value );
}
} else {
update_post_meta( $id, $meta_key, $meta_value );
}
}
}
if ( $strict ) {
foreach ( $meta as $meta_key => $meta_value ) {
if ( ! isset( $post_meta[ $meta_key ] ) ) {
delete_post_meta( $id, $meta_key, $meta_value );
}
}
}
if ( ! $conflicted ) {
pods_no_conflict_off( 'post' );
}
return $id;
} | php | public function save_post_meta( $id, $post_meta = null, $strict = false, $fields = array() ) {
$simple_tableless_objects = PodsForm::simple_tableless_objects();
$conflicted = pods_no_conflict_check( 'post' );
if ( ! $conflicted ) {
pods_no_conflict_on( 'post' );
}
if ( ! is_array( $post_meta ) ) {
$post_meta = array();
}
$id = (int) $id;
$meta = get_post_meta( $id );
foreach ( $meta as $k => $value ) {
if ( is_array( $value ) && 1 == count( $value ) ) {
$meta[ $k ] = current( $value );
}
}
foreach ( $post_meta as $meta_key => $meta_value ) {
if ( null === $meta_value || ( $strict && '' === $post_meta[ $meta_key ] ) ) {
$old_meta_value = '';
if ( isset( $meta[ $meta_key ] ) ) {
$old_meta_value = $meta[ $meta_key ];
}
delete_post_meta( $id, $meta_key, $old_meta_value );
} else {
$simple = false;
if ( isset( $fields[ $meta_key ] ) ) {
$field_data = $fields[ $meta_key ];
$simple = ( 'pick' === $field_data['type'] && in_array( pods_var( 'pick_object', $field_data ), $simple_tableless_objects ) );
}
if ( $simple ) {
delete_post_meta( $id, $meta_key );
update_post_meta( $id, '_pods_' . $meta_key, $meta_value );
if ( ! is_array( $meta_value ) ) {
$meta_value = array( $meta_value );
}
foreach ( $meta_value as $value ) {
add_post_meta( $id, $meta_key, $value );
}
} else {
update_post_meta( $id, $meta_key, $meta_value );
}
}
}
if ( $strict ) {
foreach ( $meta as $meta_key => $meta_value ) {
if ( ! isset( $post_meta[ $meta_key ] ) ) {
delete_post_meta( $id, $meta_key, $meta_value );
}
}
}
if ( ! $conflicted ) {
pods_no_conflict_off( 'post' );
}
return $id;
} | [
"public",
"function",
"save_post_meta",
"(",
"$",
"id",
",",
"$",
"post_meta",
"=",
"null",
",",
"$",
"strict",
"=",
"false",
",",
"$",
"fields",
"=",
"array",
"(",
")",
")",
"{",
"$",
"simple_tableless_objects",
"=",
"PodsForm",
"::",
"simple_tableless_ob... | Save a post's meta
@param int $id Post ID
@param array $post_meta All meta to be saved (set value to null to delete)
@param bool $strict Whether to delete previously saved meta not in $post_meta
@param array $fields (optional) The array of fields and their options, for further processing with
@return int Id of the post with the meta
@since 2.0.0 | [
"Save",
"a",
"post",
"s",
"meta"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsAPI.php#L288-L361 | train |
pods-framework/pods | classes/PodsAPI.php | PodsAPI.save_user | public function save_user( $user_data, $user_meta = null, $strict = false, $sanitized = false, $fields = array() ) {
if ( ! is_array( $user_data ) || empty( $user_data ) ) {
return pods_error( __( 'User data is required but is either invalid or empty', 'pods' ), $this );
}
$conflicted = pods_no_conflict_check( 'user' );
if ( ! $conflicted ) {
pods_no_conflict_on( 'user' );
}
if ( ! is_array( $user_meta ) ) {
$user_meta = array();
}
if ( $sanitized ) {
$user_data = pods_unsanitize( $user_data );
$user_meta = pods_unsanitize( $user_meta );
}
// Set role
if ( isset( $user_meta['role'] ) ) {
$user_data['role'] = $user_meta['role'];
unset( $user_meta['role'] );
}
if ( ! isset( $user_data['ID'] ) || empty( $user_data['ID'] ) ) {
$user_data['ID'] = wp_insert_user( $user_data );
} elseif ( 1 < count( $user_data ) ) {
wp_update_user( $user_data );
}
if ( is_wp_error( $user_data['ID'] ) ) {
if ( ! $conflicted ) {
pods_no_conflict_off( 'user' );
}
/**
* @var $user_error WP_Error
*/
$user_error = $user_data['ID'];
return pods_error( $user_error->get_error_message(), $this );
}
$this->save_user_meta( $user_data['ID'], $user_meta, $strict, $fields );
if ( ! $conflicted ) {
pods_no_conflict_off( 'user' );
}
return $user_data['ID'];
} | php | public function save_user( $user_data, $user_meta = null, $strict = false, $sanitized = false, $fields = array() ) {
if ( ! is_array( $user_data ) || empty( $user_data ) ) {
return pods_error( __( 'User data is required but is either invalid or empty', 'pods' ), $this );
}
$conflicted = pods_no_conflict_check( 'user' );
if ( ! $conflicted ) {
pods_no_conflict_on( 'user' );
}
if ( ! is_array( $user_meta ) ) {
$user_meta = array();
}
if ( $sanitized ) {
$user_data = pods_unsanitize( $user_data );
$user_meta = pods_unsanitize( $user_meta );
}
// Set role
if ( isset( $user_meta['role'] ) ) {
$user_data['role'] = $user_meta['role'];
unset( $user_meta['role'] );
}
if ( ! isset( $user_data['ID'] ) || empty( $user_data['ID'] ) ) {
$user_data['ID'] = wp_insert_user( $user_data );
} elseif ( 1 < count( $user_data ) ) {
wp_update_user( $user_data );
}
if ( is_wp_error( $user_data['ID'] ) ) {
if ( ! $conflicted ) {
pods_no_conflict_off( 'user' );
}
/**
* @var $user_error WP_Error
*/
$user_error = $user_data['ID'];
return pods_error( $user_error->get_error_message(), $this );
}
$this->save_user_meta( $user_data['ID'], $user_meta, $strict, $fields );
if ( ! $conflicted ) {
pods_no_conflict_off( 'user' );
}
return $user_data['ID'];
} | [
"public",
"function",
"save_user",
"(",
"$",
"user_data",
",",
"$",
"user_meta",
"=",
"null",
",",
"$",
"strict",
"=",
"false",
",",
"$",
"sanitized",
"=",
"false",
",",
"$",
"fields",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"is_array",
"... | Save a user and it's meta
@param array $user_data All user data to be saved (using wp_insert_user / wp_update_user)
@param array $user_meta (optional) All meta to be saved (set value to null to delete)
@param bool $strict (optional) Whether to delete previously saved meta not in $user_meta
@param bool $sanitized (optional) Will unsanitize the data, should be passed if the data is sanitized before
sending.
@param array $fields (optional) The array of fields and their options, for further processing with
@return int Returns user id on success
@since 2.0.0 | [
"Save",
"a",
"user",
"and",
"it",
"s",
"meta"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsAPI.php#L377-L431 | train |
pods-framework/pods | classes/PodsAPI.php | PodsAPI.save_user_meta | public function save_user_meta( $id, $user_meta = null, $strict = false, $fields = array() ) {
$simple_tableless_objects = PodsForm::simple_tableless_objects();
$conflicted = pods_no_conflict_check( 'user' );
if ( ! $conflicted ) {
pods_no_conflict_on( 'user' );
}
if ( ! is_array( $user_meta ) ) {
$user_meta = array();
}
$id = (int) $id;
$meta = get_user_meta( $id );
foreach ( $user_meta as $meta_key => $meta_value ) {
if ( null === $meta_value ) {
$old_meta_value = '';
if ( isset( $meta[ $meta_key ] ) ) {
$old_meta_value = $meta[ $meta_key ];
}
delete_user_meta( $id, $meta_key, $old_meta_value );
} else {
$simple = false;
if ( isset( $fields[ $meta_key ] ) ) {
$field_data = $fields[ $meta_key ];
$simple = ( 'pick' === $field_data['type'] && in_array( pods_var( 'pick_object', $field_data ), $simple_tableless_objects ) );
}
if ( $simple ) {
delete_user_meta( $id, $meta_key );
if ( ! is_array( $meta_value ) ) {
$meta_value = array( $meta_value );
}
foreach ( $meta_value as $value ) {
add_user_meta( $id, $meta_key, $value );
}
} else {
update_user_meta( $id, $meta_key, $meta_value );
}
}
}
if ( $strict ) {
foreach ( $meta as $meta_key => $meta_value ) {
if ( ! isset( $user_meta[ $meta_key ] ) ) {
delete_user_meta( $id, $meta_key, $user_meta[ $meta_key ] );
}
}
}
if ( ! $conflicted ) {
pods_no_conflict_off( 'user' );
}
return $id;
} | php | public function save_user_meta( $id, $user_meta = null, $strict = false, $fields = array() ) {
$simple_tableless_objects = PodsForm::simple_tableless_objects();
$conflicted = pods_no_conflict_check( 'user' );
if ( ! $conflicted ) {
pods_no_conflict_on( 'user' );
}
if ( ! is_array( $user_meta ) ) {
$user_meta = array();
}
$id = (int) $id;
$meta = get_user_meta( $id );
foreach ( $user_meta as $meta_key => $meta_value ) {
if ( null === $meta_value ) {
$old_meta_value = '';
if ( isset( $meta[ $meta_key ] ) ) {
$old_meta_value = $meta[ $meta_key ];
}
delete_user_meta( $id, $meta_key, $old_meta_value );
} else {
$simple = false;
if ( isset( $fields[ $meta_key ] ) ) {
$field_data = $fields[ $meta_key ];
$simple = ( 'pick' === $field_data['type'] && in_array( pods_var( 'pick_object', $field_data ), $simple_tableless_objects ) );
}
if ( $simple ) {
delete_user_meta( $id, $meta_key );
if ( ! is_array( $meta_value ) ) {
$meta_value = array( $meta_value );
}
foreach ( $meta_value as $value ) {
add_user_meta( $id, $meta_key, $value );
}
} else {
update_user_meta( $id, $meta_key, $meta_value );
}
}
}
if ( $strict ) {
foreach ( $meta as $meta_key => $meta_value ) {
if ( ! isset( $user_meta[ $meta_key ] ) ) {
delete_user_meta( $id, $meta_key, $user_meta[ $meta_key ] );
}
}
}
if ( ! $conflicted ) {
pods_no_conflict_off( 'user' );
}
return $id;
} | [
"public",
"function",
"save_user_meta",
"(",
"$",
"id",
",",
"$",
"user_meta",
"=",
"null",
",",
"$",
"strict",
"=",
"false",
",",
"$",
"fields",
"=",
"array",
"(",
")",
")",
"{",
"$",
"simple_tableless_objects",
"=",
"PodsForm",
"::",
"simple_tableless_ob... | Save a user meta
@param int $id User ID
@param array $user_meta (optional) All meta to be saved (set value to null to delete)
@param bool $strict (optional) Whether to delete previously saved meta not in $user_meta
@param array $fields (optional) The array of fields and their options, for further processing with
@return int User ID
@since 2.0.0 | [
"Save",
"a",
"user",
"meta"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsAPI.php#L446-L511 | train |
pods-framework/pods | classes/PodsAPI.php | PodsAPI.save_comment | public function save_comment( $comment_data, $comment_meta = null, $strict = false, $sanitized = false, $fields = array() ) {
if ( ! is_array( $comment_data ) || empty( $comment_data ) ) {
return pods_error( __( 'Comment data is required but is either invalid or empty', 'pods' ), $this );
}
$conflicted = pods_no_conflict_check( 'comment' );
if ( ! $conflicted ) {
pods_no_conflict_on( 'comment' );
}
if ( ! is_array( $comment_meta ) ) {
$comment_meta = array();
}
if ( $sanitized ) {
$comment_data = pods_unsanitize( $comment_data );
$comment_meta = pods_unsanitize( $comment_meta );
}
if ( ! isset( $comment_data['comment_ID'] ) || empty( $comment_data['comment_ID'] ) ) {
$comment_data['comment_ID'] = wp_insert_comment( pods_slash( $comment_data ) );
} elseif ( 1 < count( $comment_data ) ) {
// Expects slashed
wp_update_comment( $comment_data );
}
if ( is_wp_error( $comment_data['comment_ID'] ) ) {
if ( ! $conflicted ) {
pods_no_conflict_off( 'comment' );
}
/**
* @var $comment_error WP_Error
*/
$comment_error = $comment_data['comment_ID'];
return pods_error( $comment_error->get_error_message(), $this );
}
$this->save_comment_meta( $comment_data['comment_ID'], $comment_meta, $strict, $fields );
if ( ! $conflicted ) {
pods_no_conflict_off( 'comment' );
}
return $comment_data['comment_ID'];
} | php | public function save_comment( $comment_data, $comment_meta = null, $strict = false, $sanitized = false, $fields = array() ) {
if ( ! is_array( $comment_data ) || empty( $comment_data ) ) {
return pods_error( __( 'Comment data is required but is either invalid or empty', 'pods' ), $this );
}
$conflicted = pods_no_conflict_check( 'comment' );
if ( ! $conflicted ) {
pods_no_conflict_on( 'comment' );
}
if ( ! is_array( $comment_meta ) ) {
$comment_meta = array();
}
if ( $sanitized ) {
$comment_data = pods_unsanitize( $comment_data );
$comment_meta = pods_unsanitize( $comment_meta );
}
if ( ! isset( $comment_data['comment_ID'] ) || empty( $comment_data['comment_ID'] ) ) {
$comment_data['comment_ID'] = wp_insert_comment( pods_slash( $comment_data ) );
} elseif ( 1 < count( $comment_data ) ) {
// Expects slashed
wp_update_comment( $comment_data );
}
if ( is_wp_error( $comment_data['comment_ID'] ) ) {
if ( ! $conflicted ) {
pods_no_conflict_off( 'comment' );
}
/**
* @var $comment_error WP_Error
*/
$comment_error = $comment_data['comment_ID'];
return pods_error( $comment_error->get_error_message(), $this );
}
$this->save_comment_meta( $comment_data['comment_ID'], $comment_meta, $strict, $fields );
if ( ! $conflicted ) {
pods_no_conflict_off( 'comment' );
}
return $comment_data['comment_ID'];
} | [
"public",
"function",
"save_comment",
"(",
"$",
"comment_data",
",",
"$",
"comment_meta",
"=",
"null",
",",
"$",
"strict",
"=",
"false",
",",
"$",
"sanitized",
"=",
"false",
",",
"$",
"fields",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"is_ar... | Save a comment and it's meta
@param array $comment_data All comment data to be saved (using wp_insert_comment / wp_update_comment)
@param array $comment_meta (optional) All meta to be saved (set value to null to delete)
@param bool $strict (optional) Whether to delete previously saved meta not in $comment_meta
@param bool $sanitized (optional) Will unsanitize the data, should be passed if the data is sanitized before
sending.
@param array $fields (optional) The array of fields and their options, for further processing with
@return int Comment ID
@since 2.0.0 | [
"Save",
"a",
"comment",
"and",
"it",
"s",
"meta"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsAPI.php#L527-L575 | train |
pods-framework/pods | classes/PodsAPI.php | PodsAPI.save_comment_meta | public function save_comment_meta( $id, $comment_meta = null, $strict = false, $fields = array() ) {
$simple_tableless_objects = PodsForm::simple_tableless_objects();
$conflicted = pods_no_conflict_check( 'comment' );
if ( ! $conflicted ) {
pods_no_conflict_on( 'comment' );
}
if ( ! is_array( $comment_meta ) ) {
$comment_meta = array();
}
$id = (int) $id;
$meta = get_comment_meta( $id );
foreach ( $comment_meta as $meta_key => $meta_value ) {
if ( null === $meta_value ) {
$old_meta_value = '';
if ( isset( $meta[ $meta_key ] ) ) {
$old_meta_value = $meta[ $meta_key ];
}
delete_comment_meta( $id, $meta_key, $old_meta_value );
} else {
$simple = false;
if ( isset( $fields[ $meta_key ] ) ) {
$field_data = $fields[ $meta_key ];
$simple = ( 'pick' === $field_data['type'] && in_array( pods_var( 'pick_object', $field_data ), $simple_tableless_objects ) );
}
if ( $simple ) {
delete_comment_meta( $id, $meta_key );
if ( ! is_array( $meta_value ) ) {
$meta_value = array( $meta_value );
}
foreach ( $meta_value as $value ) {
add_comment_meta( $id, $meta_key, $value );
}
} else {
update_comment_meta( $id, $meta_key, $meta_value );
}
}
}
if ( $strict ) {
foreach ( $meta as $meta_key => $meta_value ) {
if ( ! isset( $comment_meta[ $meta_key ] ) ) {
delete_comment_meta( (int) $id, $meta_key, $comment_meta[ $meta_key ] );
}
}
}
if ( ! $conflicted ) {
pods_no_conflict_off( 'comment' );
}
return $id;
} | php | public function save_comment_meta( $id, $comment_meta = null, $strict = false, $fields = array() ) {
$simple_tableless_objects = PodsForm::simple_tableless_objects();
$conflicted = pods_no_conflict_check( 'comment' );
if ( ! $conflicted ) {
pods_no_conflict_on( 'comment' );
}
if ( ! is_array( $comment_meta ) ) {
$comment_meta = array();
}
$id = (int) $id;
$meta = get_comment_meta( $id );
foreach ( $comment_meta as $meta_key => $meta_value ) {
if ( null === $meta_value ) {
$old_meta_value = '';
if ( isset( $meta[ $meta_key ] ) ) {
$old_meta_value = $meta[ $meta_key ];
}
delete_comment_meta( $id, $meta_key, $old_meta_value );
} else {
$simple = false;
if ( isset( $fields[ $meta_key ] ) ) {
$field_data = $fields[ $meta_key ];
$simple = ( 'pick' === $field_data['type'] && in_array( pods_var( 'pick_object', $field_data ), $simple_tableless_objects ) );
}
if ( $simple ) {
delete_comment_meta( $id, $meta_key );
if ( ! is_array( $meta_value ) ) {
$meta_value = array( $meta_value );
}
foreach ( $meta_value as $value ) {
add_comment_meta( $id, $meta_key, $value );
}
} else {
update_comment_meta( $id, $meta_key, $meta_value );
}
}
}
if ( $strict ) {
foreach ( $meta as $meta_key => $meta_value ) {
if ( ! isset( $comment_meta[ $meta_key ] ) ) {
delete_comment_meta( (int) $id, $meta_key, $comment_meta[ $meta_key ] );
}
}
}
if ( ! $conflicted ) {
pods_no_conflict_off( 'comment' );
}
return $id;
} | [
"public",
"function",
"save_comment_meta",
"(",
"$",
"id",
",",
"$",
"comment_meta",
"=",
"null",
",",
"$",
"strict",
"=",
"false",
",",
"$",
"fields",
"=",
"array",
"(",
")",
")",
"{",
"$",
"simple_tableless_objects",
"=",
"PodsForm",
"::",
"simple_tablel... | Save a comment meta
@param int $id Comment ID
@param array $comment_meta (optional) All meta to be saved (set value to null to delete)
@param bool $strict (optional) Whether to delete previously saved meta not in $comment_meta
@param array $fields (optional) The array of fields and their options, for further processing with
@return int Comment ID
@since 2.0.0 | [
"Save",
"a",
"comment",
"meta"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsAPI.php#L589-L654 | train |
pods-framework/pods | classes/PodsAPI.php | PodsAPI.save_term | public function save_term( $term_data, $term_meta, $strict = false, $sanitized = false, $fields = array() ) {
if ( empty( $term_data['taxonomy'] ) ) {
return 0;
}
$conflicted = pods_no_conflict_check( 'taxonomy' );
if ( ! is_array( $term_data ) || empty( $term_data ) ) {
$term_data = array( 'name' => '' );
}
if ( ! $conflicted ) {
pods_no_conflict_on( 'taxonomy' );
}
if ( ! is_array( $term_meta ) ) {
$term_meta = array();
}
if ( $sanitized ) {
$term_data = pods_unsanitize( $term_data );
$term_meta = pods_unsanitize( $term_meta );
}
$taxonomy = $term_data['taxonomy'];
unset( $term_data['taxonomy'] );
if ( empty( $term_data['term_id'] ) ) {
$term_name = $term_data['name'];
unset( $term_data['name'] );
$term_data['term_id'] = wp_insert_term( $term_name, $taxonomy, $term_data );
} elseif ( 1 < count( $term_data ) ) {
$term_data['term_id'] = wp_update_term( $term_data['term_id'], $taxonomy, $term_data );
}
if ( is_wp_error( $term_data['term_id'] ) ) {
if ( ! $conflicted ) {
pods_no_conflict_off( 'taxonomy' );
}
/**
* @var $term_error WP_Error
*/
$term_error = $term_data['term_id'];
return pods_error( $term_error->get_error_message(), $this );
} elseif ( is_array( $term_data['term_id'] ) ) {
$term_data['term_id'] = $term_data['term_id']['term_id'];
}
$this->save_term_meta( $term_data['term_id'], $term_meta, $strict, $fields );
if ( ! $conflicted ) {
pods_no_conflict_off( 'taxonomy' );
}
return $term_data['term_id'];
} | php | public function save_term( $term_data, $term_meta, $strict = false, $sanitized = false, $fields = array() ) {
if ( empty( $term_data['taxonomy'] ) ) {
return 0;
}
$conflicted = pods_no_conflict_check( 'taxonomy' );
if ( ! is_array( $term_data ) || empty( $term_data ) ) {
$term_data = array( 'name' => '' );
}
if ( ! $conflicted ) {
pods_no_conflict_on( 'taxonomy' );
}
if ( ! is_array( $term_meta ) ) {
$term_meta = array();
}
if ( $sanitized ) {
$term_data = pods_unsanitize( $term_data );
$term_meta = pods_unsanitize( $term_meta );
}
$taxonomy = $term_data['taxonomy'];
unset( $term_data['taxonomy'] );
if ( empty( $term_data['term_id'] ) ) {
$term_name = $term_data['name'];
unset( $term_data['name'] );
$term_data['term_id'] = wp_insert_term( $term_name, $taxonomy, $term_data );
} elseif ( 1 < count( $term_data ) ) {
$term_data['term_id'] = wp_update_term( $term_data['term_id'], $taxonomy, $term_data );
}
if ( is_wp_error( $term_data['term_id'] ) ) {
if ( ! $conflicted ) {
pods_no_conflict_off( 'taxonomy' );
}
/**
* @var $term_error WP_Error
*/
$term_error = $term_data['term_id'];
return pods_error( $term_error->get_error_message(), $this );
} elseif ( is_array( $term_data['term_id'] ) ) {
$term_data['term_id'] = $term_data['term_id']['term_id'];
}
$this->save_term_meta( $term_data['term_id'], $term_meta, $strict, $fields );
if ( ! $conflicted ) {
pods_no_conflict_off( 'taxonomy' );
}
return $term_data['term_id'];
} | [
"public",
"function",
"save_term",
"(",
"$",
"term_data",
",",
"$",
"term_meta",
",",
"$",
"strict",
"=",
"false",
",",
"$",
"sanitized",
"=",
"false",
",",
"$",
"fields",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"term_data",
... | Save a taxonomy's term
@param array $term_data All term data to be saved (using wp_insert_term / wp_update_term)
@param array $term_meta All meta to be saved (set value to null to delete)
@param bool $strict (optional) Whether to delete previously saved meta not in $post_meta
@param bool $sanitized (optional) Will unsanitize the data, should be passed if the data is sanitized before
sending.
@param array $fields (optional) The array of fields and their options, for further processing with
@return int Term ID
@since 2.0.0 | [
"Save",
"a",
"taxonomy",
"s",
"term"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsAPI.php#L670-L731 | train |
pods-framework/pods | classes/PodsAPI.php | PodsAPI.save_term_meta | public function save_term_meta( $id, $term_meta = null, $strict = false, $fields = array() ) {
if ( ! function_exists( 'get_term_meta' ) ) {
return $id;
}
$simple_tableless_objects = PodsForm::simple_tableless_objects();
$conflicted = pods_no_conflict_check( 'taxonomy' );
if ( ! $conflicted ) {
pods_no_conflict_on( 'taxonomy' );
}
if ( ! is_array( $term_meta ) ) {
$term_meta = array();
}
$id = (int) $id;
$meta = get_term_meta( $id );
foreach ( $meta as $k => $value ) {
if ( is_array( $value ) && 1 == count( $value ) ) {
$meta[ $k ] = current( $value );
}
}
foreach ( $term_meta as $meta_key => $meta_value ) {
if ( null === $meta_value || ( $strict && '' === $term_meta[ $meta_key ] ) ) {
$old_meta_value = '';
if ( isset( $meta[ $meta_key ] ) ) {
$old_meta_value = $meta[ $meta_key ];
}
delete_term_meta( $id, $meta_key, $old_meta_value );
} else {
$simple = false;
if ( isset( $fields[ $meta_key ] ) ) {
$field_data = $fields[ $meta_key ];
$simple = ( 'pick' === $field_data['type'] && in_array( pods_var( 'pick_object', $field_data ), $simple_tableless_objects ) );
}
if ( $simple ) {
delete_term_meta( $id, $meta_key );
update_term_meta( $id, '_pods_' . $meta_key, $meta_value );
if ( ! is_array( $meta_value ) ) {
$meta_value = array( $meta_value );
}
foreach ( $meta_value as $value ) {
add_term_meta( $id, $meta_key, $value );
}
} else {
update_term_meta( $id, $meta_key, $meta_value );
}
}
}
if ( $strict ) {
foreach ( $meta as $meta_key => $meta_value ) {
if ( ! isset( $term_meta[ $meta_key ] ) ) {
delete_term_meta( $id, $meta_key, $meta_value );
}
}
}
if ( ! $conflicted ) {
pods_no_conflict_off( 'taxonomy' );
}
return $id;
} | php | public function save_term_meta( $id, $term_meta = null, $strict = false, $fields = array() ) {
if ( ! function_exists( 'get_term_meta' ) ) {
return $id;
}
$simple_tableless_objects = PodsForm::simple_tableless_objects();
$conflicted = pods_no_conflict_check( 'taxonomy' );
if ( ! $conflicted ) {
pods_no_conflict_on( 'taxonomy' );
}
if ( ! is_array( $term_meta ) ) {
$term_meta = array();
}
$id = (int) $id;
$meta = get_term_meta( $id );
foreach ( $meta as $k => $value ) {
if ( is_array( $value ) && 1 == count( $value ) ) {
$meta[ $k ] = current( $value );
}
}
foreach ( $term_meta as $meta_key => $meta_value ) {
if ( null === $meta_value || ( $strict && '' === $term_meta[ $meta_key ] ) ) {
$old_meta_value = '';
if ( isset( $meta[ $meta_key ] ) ) {
$old_meta_value = $meta[ $meta_key ];
}
delete_term_meta( $id, $meta_key, $old_meta_value );
} else {
$simple = false;
if ( isset( $fields[ $meta_key ] ) ) {
$field_data = $fields[ $meta_key ];
$simple = ( 'pick' === $field_data['type'] && in_array( pods_var( 'pick_object', $field_data ), $simple_tableless_objects ) );
}
if ( $simple ) {
delete_term_meta( $id, $meta_key );
update_term_meta( $id, '_pods_' . $meta_key, $meta_value );
if ( ! is_array( $meta_value ) ) {
$meta_value = array( $meta_value );
}
foreach ( $meta_value as $value ) {
add_term_meta( $id, $meta_key, $value );
}
} else {
update_term_meta( $id, $meta_key, $meta_value );
}
}
}
if ( $strict ) {
foreach ( $meta as $meta_key => $meta_value ) {
if ( ! isset( $term_meta[ $meta_key ] ) ) {
delete_term_meta( $id, $meta_key, $meta_value );
}
}
}
if ( ! $conflicted ) {
pods_no_conflict_off( 'taxonomy' );
}
return $id;
} | [
"public",
"function",
"save_term_meta",
"(",
"$",
"id",
",",
"$",
"term_meta",
"=",
"null",
",",
"$",
"strict",
"=",
"false",
",",
"$",
"fields",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"function_exists",
"(",
"'get_term_meta'",
")",
")",
"... | Save a term's meta
@param int $id Term ID
@param array $term_meta All meta to be saved (set value to null to delete)
@param bool $strict Whether to delete previously saved meta not in $term_meta
@param array $fields (optional) The array of fields and their options, for further processing with
@return int Id of the term with the meta
@since 2.0.0 | [
"Save",
"a",
"term",
"s",
"meta"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsAPI.php#L745-L822 | train |
pods-framework/pods | classes/PodsAPI.php | PodsAPI.save_setting | public function save_setting( $setting, $option_data, $sanitized = false ) {
if ( ! is_array( $option_data ) || empty( $option_data ) ) {
return pods_error( __( 'Setting data is required but is either invalid or empty', 'pods' ), $this );
}
$conflicted = pods_no_conflict_check( 'settings' );
if ( ! $conflicted ) {
pods_no_conflict_on( 'settings' );
}
if ( $sanitized ) {
$option_data = pods_unsanitize( $option_data );
}
foreach ( $option_data as $option => $value ) {
if ( ! empty( $setting ) ) {
$option = $setting . '_' . $option;
}
update_option( $option, $value );
}
if ( ! $conflicted ) {
pods_no_conflict_off( 'settings' );
}
return true;
} | php | public function save_setting( $setting, $option_data, $sanitized = false ) {
if ( ! is_array( $option_data ) || empty( $option_data ) ) {
return pods_error( __( 'Setting data is required but is either invalid or empty', 'pods' ), $this );
}
$conflicted = pods_no_conflict_check( 'settings' );
if ( ! $conflicted ) {
pods_no_conflict_on( 'settings' );
}
if ( $sanitized ) {
$option_data = pods_unsanitize( $option_data );
}
foreach ( $option_data as $option => $value ) {
if ( ! empty( $setting ) ) {
$option = $setting . '_' . $option;
}
update_option( $option, $value );
}
if ( ! $conflicted ) {
pods_no_conflict_off( 'settings' );
}
return true;
} | [
"public",
"function",
"save_setting",
"(",
"$",
"setting",
",",
"$",
"option_data",
",",
"$",
"sanitized",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"option_data",
")",
"||",
"empty",
"(",
"$",
"option_data",
")",
")",
"{",
"return"... | Save a set of options
@param string $setting Setting group name
@param array $option_data All option data to be saved
@param bool $sanitized (optional) Will unsanitize the data, should be passed if the data is sanitized before
sending.
@return bool
@since 2.3.0 | [
"Save",
"a",
"set",
"of",
"options"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsAPI.php#L836-L865 | train |
pods-framework/pods | classes/PodsAPI.php | PodsAPI.rename_wp_object_type | public function rename_wp_object_type( $object_type, $old_name, $new_name ) {
/**
* @var $wpdb wpdb
*/
global $wpdb;
if ( 'post_type' === $object_type ) {
$object_type = 'post';
}
if ( 'post' === $object_type ) {
pods_query( "UPDATE `{$wpdb->posts}` SET `post_type` = %s WHERE `post_type` = %s", array(
$new_name,
$old_name
) );
} elseif ( 'taxonomy' === $object_type ) {
pods_query( "UPDATE `{$wpdb->term_taxonomy}` SET `taxonomy` = %s WHERE `taxonomy` = %s", array(
$new_name,
$old_name
) );
} elseif ( 'comment' === $object_type ) {
pods_query( "UPDATE `{$wpdb->comments}` SET `comment_type` = %s WHERE `comment_type` = %s", array(
$new_name,
$old_name
) );
} elseif ( 'settings' === $object_type ) {
pods_query( "UPDATE `{$wpdb->options}` SET `option_name` = REPLACE( `option_name`, %s, %s ) WHERE `option_name` LIKE '" . pods_sanitize_like( $old_name ) . "_%'", array(
$new_name . '_',
$old_name . '_'
) );
}
return true;
} | php | public function rename_wp_object_type( $object_type, $old_name, $new_name ) {
/**
* @var $wpdb wpdb
*/
global $wpdb;
if ( 'post_type' === $object_type ) {
$object_type = 'post';
}
if ( 'post' === $object_type ) {
pods_query( "UPDATE `{$wpdb->posts}` SET `post_type` = %s WHERE `post_type` = %s", array(
$new_name,
$old_name
) );
} elseif ( 'taxonomy' === $object_type ) {
pods_query( "UPDATE `{$wpdb->term_taxonomy}` SET `taxonomy` = %s WHERE `taxonomy` = %s", array(
$new_name,
$old_name
) );
} elseif ( 'comment' === $object_type ) {
pods_query( "UPDATE `{$wpdb->comments}` SET `comment_type` = %s WHERE `comment_type` = %s", array(
$new_name,
$old_name
) );
} elseif ( 'settings' === $object_type ) {
pods_query( "UPDATE `{$wpdb->options}` SET `option_name` = REPLACE( `option_name`, %s, %s ) WHERE `option_name` LIKE '" . pods_sanitize_like( $old_name ) . "_%'", array(
$new_name . '_',
$old_name . '_'
) );
}
return true;
} | [
"public",
"function",
"rename_wp_object_type",
"(",
"$",
"object_type",
",",
"$",
"old_name",
",",
"$",
"new_name",
")",
"{",
"/**\n\t\t * @var $wpdb wpdb\n\t\t */",
"global",
"$",
"wpdb",
";",
"if",
"(",
"'post_type'",
"===",
"$",
"object_type",
")",
"{",
"$",
... | Rename a WP object's type
@param string $object_type Object type: post|taxonomy|comment|setting
@param string $old_name The old name
@param string $new_name The new name
@return bool
@since 2.0.0 | [
"Rename",
"a",
"WP",
"object",
"s",
"type"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsAPI.php#L878-L912 | train |
pods-framework/pods | classes/PodsAPI.php | PodsAPI.handle_changed_fields | public static function handle_changed_fields( $pod, $id, $mode = 'set' ) {
static $changed_pods_cache = array();
static $old_fields_cache = array();
static $changed_fields_cache = array();
$cache_key = $pod . '|' . $id;
$export_params = array(
'depth' => 1,
);
if ( in_array( $mode, array( 'set', 'reset' ), true ) ) {
if ( isset( $changed_fields_cache[ $cache_key ] ) ) {
unset( $changed_fields_cache[ $cache_key ] );
}
if ( empty( $old_fields_cache[ $cache_key ] ) || 'reset' === $mode ) {
$old_fields_cache[ $cache_key ] = array();
if ( ! empty( $id ) ) {
if ( ! isset( $changed_pods_cache[ $pod ] ) ) {
$changed_pods_cache[ $pod ] = pods( $pod );
}
if ( $changed_pods_cache[ $pod ] && $changed_pods_cache[ $pod ]->valid() ) {
$changed_pods_cache[ $pod ]->fetch( $id );
$old_fields_cache[ $cache_key ] = $changed_pods_cache[ $pod ]->export( $export_params );
}
}
}
}
$changed_fields = array();
if ( isset( $changed_fields_cache[ $cache_key ] ) ) {
$changed_fields = $changed_fields_cache[ $cache_key ];
} elseif ( isset( $old_fields_cache[ $cache_key ] ) ) {
$old_fields = $old_fields_cache[ $cache_key ];
if ( 'get' === $mode ) {
$changed_fields_cache[ $cache_key ] = array();
if ( ! empty( $changed_pods_cache[ $pod ] ) ) {
if ( $id != $changed_pods_cache[ $pod ]->id() ) {
$changed_pods_cache[ $pod ]->fetch( $id );
}
$new_fields = $changed_pods_cache[ $pod ]->export( $export_params );
foreach ( $new_fields as $field => $value ) {
if ( ! isset( $old_fields[ $field ] ) || $value != $old_fields[ $field ] ) {
$changed_fields[ $field ] = $value;
}
}
$changed_fields_cache[ $cache_key ] = $changed_fields;
}
}
}
return $changed_fields;
} | php | public static function handle_changed_fields( $pod, $id, $mode = 'set' ) {
static $changed_pods_cache = array();
static $old_fields_cache = array();
static $changed_fields_cache = array();
$cache_key = $pod . '|' . $id;
$export_params = array(
'depth' => 1,
);
if ( in_array( $mode, array( 'set', 'reset' ), true ) ) {
if ( isset( $changed_fields_cache[ $cache_key ] ) ) {
unset( $changed_fields_cache[ $cache_key ] );
}
if ( empty( $old_fields_cache[ $cache_key ] ) || 'reset' === $mode ) {
$old_fields_cache[ $cache_key ] = array();
if ( ! empty( $id ) ) {
if ( ! isset( $changed_pods_cache[ $pod ] ) ) {
$changed_pods_cache[ $pod ] = pods( $pod );
}
if ( $changed_pods_cache[ $pod ] && $changed_pods_cache[ $pod ]->valid() ) {
$changed_pods_cache[ $pod ]->fetch( $id );
$old_fields_cache[ $cache_key ] = $changed_pods_cache[ $pod ]->export( $export_params );
}
}
}
}
$changed_fields = array();
if ( isset( $changed_fields_cache[ $cache_key ] ) ) {
$changed_fields = $changed_fields_cache[ $cache_key ];
} elseif ( isset( $old_fields_cache[ $cache_key ] ) ) {
$old_fields = $old_fields_cache[ $cache_key ];
if ( 'get' === $mode ) {
$changed_fields_cache[ $cache_key ] = array();
if ( ! empty( $changed_pods_cache[ $pod ] ) ) {
if ( $id != $changed_pods_cache[ $pod ]->id() ) {
$changed_pods_cache[ $pod ]->fetch( $id );
}
$new_fields = $changed_pods_cache[ $pod ]->export( $export_params );
foreach ( $new_fields as $field => $value ) {
if ( ! isset( $old_fields[ $field ] ) || $value != $old_fields[ $field ] ) {
$changed_fields[ $field ] = $value;
}
}
$changed_fields_cache[ $cache_key ] = $changed_fields;
}
}
}
return $changed_fields;
} | [
"public",
"static",
"function",
"handle_changed_fields",
"(",
"$",
"pod",
",",
"$",
"id",
",",
"$",
"mode",
"=",
"'set'",
")",
"{",
"static",
"$",
"changed_pods_cache",
"=",
"array",
"(",
")",
";",
"static",
"$",
"old_fields_cache",
"=",
"array",
"(",
")... | Handle tracking changed fields or get them.
@since 2.7.0
@param string $pod
@param int $id
@param string $mode
@return array List of changed fields (if $mode = 'get') | [
"Handle",
"tracking",
"changed",
"fields",
"or",
"get",
"them",
"."
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsAPI.php#L4216-L4280 | train |
pods-framework/pods | classes/PodsAPI.php | PodsAPI.duplicate_pod | public function duplicate_pod( $params, $strict = false ) {
if ( ! is_object( $params ) && ! is_array( $params ) ) {
if ( is_numeric( $params ) ) {
$params = array( 'id' => $params );
} else {
$params = array( 'name' => $params );
}
$params = (object) pods_sanitize( $params );
} else {
$params = (object) pods_sanitize( $params );
}
$params->table_info = false;
$pod = $this->load_pod( $params, $strict );
if ( empty( $pod ) ) {
if ( false !== $strict ) {
return pods_error( __( 'Pod not found', 'pods' ), $this );
}
return false;
} elseif ( in_array( $pod['type'], array( 'media', 'user', 'comment' ) ) ) {
if ( false !== $strict ) {
return pods_error( __( 'Pod not allowed to be duplicated', 'pods' ), $this );
}
return false;
} elseif ( in_array( $pod['type'], array( 'post_type', 'taxonomy' ) ) && 0 < strlen( $pod['object'] ) ) {
$pod['object'] = '';
}
unset( $pod['id'] );
if ( isset( $params->new_name ) ) {
$pod['name'] = $params->new_name;
}
$try = 1;
$check_name = $pod['name'];
$new_label = $pod['label'];
while ( $this->load_pod( array( 'name' => $check_name, 'table_info' => false ), false ) ) {
$try ++;
$check_name = $pod['name'] . $try;
$new_label = $pod['label'] . $try;
}
$pod['name'] = $check_name;
$pod['label'] = $new_label;
foreach ( $pod['fields'] as $field => $field_data ) {
unset( $pod['fields'][ $field ]['id'] );
}
return $this->save_pod( $pod );
} | php | public function duplicate_pod( $params, $strict = false ) {
if ( ! is_object( $params ) && ! is_array( $params ) ) {
if ( is_numeric( $params ) ) {
$params = array( 'id' => $params );
} else {
$params = array( 'name' => $params );
}
$params = (object) pods_sanitize( $params );
} else {
$params = (object) pods_sanitize( $params );
}
$params->table_info = false;
$pod = $this->load_pod( $params, $strict );
if ( empty( $pod ) ) {
if ( false !== $strict ) {
return pods_error( __( 'Pod not found', 'pods' ), $this );
}
return false;
} elseif ( in_array( $pod['type'], array( 'media', 'user', 'comment' ) ) ) {
if ( false !== $strict ) {
return pods_error( __( 'Pod not allowed to be duplicated', 'pods' ), $this );
}
return false;
} elseif ( in_array( $pod['type'], array( 'post_type', 'taxonomy' ) ) && 0 < strlen( $pod['object'] ) ) {
$pod['object'] = '';
}
unset( $pod['id'] );
if ( isset( $params->new_name ) ) {
$pod['name'] = $params->new_name;
}
$try = 1;
$check_name = $pod['name'];
$new_label = $pod['label'];
while ( $this->load_pod( array( 'name' => $check_name, 'table_info' => false ), false ) ) {
$try ++;
$check_name = $pod['name'] . $try;
$new_label = $pod['label'] . $try;
}
$pod['name'] = $check_name;
$pod['label'] = $new_label;
foreach ( $pod['fields'] as $field => $field_data ) {
unset( $pod['fields'][ $field ]['id'] );
}
return $this->save_pod( $pod );
} | [
"public",
"function",
"duplicate_pod",
"(",
"$",
"params",
",",
"$",
"strict",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"is_object",
"(",
"$",
"params",
")",
"&&",
"!",
"is_array",
"(",
"$",
"params",
")",
")",
"{",
"if",
"(",
"is_numeric",
"(",
"$"... | Duplicate a Pod
$params['id'] int The Pod ID
$params['name'] string The Pod name
$params['new_name'] string The new Pod name
@param array $params An associative array of parameters
@param bool $strict (optional) Makes sure a pod exists, if it doesn't throws an error
@return int New Pod ID
@since 2.3.0 | [
"Duplicate",
"a",
"Pod"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsAPI.php#L4455-L4515 | train |
pods-framework/pods | classes/PodsAPI.php | PodsAPI.duplicate_field | public function duplicate_field( $params, $strict = false ) {
if ( ! is_object( $params ) && ! is_array( $params ) ) {
if ( is_numeric( $params ) ) {
$params = array( 'id' => $params );
} else {
$params = array( 'name' => $params );
}
}
$params = (object) pods_sanitize( $params );
$params->table_info = false;
$field = $this->load_field( $params, $strict );
if ( empty( $field ) ) {
if ( false !== $strict ) {
return pods_error( __( 'Field not found', 'pods' ), $this );
}
return false;
}
unset( $field['id'] );
if ( isset( $params->new_name ) ) {
$field['name'] = $params->new_name;
}
$try = 1;
$check_name = $field['name'];
$new_label = $field['label'];
while ( $this->load_field( array(
'pod_id' => $field['pod_id'],
'name' => $check_name,
'table_info' => false
), false ) ) {
$try ++;
$check_name = $field['name'] . $try;
$new_label = $field['label'] . $try;
}
$field['name'] = $check_name;
$field['label'] = $new_label;
return $this->save_field( $field );
} | php | public function duplicate_field( $params, $strict = false ) {
if ( ! is_object( $params ) && ! is_array( $params ) ) {
if ( is_numeric( $params ) ) {
$params = array( 'id' => $params );
} else {
$params = array( 'name' => $params );
}
}
$params = (object) pods_sanitize( $params );
$params->table_info = false;
$field = $this->load_field( $params, $strict );
if ( empty( $field ) ) {
if ( false !== $strict ) {
return pods_error( __( 'Field not found', 'pods' ), $this );
}
return false;
}
unset( $field['id'] );
if ( isset( $params->new_name ) ) {
$field['name'] = $params->new_name;
}
$try = 1;
$check_name = $field['name'];
$new_label = $field['label'];
while ( $this->load_field( array(
'pod_id' => $field['pod_id'],
'name' => $check_name,
'table_info' => false
), false ) ) {
$try ++;
$check_name = $field['name'] . $try;
$new_label = $field['label'] . $try;
}
$field['name'] = $check_name;
$field['label'] = $new_label;
return $this->save_field( $field );
} | [
"public",
"function",
"duplicate_field",
"(",
"$",
"params",
",",
"$",
"strict",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"is_object",
"(",
"$",
"params",
")",
"&&",
"!",
"is_array",
"(",
"$",
"params",
")",
")",
"{",
"if",
"(",
"is_numeric",
"(",
"... | Duplicate a Field
$params['pod_id'] int The Pod ID
$params['pod'] string The Pod name
$params['id'] int The Field ID
$params['name'] string The Field name
$params['new_name'] string The new Field name
@param array $params An associative array of parameters
@param bool $strict (optional) Makes sure a field exists, if it doesn't throws an error
@return int New Field ID
@since 2.3.10 | [
"Duplicate",
"a",
"Field"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsAPI.php#L4532-L4583 | train |
pods-framework/pods | classes/PodsAPI.php | PodsAPI.reorder_pod_item | public function reorder_pod_item( $params ) {
$params = (object) pods_sanitize( $params );
// @deprecated 2.0.0
if ( isset( $params->datatype ) ) {
pods_deprecated( __( '$params->pod instead of $params->datatype', 'pods' ), '2.0' );
$params->pod = $params->datatype;
unset( $params->datatype );
}
if ( null === pods_var_raw( 'pod', $params, null, null, true ) ) {
return pods_error( __( '$params->pod is required', 'pods' ), $this );
}
if ( ! is_array( $params->order ) ) {
$params->order = explode( ',', $params->order );
}
$pod = $this->load_pod( array( 'name' => $params->pod, 'table_info' => true ) );
$params->name = $pod['name'];
if ( false === $pod ) {
return pods_error( __( 'Pod is required', 'pods' ), $this );
}
foreach ( $params->order as $order => $id ) {
if ( isset( $pod['fields'][ $params->field ] ) || isset( $pod['object_fields'][ $params->field ] ) ) {
if ( 'table' === $pod['storage'] && ( ! pods_tableless() ) ) {
if ( isset( $pod['fields'][ $params->field ] ) ) {
pods_query( "UPDATE `@wp_pods_{$params->name}` SET `{$params->field}` = " . pods_absint( $order ) . " WHERE `id` = " . pods_absint( $id ) . " LIMIT 1" );
} else {
pods_query( "UPDATE `{$pod['table']}` SET `{$params->field}` = " . pods_absint( $order ) . " WHERE `{$pod['field_id']}` = " . pods_absint( $id ) . " LIMIT 1" );
}
} else {
$this->save_pod_item( array(
'pod' => $params->pod,
'pod_id' => $params->pod_id,
'id' => $id,
'data' => array( $params->field => pods_absint( $order ) )
) );
}
}
}
return true;
} | php | public function reorder_pod_item( $params ) {
$params = (object) pods_sanitize( $params );
// @deprecated 2.0.0
if ( isset( $params->datatype ) ) {
pods_deprecated( __( '$params->pod instead of $params->datatype', 'pods' ), '2.0' );
$params->pod = $params->datatype;
unset( $params->datatype );
}
if ( null === pods_var_raw( 'pod', $params, null, null, true ) ) {
return pods_error( __( '$params->pod is required', 'pods' ), $this );
}
if ( ! is_array( $params->order ) ) {
$params->order = explode( ',', $params->order );
}
$pod = $this->load_pod( array( 'name' => $params->pod, 'table_info' => true ) );
$params->name = $pod['name'];
if ( false === $pod ) {
return pods_error( __( 'Pod is required', 'pods' ), $this );
}
foreach ( $params->order as $order => $id ) {
if ( isset( $pod['fields'][ $params->field ] ) || isset( $pod['object_fields'][ $params->field ] ) ) {
if ( 'table' === $pod['storage'] && ( ! pods_tableless() ) ) {
if ( isset( $pod['fields'][ $params->field ] ) ) {
pods_query( "UPDATE `@wp_pods_{$params->name}` SET `{$params->field}` = " . pods_absint( $order ) . " WHERE `id` = " . pods_absint( $id ) . " LIMIT 1" );
} else {
pods_query( "UPDATE `{$pod['table']}` SET `{$params->field}` = " . pods_absint( $order ) . " WHERE `{$pod['field_id']}` = " . pods_absint( $id ) . " LIMIT 1" );
}
} else {
$this->save_pod_item( array(
'pod' => $params->pod,
'pod_id' => $params->pod_id,
'id' => $id,
'data' => array( $params->field => pods_absint( $order ) )
) );
}
}
}
return true;
} | [
"public",
"function",
"reorder_pod_item",
"(",
"$",
"params",
")",
"{",
"$",
"params",
"=",
"(",
"object",
")",
"pods_sanitize",
"(",
"$",
"params",
")",
";",
"// @deprecated 2.0.0",
"if",
"(",
"isset",
"(",
"$",
"params",
"->",
"datatype",
")",
")",
"{"... | Reorder a Pod
$params['pod'] string The Pod name
$params['field'] string The field name of the field to reorder
$params['order'] array The key => value array of items to reorder (key should be an integer)
@param array $params An associative array of parameters
@return bool
@since 1.9.0 | [
"Reorder",
"a",
"Pod"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsAPI.php#L4951-L5000 | train |
pods-framework/pods | classes/PodsAPI.php | PodsAPI.delete_pod | public function delete_pod( $params, $strict = false, $delete_all = false ) {
/**
* @var $wpdb wpdb
*/
global $wpdb;
if ( ! is_object( $params ) && ! is_array( $params ) ) {
if ( is_numeric( $params ) ) {
$params = array( 'id' => $params );
} else {
$params = array( 'name' => $params );
}
$params = (object) pods_sanitize( $params );
} else {
$params = (object) pods_sanitize( $params );
}
if ( ! isset( $params->delete_all ) ) {
$params->delete_all = $delete_all;
}
$params->table_info = false;
$pod = $this->load_pod( $params, $strict );
if ( empty( $pod ) ) {
if ( false !== $strict ) {
return pods_error( __( 'Pod not found', 'pods' ), $this );
}
return false;
}
$params->id = (int) $pod['id'];
$params->name = $pod['name'];
// Reset content
if ( true === $params->delete_all ) {
$this->reset_pod( $params, $pod );
}
foreach ( $pod['fields'] as $field ) {
$field['pod'] = $pod;
$this->delete_field( $field, false );
}
// Only delete the post once the fields are taken care of, it's not required anymore
$success = wp_delete_post( $params->id );
if ( ! $success ) {
return pods_error( __( 'Pod unable to be deleted', 'pods' ), $this );
}
if ( ! pods_tableless() ) {
if ( 'table' === $pod['storage'] ) {
try {
pods_query( "DROP TABLE IF EXISTS `@wp_pods_{$params->name}`", false );
} catch ( Exception $e ) {
// Allow pod to be deleted if the table doesn't exist
if ( false === strpos( $e->getMessage(), 'Unknown table' ) ) {
return pods_error( $e->getMessage(), $this );
}
}
}
pods_query( "DELETE FROM `@wp_podsrel` WHERE `pod_id` = {$params->id} OR `related_pod_id` = {$params->id}", false );
}
// @todo Delete relationships from tableless relationships
// Delete any relationship references
$sql = "
DELETE `pm`
FROM `{$wpdb->postmeta}` AS `pm`
LEFT JOIN `{$wpdb->posts}` AS `p`
ON `p`.`post_type` = '_pods_field'
AND `p`.`ID` = `pm`.`post_id`
LEFT JOIN `{$wpdb->postmeta}` AS `pm2`
ON `pm2`.`meta_key` = 'pick_object'
AND `pm2`.`meta_value` = 'pod'
AND `pm2`.`post_id` = `pm`.`post_id`
WHERE
`p`.`ID` IS NOT NULL
AND `pm2`.`meta_id` IS NOT NULL
AND `pm`.`meta_key` = 'pick_val'
AND `pm`.`meta_value` = '{$params->name}'
";
pods_query( $sql );
$this->cache_flush_pods( $pod );
return true;
} | php | public function delete_pod( $params, $strict = false, $delete_all = false ) {
/**
* @var $wpdb wpdb
*/
global $wpdb;
if ( ! is_object( $params ) && ! is_array( $params ) ) {
if ( is_numeric( $params ) ) {
$params = array( 'id' => $params );
} else {
$params = array( 'name' => $params );
}
$params = (object) pods_sanitize( $params );
} else {
$params = (object) pods_sanitize( $params );
}
if ( ! isset( $params->delete_all ) ) {
$params->delete_all = $delete_all;
}
$params->table_info = false;
$pod = $this->load_pod( $params, $strict );
if ( empty( $pod ) ) {
if ( false !== $strict ) {
return pods_error( __( 'Pod not found', 'pods' ), $this );
}
return false;
}
$params->id = (int) $pod['id'];
$params->name = $pod['name'];
// Reset content
if ( true === $params->delete_all ) {
$this->reset_pod( $params, $pod );
}
foreach ( $pod['fields'] as $field ) {
$field['pod'] = $pod;
$this->delete_field( $field, false );
}
// Only delete the post once the fields are taken care of, it's not required anymore
$success = wp_delete_post( $params->id );
if ( ! $success ) {
return pods_error( __( 'Pod unable to be deleted', 'pods' ), $this );
}
if ( ! pods_tableless() ) {
if ( 'table' === $pod['storage'] ) {
try {
pods_query( "DROP TABLE IF EXISTS `@wp_pods_{$params->name}`", false );
} catch ( Exception $e ) {
// Allow pod to be deleted if the table doesn't exist
if ( false === strpos( $e->getMessage(), 'Unknown table' ) ) {
return pods_error( $e->getMessage(), $this );
}
}
}
pods_query( "DELETE FROM `@wp_podsrel` WHERE `pod_id` = {$params->id} OR `related_pod_id` = {$params->id}", false );
}
// @todo Delete relationships from tableless relationships
// Delete any relationship references
$sql = "
DELETE `pm`
FROM `{$wpdb->postmeta}` AS `pm`
LEFT JOIN `{$wpdb->posts}` AS `p`
ON `p`.`post_type` = '_pods_field'
AND `p`.`ID` = `pm`.`post_id`
LEFT JOIN `{$wpdb->postmeta}` AS `pm2`
ON `pm2`.`meta_key` = 'pick_object'
AND `pm2`.`meta_value` = 'pod'
AND `pm2`.`post_id` = `pm`.`post_id`
WHERE
`p`.`ID` IS NOT NULL
AND `pm2`.`meta_id` IS NOT NULL
AND `pm`.`meta_key` = 'pick_val'
AND `pm`.`meta_value` = '{$params->name}'
";
pods_query( $sql );
$this->cache_flush_pods( $pod );
return true;
} | [
"public",
"function",
"delete_pod",
"(",
"$",
"params",
",",
"$",
"strict",
"=",
"false",
",",
"$",
"delete_all",
"=",
"false",
")",
"{",
"/**\n\t\t * @var $wpdb wpdb\n\t\t */",
"global",
"$",
"wpdb",
";",
"if",
"(",
"!",
"is_object",
"(",
"$",
"params",
"... | Delete a Pod and all its content
$params['id'] int The Pod ID
$params['name'] string The Pod name
@param array $params An associative array of parameters
@param bool $strict (optional) Makes sure a pod exists, if it doesn't throws an error
@param bool $delete_all (optional) Whether to delete all content from a WP object
@uses PodsAPI::load_pod
@uses wp_delete_post
@uses pods_query
@return bool
@since 1.7.9 | [
"Delete",
"a",
"Pod",
"and",
"all",
"its",
"content"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsAPI.php#L5139-L5235 | train |
pods-framework/pods | classes/PodsAPI.php | PodsAPI.delete_object | public function delete_object( $params ) {
$params = (object) $params;
$object = $this->load_object( $params );
if ( empty( $object ) ) {
return pods_error( sprintf( __( "%s Object not found", 'pods' ), ucwords( $params->type ) ), $this );
}
$success = wp_delete_post( $params->id );
if ( ! $success ) {
return pods_error( sprintf( __( "%s Object not deleted", 'pods' ), ucwords( $params->type ) ), $this );
}
pods_transient_clear( 'pods_objects_' . $params->type );
return true;
} | php | public function delete_object( $params ) {
$params = (object) $params;
$object = $this->load_object( $params );
if ( empty( $object ) ) {
return pods_error( sprintf( __( "%s Object not found", 'pods' ), ucwords( $params->type ) ), $this );
}
$success = wp_delete_post( $params->id );
if ( ! $success ) {
return pods_error( sprintf( __( "%s Object not deleted", 'pods' ), ucwords( $params->type ) ), $this );
}
pods_transient_clear( 'pods_objects_' . $params->type );
return true;
} | [
"public",
"function",
"delete_object",
"(",
"$",
"params",
")",
"{",
"$",
"params",
"=",
"(",
"object",
")",
"$",
"params",
";",
"$",
"object",
"=",
"$",
"this",
"->",
"load_object",
"(",
"$",
"params",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"obje... | Drop a Pod Object
$params['id'] int The object ID
$params['name'] string The object name
$params['type'] string The object type
@param array|object $params An associative array of parameters
@uses wp_delete_post
@return bool
@since 2.0.0 | [
"Drop",
"a",
"Pod",
"Object"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsAPI.php#L5359-L5377 | train |
pods-framework/pods | classes/PodsAPI.php | PodsAPI.delete_object_from_relationships | public function delete_object_from_relationships( $id, $object, $name = null ) {
/**
* @var $pods_init \PodsInit
*/
global $pods_init;
$pod = false;
// Run any bidirectional delete operations
if ( is_array( $object ) ) {
$pod = $object;
} elseif ( is_object( $pods_init ) ) {
$pod = PodsInit::$meta->get_object( $object, $name );
}
if ( ! empty( $pod ) ) {
$object = $pod['type'];
$name = $pod['name'];
foreach ( $pod['fields'] as $field ) {
PodsForm::delete( $field['type'], $id, $field['name'], array_merge( $field, $field['options'] ), $pod );
}
}
// Lookup related fields (non-bidirectional)
$params = array(
'where' => array(
array(
'key' => 'type',
'value' => 'pick'
),
array(
'key' => 'pick_object',
'value' => $object
)
)
);
if ( ! empty( $name ) && $name !== $object ) {
$params['where'][] = array(
'key' => 'pick_val',
'value' => $name
);
}
$fields = $this->load_fields( $params, false );
if ( ! empty( $pod ) && 'media' === $pod['type'] ) {
$params['where'] = array(
array(
'key' => 'type',
'value' => 'file'
)
);
$fields = array_merge( $fields, $this->load_fields( $params, false ) );
}
if ( is_array( $fields ) && ! empty( $fields ) ) {
foreach ( $fields as $related_field ) {
$related_pod = $this->load_pod( array( 'id' => $related_field['pod_id'], 'fields' => false ), false );
if ( empty( $related_pod ) ) {
continue;
}
$related_from = $this->lookup_related_items_from( $related_field['id'], $related_pod['id'], $id, $related_field, $related_pod );
$this->delete_relationships( $related_from, $id, $related_pod, $related_field );
}
}
if ( ! empty( $pod ) && ! pods_tableless() ) {
pods_query( "
DELETE FROM `@wp_podsrel`
WHERE
(
`pod_id` = %d
AND `item_id` = %d
)
OR (
`related_pod_id` = %d
AND `related_item_id` = %d
)
", array(
$pod['id'],
$id,
$pod['id'],
$id
) );
}
return true;
} | php | public function delete_object_from_relationships( $id, $object, $name = null ) {
/**
* @var $pods_init \PodsInit
*/
global $pods_init;
$pod = false;
// Run any bidirectional delete operations
if ( is_array( $object ) ) {
$pod = $object;
} elseif ( is_object( $pods_init ) ) {
$pod = PodsInit::$meta->get_object( $object, $name );
}
if ( ! empty( $pod ) ) {
$object = $pod['type'];
$name = $pod['name'];
foreach ( $pod['fields'] as $field ) {
PodsForm::delete( $field['type'], $id, $field['name'], array_merge( $field, $field['options'] ), $pod );
}
}
// Lookup related fields (non-bidirectional)
$params = array(
'where' => array(
array(
'key' => 'type',
'value' => 'pick'
),
array(
'key' => 'pick_object',
'value' => $object
)
)
);
if ( ! empty( $name ) && $name !== $object ) {
$params['where'][] = array(
'key' => 'pick_val',
'value' => $name
);
}
$fields = $this->load_fields( $params, false );
if ( ! empty( $pod ) && 'media' === $pod['type'] ) {
$params['where'] = array(
array(
'key' => 'type',
'value' => 'file'
)
);
$fields = array_merge( $fields, $this->load_fields( $params, false ) );
}
if ( is_array( $fields ) && ! empty( $fields ) ) {
foreach ( $fields as $related_field ) {
$related_pod = $this->load_pod( array( 'id' => $related_field['pod_id'], 'fields' => false ), false );
if ( empty( $related_pod ) ) {
continue;
}
$related_from = $this->lookup_related_items_from( $related_field['id'], $related_pod['id'], $id, $related_field, $related_pod );
$this->delete_relationships( $related_from, $id, $related_pod, $related_field );
}
}
if ( ! empty( $pod ) && ! pods_tableless() ) {
pods_query( "
DELETE FROM `@wp_podsrel`
WHERE
(
`pod_id` = %d
AND `item_id` = %d
)
OR (
`related_pod_id` = %d
AND `related_item_id` = %d
)
", array(
$pod['id'],
$id,
$pod['id'],
$id
) );
}
return true;
} | [
"public",
"function",
"delete_object_from_relationships",
"(",
"$",
"id",
",",
"$",
"object",
",",
"$",
"name",
"=",
"null",
")",
"{",
"/**\n\t\t * @var $pods_init \\PodsInit\n\t\t */",
"global",
"$",
"pods_init",
";",
"$",
"pod",
"=",
"false",
";",
"// Run any bi... | Delete an object from tableless fields
@param int $id
@param string $type
@param string $name
@return bool
@since 2.3.0 | [
"Delete",
"an",
"object",
"from",
"tableless",
"fields"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsAPI.php#L5616-L5711 | train |
pods-framework/pods | classes/PodsAPI.php | PodsAPI.pod_exists | public function pod_exists( $params, $type = null ) {
if ( is_string( $params ) ) {
$params = array( 'name' => $params );
}
$params = (object) pods_sanitize( $params );
if ( ! empty( $params->id ) || ! empty( $params->name ) ) {
if ( ! isset( $params->name ) ) {
$dummy = (int) $params->id;
$pod = get_post( $dummy );
} else {
$pod = get_posts( array(
'name' => $params->name,
'post_type' => '_pods_pod',
'posts_per_page' => 1
) );
if ( is_array( $pod ) && ! empty( $pod[0] ) ) {
$pod = $pod[0];
}
}
if ( ! empty( $pod ) && ( empty( $type ) || $type == get_post_meta( $pod->ID, 'type', true ) ) ) {
return true;
}
}
return false;
} | php | public function pod_exists( $params, $type = null ) {
if ( is_string( $params ) ) {
$params = array( 'name' => $params );
}
$params = (object) pods_sanitize( $params );
if ( ! empty( $params->id ) || ! empty( $params->name ) ) {
if ( ! isset( $params->name ) ) {
$dummy = (int) $params->id;
$pod = get_post( $dummy );
} else {
$pod = get_posts( array(
'name' => $params->name,
'post_type' => '_pods_pod',
'posts_per_page' => 1
) );
if ( is_array( $pod ) && ! empty( $pod[0] ) ) {
$pod = $pod[0];
}
}
if ( ! empty( $pod ) && ( empty( $type ) || $type == get_post_meta( $pod->ID, 'type', true ) ) ) {
return true;
}
}
return false;
} | [
"public",
"function",
"pod_exists",
"(",
"$",
"params",
",",
"$",
"type",
"=",
"null",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"params",
")",
")",
"{",
"$",
"params",
"=",
"array",
"(",
"'name'",
"=>",
"$",
"params",
")",
";",
"}",
"$",
"para... | Check if a Pod exists
$params['id'] int Pod ID
$params['name'] string Pod name
@param array $params An associative array of parameters
@return bool True if exists
@since 1.12 | [
"Check",
"if",
"a",
"Pod",
"exists"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsAPI.php#L5848-L5878 | train |
pods-framework/pods | classes/PodsAPI.php | PodsAPI.get_pod_type_count | public function get_pod_type_count( $type ) {
$args = array(
'post_type' => '_pods_pod',
'posts_per_page' => - 1,
'nopaging' => true,
'fields' => 'ids',
'meta_query' => array(
array(
'key' => 'type',
'value' => $type,
),
),
);
$posts = get_posts( $args );
$total = count( $posts );
return $total;
} | php | public function get_pod_type_count( $type ) {
$args = array(
'post_type' => '_pods_pod',
'posts_per_page' => - 1,
'nopaging' => true,
'fields' => 'ids',
'meta_query' => array(
array(
'key' => 'type',
'value' => $type,
),
),
);
$posts = get_posts( $args );
$total = count( $posts );
return $total;
} | [
"public",
"function",
"get_pod_type_count",
"(",
"$",
"type",
")",
"{",
"$",
"args",
"=",
"array",
"(",
"'post_type'",
"=>",
"'_pods_pod'",
",",
"'posts_per_page'",
"=>",
"-",
"1",
",",
"'nopaging'",
"=>",
"true",
",",
"'fields'",
"=>",
"'ids'",
",",
"'met... | Get number of pods for a specific pod type
@param string $type Type to get count
@return int Total number of pods for a type
@since 2.6.6 | [
"Get",
"number",
"of",
"pods",
"for",
"a",
"specific",
"pod",
"type"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsAPI.php#L5889-L5910 | train |
pods-framework/pods | classes/PodsAPI.php | PodsAPI.field_exists | public function field_exists( $params ) {
$params = (object) pods_sanitize( $params );
if ( ( ! empty( $params->id ) || ! empty( $params->name ) ) && isset( $params->pod_id ) && ! empty( $params->pod_id ) ) {
if ( ! isset( $params->name ) ) {
$dummy = (int) $params->id;
$field = get_post( $dummy );
} else {
$field = get_posts( array(
'name' => $params->name,
'post_type' => '_pods_field',
'posts_per_page' => 1,
'post_parent' => $params->pod_id
) );
}
if ( ! empty( $field ) ) {
return true;
}
}
return false;
} | php | public function field_exists( $params ) {
$params = (object) pods_sanitize( $params );
if ( ( ! empty( $params->id ) || ! empty( $params->name ) ) && isset( $params->pod_id ) && ! empty( $params->pod_id ) ) {
if ( ! isset( $params->name ) ) {
$dummy = (int) $params->id;
$field = get_post( $dummy );
} else {
$field = get_posts( array(
'name' => $params->name,
'post_type' => '_pods_field',
'posts_per_page' => 1,
'post_parent' => $params->pod_id
) );
}
if ( ! empty( $field ) ) {
return true;
}
}
return false;
} | [
"public",
"function",
"field_exists",
"(",
"$",
"params",
")",
"{",
"$",
"params",
"=",
"(",
"object",
")",
"pods_sanitize",
"(",
"$",
"params",
")",
";",
"if",
"(",
"(",
"!",
"empty",
"(",
"$",
"params",
"->",
"id",
")",
"||",
"!",
"empty",
"(",
... | Check if a Pod's field exists
$params['pod_id'] int The Pod ID
$params['id'] int The field ID
$params['name'] string The field name
@param array $params An associative array of parameters
@return bool
@since 1.12 | [
"Check",
"if",
"a",
"Pod",
"s",
"field",
"exists"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsAPI.php#L6570-L6593 | train |
pods-framework/pods | classes/PodsAPI.php | PodsAPI.load_object | public function load_object( $params, $strict = false ) {
if ( is_object( $params ) && isset( $params->post_title ) ) {
$_object = get_object_vars( $params );
} else {
$params = (object) pods_sanitize( $params );
if ( ! isset( $params->type ) || empty( $params->type ) ) {
return pods_error( __( 'Object type is required', 'pods' ), $this );
}
if ( ( ! isset( $params->id ) || empty( $params->id ) ) && ( ! isset( $params->name ) || empty( $params->name ) ) ) {
return pods_error( __( 'Either Object ID or Name are required', 'pods' ), $this );
}
/**
* @var $wpdb wpdb
*/
global $wpdb;
if ( isset( $params->name ) ) {
$_object = pods_by_title( $params->name, ARRAY_A, '_pods_' . $params->type, 'publish' );
} else {
$object = $params->id;
$_object = get_post( $object, ARRAY_A );
}
if ( empty( $_object ) ) {
if ( $strict ) {
return pods_error( __( 'Object not found', 'pods' ), $this );
}
return false;
}
}
$object = array(
'id' => $_object['ID'],
'name' => $_object['post_title'],
'code' => $_object['post_content'],
'type' => str_replace( '_pods_', '', $_object['post_type'] ),
'slug' => $_object['post_name']
);
$object['options'] = get_post_meta( $object['id'] );
foreach ( $object['options'] as $option => &$value ) {
if ( is_array( $value ) && 1 == count( $value ) ) {
$value = current( $value );
}
}
return $object;
} | php | public function load_object( $params, $strict = false ) {
if ( is_object( $params ) && isset( $params->post_title ) ) {
$_object = get_object_vars( $params );
} else {
$params = (object) pods_sanitize( $params );
if ( ! isset( $params->type ) || empty( $params->type ) ) {
return pods_error( __( 'Object type is required', 'pods' ), $this );
}
if ( ( ! isset( $params->id ) || empty( $params->id ) ) && ( ! isset( $params->name ) || empty( $params->name ) ) ) {
return pods_error( __( 'Either Object ID or Name are required', 'pods' ), $this );
}
/**
* @var $wpdb wpdb
*/
global $wpdb;
if ( isset( $params->name ) ) {
$_object = pods_by_title( $params->name, ARRAY_A, '_pods_' . $params->type, 'publish' );
} else {
$object = $params->id;
$_object = get_post( $object, ARRAY_A );
}
if ( empty( $_object ) ) {
if ( $strict ) {
return pods_error( __( 'Object not found', 'pods' ), $this );
}
return false;
}
}
$object = array(
'id' => $_object['ID'],
'name' => $_object['post_title'],
'code' => $_object['post_content'],
'type' => str_replace( '_pods_', '', $_object['post_type'] ),
'slug' => $_object['post_name']
);
$object['options'] = get_post_meta( $object['id'] );
foreach ( $object['options'] as $option => &$value ) {
if ( is_array( $value ) && 1 == count( $value ) ) {
$value = current( $value );
}
}
return $object;
} | [
"public",
"function",
"load_object",
"(",
"$",
"params",
",",
"$",
"strict",
"=",
"false",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"params",
")",
"&&",
"isset",
"(",
"$",
"params",
"->",
"post_title",
")",
")",
"{",
"$",
"_object",
"=",
"get_obje... | Load a Pods Object
$params['id'] int The Object ID
$params['name'] string The Object name
$params['type'] string The Object type
@param array|object $params An associative array of parameters
@param bool $strict
@return array|bool
@since 2.0.0 | [
"Load",
"a",
"Pods",
"Object"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsAPI.php#L7049-L7103 | train |
pods-framework/pods | classes/PodsAPI.php | PodsAPI.load_pod_item | public function load_pod_item( $params ) {
$params = (object) pods_sanitize( $params );
if ( ! isset( $params->pod ) || empty( $params->pod ) ) {
return pods_error( __( 'Pod name required', 'pods' ), $this );
}
if ( ! isset( $params->id ) || empty( $params->id ) ) {
return pods_error( __( 'Item ID required', 'pods' ), $this );
}
$pod = false;
if ( pods_api_cache() ) {
$pod = pods_cache_get( $params->id, 'pods_item_object_' . $params->pod );
}
if ( false !== $pod ) {
return $pod;
}
$pod = pods( $params->pod, $params->id );
if ( pods_api_cache() ) {
pods_cache_set( $params->id, $pod, 'pods_item_object_' . $params->pod );
}
return $pod;
} | php | public function load_pod_item( $params ) {
$params = (object) pods_sanitize( $params );
if ( ! isset( $params->pod ) || empty( $params->pod ) ) {
return pods_error( __( 'Pod name required', 'pods' ), $this );
}
if ( ! isset( $params->id ) || empty( $params->id ) ) {
return pods_error( __( 'Item ID required', 'pods' ), $this );
}
$pod = false;
if ( pods_api_cache() ) {
$pod = pods_cache_get( $params->id, 'pods_item_object_' . $params->pod );
}
if ( false !== $pod ) {
return $pod;
}
$pod = pods( $params->pod, $params->id );
if ( pods_api_cache() ) {
pods_cache_set( $params->id, $pod, 'pods_item_object_' . $params->pod );
}
return $pod;
} | [
"public",
"function",
"load_pod_item",
"(",
"$",
"params",
")",
"{",
"$",
"params",
"=",
"(",
"object",
")",
"pods_sanitize",
"(",
"$",
"params",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"params",
"->",
"pod",
")",
"||",
"empty",
"(",
"$",
"par... | Load the pod item object
$params['pod'] string The datatype name
$params['id'] int (optional) The item's ID
@param array $params An associative array of parameters
@return bool|\Pods
@uses pods()
@since 2.0.0 | [
"Load",
"the",
"pod",
"item",
"object"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsAPI.php#L7405-L7433 | train |
pods-framework/pods | classes/PodsAPI.php | PodsAPI.load_sister_fields | public function load_sister_fields( $params, $pod = null ) {
$params = (object) pods_sanitize( $params );
if ( empty( $pod ) ) {
$pod = $this->load_pod( array( 'name' => $params->pod, 'table_info' => false ), false );
if ( false === $pod ) {
return pods_error( __( 'Pod not found', 'pods' ), $this );
}
}
$params->pod_id = $pod['id'];
$params->pod = $pod['name'];
$type = false;
if ( 0 === strpos( $params->related_pod, 'pod-' ) ) {
$params->related_pod = pods_str_replace( 'pod-', '', $params->related_pod, 1 );
$type = 'pod';
} elseif ( 0 === strpos( $params->related_pod, 'post_type-' ) ) {
$params->related_pod = pods_str_replace( 'post_type-', '', $params->related_pod, 1 );
$type = 'post_type';
} elseif ( 0 === strpos( $params->related_pod, 'taxonomy-' ) ) {
$params->related_pod = pods_str_replace( 'taxonomy-', '', $params->related_pod, 1 );
$type = 'taxonomy';
} elseif ( 'comment' === $params->related_pod ) {
$type = $params->related_pod;
}
$related_pod = $this->load_pod( array( 'name' => $params->related_pod, 'table_info' => false ), false );
if ( false === $related_pod || ( false !== $type && 'pod' !== $type && $type !== $related_pod['type'] ) ) {
return pods_error( __( 'Related Pod not found', 'pods' ), $this );
}
$params->related_pod_id = $related_pod['id'];
$params->related_pod = $related_pod['name'];
$sister_fields = array();
foreach ( $related_pod['fields'] as $field ) {
if ( 'pick' === $field['type'] && in_array( $field['pick_object'], array(
$pod['type'],
'pod'
) ) && ( $params->pod == $field['pick_object'] || $params->pod == $field['pick_val'] ) ) {
$sister_fields[ $field['id'] ] = esc_html( $field['label'] . ' (' . $field['name'] . ')' );
}
}
return $sister_fields;
} | php | public function load_sister_fields( $params, $pod = null ) {
$params = (object) pods_sanitize( $params );
if ( empty( $pod ) ) {
$pod = $this->load_pod( array( 'name' => $params->pod, 'table_info' => false ), false );
if ( false === $pod ) {
return pods_error( __( 'Pod not found', 'pods' ), $this );
}
}
$params->pod_id = $pod['id'];
$params->pod = $pod['name'];
$type = false;
if ( 0 === strpos( $params->related_pod, 'pod-' ) ) {
$params->related_pod = pods_str_replace( 'pod-', '', $params->related_pod, 1 );
$type = 'pod';
} elseif ( 0 === strpos( $params->related_pod, 'post_type-' ) ) {
$params->related_pod = pods_str_replace( 'post_type-', '', $params->related_pod, 1 );
$type = 'post_type';
} elseif ( 0 === strpos( $params->related_pod, 'taxonomy-' ) ) {
$params->related_pod = pods_str_replace( 'taxonomy-', '', $params->related_pod, 1 );
$type = 'taxonomy';
} elseif ( 'comment' === $params->related_pod ) {
$type = $params->related_pod;
}
$related_pod = $this->load_pod( array( 'name' => $params->related_pod, 'table_info' => false ), false );
if ( false === $related_pod || ( false !== $type && 'pod' !== $type && $type !== $related_pod['type'] ) ) {
return pods_error( __( 'Related Pod not found', 'pods' ), $this );
}
$params->related_pod_id = $related_pod['id'];
$params->related_pod = $related_pod['name'];
$sister_fields = array();
foreach ( $related_pod['fields'] as $field ) {
if ( 'pick' === $field['type'] && in_array( $field['pick_object'], array(
$pod['type'],
'pod'
) ) && ( $params->pod == $field['pick_object'] || $params->pod == $field['pick_val'] ) ) {
$sister_fields[ $field['id'] ] = esc_html( $field['label'] . ' (' . $field['name'] . ')' );
}
}
return $sister_fields;
} | [
"public",
"function",
"load_sister_fields",
"(",
"$",
"params",
",",
"$",
"pod",
"=",
"null",
")",
"{",
"$",
"params",
"=",
"(",
"object",
")",
"pods_sanitize",
"(",
"$",
"params",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"pod",
")",
")",
"{",
"$",
... | Load potential sister fields for a specific field
$params['pod'] int The Pod name
$params['related_pod'] string The related Pod name
@param array $params An associative array of parameters
@param array $pod (optional) Array of Pod data to use (to avoid lookup)
@return array|bool
@since 1.7.9
@uses PodsAPI::load_pod | [
"Load",
"potential",
"sister",
"fields",
"for",
"a",
"specific",
"field"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsAPI.php#L7450-L7501 | train |
pods-framework/pods | classes/PodsAPI.php | PodsAPI.detect_pod_field_from_sql_data_type | public static function detect_pod_field_from_sql_data_type( $sql_field ) {
$sql_field = strtolower( $sql_field );
$field_to_field_map = array(
'tinyint' => 'number',
'smallint' => 'number',
'mediumint' => 'number',
'int' => 'number',
'bigint' => 'number',
'float' => 'number',
'double' => 'number',
'decimal' => 'number',
'date' => 'date',
'datetime' => 'datetime',
'timestamp' => 'datetime',
'time' => 'time',
'year' => 'date',
'varchar' => 'text',
'text' => 'paragraph',
'mediumtext' => 'paragraph',
'longtext' => 'paragraph'
);
return ( array_key_exists( $sql_field, $field_to_field_map ) ) ? $field_to_field_map[ $sql_field ] : 'paragraph';
} | php | public static function detect_pod_field_from_sql_data_type( $sql_field ) {
$sql_field = strtolower( $sql_field );
$field_to_field_map = array(
'tinyint' => 'number',
'smallint' => 'number',
'mediumint' => 'number',
'int' => 'number',
'bigint' => 'number',
'float' => 'number',
'double' => 'number',
'decimal' => 'number',
'date' => 'date',
'datetime' => 'datetime',
'timestamp' => 'datetime',
'time' => 'time',
'year' => 'date',
'varchar' => 'text',
'text' => 'paragraph',
'mediumtext' => 'paragraph',
'longtext' => 'paragraph'
);
return ( array_key_exists( $sql_field, $field_to_field_map ) ) ? $field_to_field_map[ $sql_field ] : 'paragraph';
} | [
"public",
"static",
"function",
"detect_pod_field_from_sql_data_type",
"(",
"$",
"sql_field",
")",
"{",
"$",
"sql_field",
"=",
"strtolower",
"(",
"$",
"sql_field",
")",
";",
"$",
"field_to_field_map",
"=",
"array",
"(",
"'tinyint'",
"=>",
"'number'",
",",
"'smal... | Takes a sql field such as tinyint and returns the pods field type, such as num.
@param string $sql_field The SQL field to look for
@return string The field type
@since 2.0.0 | [
"Takes",
"a",
"sql",
"field",
"such",
"as",
"tinyint",
"and",
"returns",
"the",
"pods",
"field",
"type",
"such",
"as",
"num",
"."
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsAPI.php#L7512-L7537 | train |
pods-framework/pods | classes/PodsAPI.php | PodsAPI.get_field_definition | private function get_field_definition( $type, $options = null ) {
$definition = PodsForm::field_method( $type, 'schema', $options );
return $this->do_hook( 'field_definition', $definition, $type, $options );
} | php | private function get_field_definition( $type, $options = null ) {
$definition = PodsForm::field_method( $type, 'schema', $options );
return $this->do_hook( 'field_definition', $definition, $type, $options );
} | [
"private",
"function",
"get_field_definition",
"(",
"$",
"type",
",",
"$",
"options",
"=",
"null",
")",
"{",
"$",
"definition",
"=",
"PodsForm",
"::",
"field_method",
"(",
"$",
"type",
",",
"'schema'",
",",
"$",
"options",
")",
";",
"return",
"$",
"this"... | Gets the schema definition of a field.
@param string $type Field type to look for
@param array $options (optional) Options of the field to pass to the schema function.
@return array|bool|mixed|null
@since 2.0.0 | [
"Gets",
"the",
"schema",
"definition",
"of",
"a",
"field",
"."
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsAPI.php#L7564-L7569 | train |
pods-framework/pods | classes/PodsAPI.php | PodsAPI.import_package | public function import_package( $data = false, $replace = false ) {
if ( class_exists( 'Pods_Migrate_Packages' ) ) {
return Pods_Migrate_Packages::import( $data, $replace );
}
return false;
} | php | public function import_package( $data = false, $replace = false ) {
if ( class_exists( 'Pods_Migrate_Packages' ) ) {
return Pods_Migrate_Packages::import( $data, $replace );
}
return false;
} | [
"public",
"function",
"import_package",
"(",
"$",
"data",
"=",
"false",
",",
"$",
"replace",
"=",
"false",
")",
"{",
"if",
"(",
"class_exists",
"(",
"'Pods_Migrate_Packages'",
")",
")",
"{",
"return",
"Pods_Migrate_Packages",
"::",
"import",
"(",
"$",
"data"... | Import a package
@param mixed $data (optional) An associative array containing a package, or the json encoded package
@param bool $replace (optional) Replace existing items when found
@return bool
@since 1.9.0
@deprecated 2.0.0 | [
"Import",
"a",
"package"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsAPI.php#L8747-L8754 | train |
pods-framework/pods | classes/PodsAPI.php | PodsAPI.export | public function export( $pod = null, $params = null ) {
if ( empty( $pod ) ) {
$pod = $this->pod;
}
$find = array(
'limit' => - 1,
'search' => false,
'pagination' => false
);
if ( ! empty( $params ) && isset( $params['params'] ) ) {
$find = array_merge( $find, (array) $params['params'] );
unset( $params['params'] );
$pod = pods( $pod, $find );
} elseif ( ! is_object( $pod ) ) {
$pod = pods( $pod, $find );
}
$data = array();
while ( $pod->fetch() ) {
$data[ $pod->id() ] = $this->export_pod_item( $params, $pod );
}
$data = $this->do_hook( 'export', $data, $pod->pod, $pod );
return $data;
} | php | public function export( $pod = null, $params = null ) {
if ( empty( $pod ) ) {
$pod = $this->pod;
}
$find = array(
'limit' => - 1,
'search' => false,
'pagination' => false
);
if ( ! empty( $params ) && isset( $params['params'] ) ) {
$find = array_merge( $find, (array) $params['params'] );
unset( $params['params'] );
$pod = pods( $pod, $find );
} elseif ( ! is_object( $pod ) ) {
$pod = pods( $pod, $find );
}
$data = array();
while ( $pod->fetch() ) {
$data[ $pod->id() ] = $this->export_pod_item( $params, $pod );
}
$data = $this->do_hook( 'export', $data, $pod->pod, $pod );
return $data;
} | [
"public",
"function",
"export",
"(",
"$",
"pod",
"=",
"null",
",",
"$",
"params",
"=",
"null",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"pod",
")",
")",
"{",
"$",
"pod",
"=",
"$",
"this",
"->",
"pod",
";",
"}",
"$",
"find",
"=",
"array",
"(",
... | Export data from a Pod
@param string|object $pod The pod name or Pods object
@param array $params An associative array of parameters
@return array Data arrays of all exported pod items
@since 1.7.1 | [
"Export",
"data",
"from",
"a",
"Pod"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsAPI.php#L8972-L9003 | train |
pods-framework/pods | classes/PodsAPI.php | PodsAPI.csv_to_php | public function csv_to_php( $data, $delimiter = ',' ) {
pods_deprecated( "PodsAPI->csv_to_php", '2.3.5' );
$data = pods_migrate( 'sv', $delimiter, $data )->parse();
return $data['items'];
} | php | public function csv_to_php( $data, $delimiter = ',' ) {
pods_deprecated( "PodsAPI->csv_to_php", '2.3.5' );
$data = pods_migrate( 'sv', $delimiter, $data )->parse();
return $data['items'];
} | [
"public",
"function",
"csv_to_php",
"(",
"$",
"data",
",",
"$",
"delimiter",
"=",
"','",
")",
"{",
"pods_deprecated",
"(",
"\"PodsAPI->csv_to_php\"",
",",
"'2.3.5'",
")",
";",
"$",
"data",
"=",
"pods_migrate",
"(",
"'sv'",
",",
"$",
"delimiter",
",",
"$",
... | Convert CSV to a PHP array
@param string $data The CSV input
@return array
@since 1.7.1
@deprecated 2.3.5 | [
"Convert",
"CSV",
"to",
"a",
"PHP",
"array"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsAPI.php#L9015-L9022 | train |
pods-framework/pods | classes/PodsAPI.php | PodsAPI.cache_flush_pods | public function cache_flush_pods( $pod = null ) {
/**
* @var $wpdb wpdb
*/
global $wpdb;
pods_transient_clear( 'pods' );
pods_transient_clear( 'pods_components' );
if ( null !== $pod && is_array( $pod ) ) {
pods_transient_clear( 'pods_pod_' . $pod['name'] );
pods_cache_clear( $pod['name'], 'pods-class' );
foreach ( $pod['fields'] as $field ) {
pods_transient_clear( 'pods_field_' . $pod['name'] . '_' . $field['name'] );
}
if ( in_array( $pod['type'], array( 'post_type', 'taxonomy' ) ) ) {
pods_transient_clear( 'pods_wp_cpt_ct' );
}
} else {
pods_transient_clear( 'pods_wp_cpt_ct' );
}
// Delete transients in the database
$wpdb->query( "DELETE FROM `{$wpdb->options}` WHERE `option_name` LIKE '_transient_pods%'" );
$wpdb->query( "DELETE FROM `{$wpdb->options}` WHERE `option_name` LIKE '_transient_timeout_pods%'" );
// Delete Pods Options Cache in the database
$wpdb->query( "DELETE FROM `{$wpdb->options}` WHERE `option_name` LIKE '_pods_option_%'" );
pods_cache_clear( true );
pods_transient_set( 'pods_flush_rewrites', 1 );
do_action( 'pods_cache_flushed' );
} | php | public function cache_flush_pods( $pod = null ) {
/**
* @var $wpdb wpdb
*/
global $wpdb;
pods_transient_clear( 'pods' );
pods_transient_clear( 'pods_components' );
if ( null !== $pod && is_array( $pod ) ) {
pods_transient_clear( 'pods_pod_' . $pod['name'] );
pods_cache_clear( $pod['name'], 'pods-class' );
foreach ( $pod['fields'] as $field ) {
pods_transient_clear( 'pods_field_' . $pod['name'] . '_' . $field['name'] );
}
if ( in_array( $pod['type'], array( 'post_type', 'taxonomy' ) ) ) {
pods_transient_clear( 'pods_wp_cpt_ct' );
}
} else {
pods_transient_clear( 'pods_wp_cpt_ct' );
}
// Delete transients in the database
$wpdb->query( "DELETE FROM `{$wpdb->options}` WHERE `option_name` LIKE '_transient_pods%'" );
$wpdb->query( "DELETE FROM `{$wpdb->options}` WHERE `option_name` LIKE '_transient_timeout_pods%'" );
// Delete Pods Options Cache in the database
$wpdb->query( "DELETE FROM `{$wpdb->options}` WHERE `option_name` LIKE '_pods_option_%'" );
pods_cache_clear( true );
pods_transient_set( 'pods_flush_rewrites', 1 );
do_action( 'pods_cache_flushed' );
} | [
"public",
"function",
"cache_flush_pods",
"(",
"$",
"pod",
"=",
"null",
")",
"{",
"/**\n\t\t * @var $wpdb wpdb\n\t\t */",
"global",
"$",
"wpdb",
";",
"pods_transient_clear",
"(",
"'pods'",
")",
";",
"pods_transient_clear",
"(",
"'pods_components'",
")",
";",
"if",
... | Clear Pod-related cache
@param array $pod
@return void
@since 2.0.0 | [
"Clear",
"Pod",
"-",
"related",
"cache"
] | fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c | https://github.com/pods-framework/pods/blob/fd9a07c5c81ccbfcb21c5a0b2166f96c31d0826c/classes/PodsAPI.php#L9033-L9070 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.