Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/release/2.7' into f…
Browse files Browse the repository at this point in the history
…eature/#3967
  • Loading branch information
JoryHogeveen committed Mar 10, 2017
2 parents 971cc30 + 8ab52d1 commit 5674a37
Show file tree
Hide file tree
Showing 13 changed files with 279 additions and 160 deletions.
6 changes: 3 additions & 3 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ module.exports = function ( grunt ) {
pkg: grunt.file.readJSON( 'package.json' ),

exec: {
dfv_rollup_dev : 'node_modules/rollup/bin/rollup -c ui/js/pods-dfv/_src/rollup.config.dev.js',
dfv_rollup_prod: 'node_modules/rollup/bin/rollup -c ui/js/pods-dfv/_src/rollup.config.prod.js',
dfv_test : 'node_modules/mocha/bin/mocha --compilers js:babel-core/register --reporter dot --recursive tests/js'
dfv_rollup_dev : 'node node_modules/rollup/bin/rollup -c ui/js/pods-dfv/_src/rollup.config.dev.js',
dfv_rollup_prod: 'node node_modules/rollup/bin/rollup -c ui/js/pods-dfv/_src/rollup.config.prod.js',
dfv_test : 'node node_modules/mocha/bin/mocha --compilers js:babel-core/register --reporter dot --recursive tests/js'
},

clean: {
Expand Down
4 changes: 4 additions & 0 deletions classes/PodsAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -5324,6 +5324,10 @@ public function pod_exists ( $params, $type = null ) {
'post_type' => '_pods_pod',
'posts_per_page' => 1
) );

if ( is_array( $pod ) ) {
$pod = $pod[0];
}
}

if ( !empty( $pod ) && ( empty( $type ) || $type == get_post_meta( $pod->ID, 'type', true ) ) )
Expand Down
24 changes: 12 additions & 12 deletions classes/PodsAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -1604,11 +1604,11 @@ public function admin_setup_edit_options ( $pod ) {
'depends-on' => array( 'show_ui' => true ),
'data' => array(
'default' => __( 'Default - Add to associated Post Type(s) menus', 'pods' ),
'settings' => __( 'Add to Settings menu', 'pods' ),
'appearances' => __( 'Add to Appearances menu', 'pods' ),
'objects' => __( 'Make a top-level menu item', 'pods' ),
'top' => __( 'Make a new top-level menu item below Settings', 'pods' ),
'submenu' => __( 'Add a submenu item to another menu', 'pods' )
'settings' => __( 'Add a submenu item to Settings menu', 'pods' ),
'appearances' => __( 'Add a submenu item to Appearances menu', 'pods' ),
'submenu' => __( 'Add a submenu item to another menu', 'pods' ),
'objects' => __( 'Make a new menu item', 'pods' ),
'top' => __( 'Make a new menu item below Settings', 'pods' )
),
'dependency' => true
),
Expand Down Expand Up @@ -1835,10 +1835,10 @@ public function admin_setup_edit_options ( $pod ) {
'type' => 'pick',
'default' => 'settings',
'data' => array(
'settings' => __( 'Add to Settings menu', 'pods' ),
'appearances' => __( 'Add to Appearances menu', 'pods' ),
'top' => __( 'Make a new top-level menu item below Settings', 'pods' ),
'submenu' => __( 'Add a submenu item to another menu', 'pods' )
'settings' => __( 'Add a submenu item to Settings menu', 'pods' ),
'appearances' => __( 'Add a submenu item to Appearances menu', 'pods' ),
'submenu' => __( 'Add a submenu item to another menu', 'pods' ),
'top' => __( 'Make a new menu item below Settings', 'pods' )
),
'dependency' => true
),
Expand Down Expand Up @@ -2452,7 +2452,7 @@ public function admin_components () {
$meta = array();

if ( !empty( $component_data[ 'Version' ] ) )
$meta[] = 'Version ' . $component_data[ 'Version' ];
$meta[] = sprintf( __( 'Version %s', 'pods' ), $component_data[ 'Version' ] );

if ( empty( $component_data[ 'Author' ] ) ) {
$component_data[ 'Author' ] = 'Pods Framework Team';
Expand Down Expand Up @@ -2498,8 +2498,8 @@ public function admin_components () {
'data' => $components,
'total' => count( $components ),
'total_found' => count( $components ),
'items' => 'Components',
'item' => 'Component',
'items' => __( 'Components', 'pods' ),
'item' => __( 'Component', 'pods' ),
'fields' => array(
'manage' => array(
'name' => array(
Expand Down
111 changes: 76 additions & 35 deletions classes/fields/pick.php
Original file line number Diff line number Diff line change
Expand Up @@ -849,34 +849,52 @@ public function build_dfv_field_config( $args ) {
// Set the file name and args based on the content type of the relationship
switch ( $args->options['pick_object'] ) {
case 'post_type':
$file_name = 'post-new.php';
$query_args = array(
'post_type' => $args->options['pick_val'],
);
// @todo Access rights for add new
if ( ! empty( $args->options['pick_val'] ) ) {
$post_type_obj = get_post_type_object( $args->options['pick_val'] );

if ( $post_type_obj && current_user_can( $post_type_obj->cap->create_posts ) ) {
$file_name = 'post-new.php';
$query_args = array(
'post_type' => $args->options['pick_val'],
);
}
}

break;

case 'taxonomy':
$file_name = 'edit-tags.php';
$query_args = array(
'taxonomy' => $args->options['pick_val'],
);
// @todo Access rights for add new
if ( ! empty( $args->options['pick_val'] ) ) {
$taxonomy_obj = get_taxonomy( $args->options['pick_val'] );

if ( $taxonomy_obj && current_user_can( $taxonomy_obj->cap->edit_terms ) ) {
$file_name = 'edit-tags.php';
$query_args = array(
'taxonomy' => $args->options['pick_val'],
);
}
}

break;

case 'user':
$file_name = 'user-new.php';
$query_args = array();
// @todo Access rights for add new
if ( current_user_can( 'create_users' ) ) {
$file_name = 'user-new.php';
}

break;

case 'pod':
$file_name = 'admin.php';
$query_args = array(
'page' => 'pods-manage-' . $args->options['pick_val'],
'action' => 'add',
);
// @todo Access rights for add new
if ( ! empty( $args->options['pick_val'] ) ) {
if ( pods_is_admin( array( 'pods', 'pods_content', 'pods_edit_' . $args->options['pick_val'] ) ) ) {
$file_name = 'admin.php';
$query_args = array(
'page' => 'pods-manage-' . $args->options['pick_val'],
'action' => 'add',
);

}
}

break;
}

Expand Down Expand Up @@ -977,7 +995,9 @@ public function build_dfv_field_item_data_recurse_item( $item_id, $item_title, $

switch ( $args->options['pick_object'] ) {
case 'post_type':
if ( null === $args->options['supports_thumbnails'] ) {
$item_id = (int) $item_id;

if ( null === $args->options['supports_thumbnails'] && ! empty( $args->options['pick_val'] ) ) {
$args->options['supports_thumbnails'] = post_type_supports( $args->options['pick_val'], 'thumbnail' );
}

Expand All @@ -989,46 +1009,67 @@ public function build_dfv_field_item_data_recurse_item( $item_id, $item_title, $
}
}

// @todo Access rights for edit link
$edit_link = get_edit_post_link( $item_id, 'raw' );

$link = get_permalink( $item_id );

break;

case 'taxonomy':
// @todo Access rights for edit link
$edit_link = get_edit_term_link( $item_id, $args->options['pick_val'] );
$item_id = (int) $item_id;

$link = get_term_link( $item_id, $args->options['pick_val'] );
if ( ! empty( $args->options['pick_val'] ) ) {
$edit_link = get_edit_term_link( $item_id, $args->options['pick_val'] );

$link = get_term_link( $item_id, $args->options['pick_val'] );
}

break;

case 'user':
$item_id = (int) $item_id;

$args->options['supports_thumbnails'] = true;

$icon = get_avatar_url( $item_id, array( 'size' => 150 ) );

// @todo Access rights for edit link
$edit_link = get_edit_user_link( $item_id );

$link = get_author_posts_url( $item_id );

break;

case 'comment':
$item_id = (int) $item_id;

$args->options['supports_thumbnails'] = true;

$icon = get_avatar_url( get_comment( $item_id ), array( 'size' => 150 ) );

$edit_link = get_edit_comment_link( $item_id );

$link = get_comment_link( $item_id );

break;

case 'pod':
$file_name = 'admin.php';
$query_args = array(
'page' => 'pods-manage-' . $args->options['pick_val'],
'action' => 'edit',
'id' => $item_id,
);
$item_id = (int) $item_id;

if ( ! empty( $args->options['pick_val'] ) ) {
if ( pods_is_admin( array( 'pods', 'pods_content', 'pods_edit_' . $args->options['pick_val'] ) ) ) {
$file_name = 'admin.php';
$query_args = array(
'page' => 'pods-manage-' . $args->options['pick_val'],
'action' => 'edit',
'id' => $item_id,
);

// @todo Access rights for edit link
$edit_link = add_query_arg( $query_args, admin_url( $file_name ) );
$edit_link = add_query_arg( $query_args, admin_url( $file_name ) );
}

// @todo Add $link support
$link = '';
// @todo Add $link support
$link = '';
}

break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,9 @@ function auto_pods() {
$archive_append = pods_v( 'pfat_append_archive', $pod_data[ 'options' ], true, true );
$single_filter = pods_v( 'pfat_filter_single', $pod_data[ 'options' ], 'the_content', true );
$archive_filter = pods_v( 'pfat_filter_archive', $pod_data[ 'options' ], 'the_content', true );
$run_outside_loop = pods_v( 'pfat_run_outside_loop', $pod_data[ 'options' ], false, true );
$type = pods_v( 'type', $pod_data, false, true );
//check if it's a post type that has an arhive
//check if it's a post type that has an archive
if ( $type === 'post_type' && $the_pod !== 'post' || $the_pod !== 'page' ) {
$has_archive = pods_v( 'has_archive', $pod_data['options'], false, true );
}
Expand All @@ -187,6 +188,7 @@ function auto_pods() {
'has_archive' => $has_archive,
'single_filter' => $single_filter,
'archive_filter' => $archive_filter,
'run_outside_loop' => $run_outside_loop,
'type' => $type,
);
}
Expand Down Expand Up @@ -269,15 +271,18 @@ function front( $content ) {

//check if $current_post_type is the key of the array of possible pods
if ( isset( $possible_pods[ $current_post_type ] ) ) {
//get array for the current post type
$this_pod = $possible_pods[ $current_post_type ];

if ( !in_the_loop() && !pods_v( 'run_outside_loop', $this_pod, false ) ) {
// If outside of the loop, exit quickly
return $content;
}

//build Pods object for current item
global $post;
$pods = pods( $current_post_type, $post->ID );

//get array for the current post type
$this_pod = $possible_pods[ $current_post_type ];


if ( $this_pod[ 'single' ] && is_singular( $current_post_type ) ) {
//load the template
$content = $this->load_template( $this_pod[ 'single' ], $content , $pods, $this_pod[ 'single_append' ] );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,14 @@ function options( $options, $pod ) {
'dependency' => true,
'boolean_yes_label' => ''
),
'pfat_run_outside_loop' => array(
'label' => __( 'Execute Auto Template outside of the WordPress loop? (advanced)', 'pods' ),
'help' => __( 'When enabled, the template will be executed whenever the specified filter is called.', 'pods' ),
'type' => 'boolean',
'default' => false,
'depends-on' => array( 'pfat_enable' => true ),
'boolean_yes_label' => ''
),
'pfat_single' => array(
'label' => __( 'Single item view template', 'pods' ),
'help' => __( 'Name of Pods template to use for single item view.', 'pods' ),
Expand Down Expand Up @@ -170,6 +178,14 @@ function options( $options, $pod ) {
'dependency' => true,
'boolean_yes_label' => ''
),
'pfat_run_outside_loop' => array(
'label' => __( 'Execute Auto Template outside of the WordPress loop? (advanced)', 'pods' ),
'help' => __( 'When enabled, the template will be executed whenever the specified filter is called.', 'pods' ),
'type' => 'boolean',
'default' => false,
'depends-on' => array( 'pfat_enable' => true ),
'boolean_yes_label' => ''
),
'pfat_archive' => array (
'label' => __( 'Taxonomy Template', 'pods' ),
'help' => __( 'Name of Pods template to use for this taxonomy.', 'pods' ),
Expand Down
Loading

0 comments on commit 5674a37

Please sign in to comment.