GithubHelp home page GithubHelp logo

johnbillion / extended-cpts Goto Github PK

View Code? Open in Web Editor NEW
953.0 35.0 97.0 874 KB

A library which provides extended functionality to WordPress custom post types and taxonomies.

License: GNU General Public License v2.0

PHP 100.00%
wordpress custom-post-types custom-taxonomies

extended-cpts's Introduction

extended-cpts's People

Contributors

aaronjorbin avatar carmoreira avatar chrillep avatar claytoncollie avatar danielhomer avatar defunctl avatar ggwicz avatar jazbek avatar joecrescoll avatar johnbillion avatar nlemoine avatar patelutkarsh avatar roygbyte avatar runofthemill avatar simonwheatley avatar spacedmonkey avatar szepeviktor avatar vinkla avatar wanacode avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

extended-cpts's Issues

Transatable label

Actually we can pass the singular and plural form of post type in that way is translatable but is not possible to pass the textdomain to translate the labels like "Add New".
In that way actually for non-english is a problem :-/

Cols : Published return none

Add some custom columns to the admin screen:

'cols' => array(
    'published' => array(
        'title'       => 'Published',
        'meta_key'    => 'published_date',
        'date_format' => 'd/m/Y'
    ),
  ),

I have tried to create a custom column "published date" using the script that you demonstrated but not working, return None

Package license is not valid

Just a little thing, but if you run composer diagnose it will complain about the license: it should be GPL-2.0+

menu_icon

What about menu icon? I can't find this attribute.

Autoload?

Hi!
Thanks for a more cleaner version of extended-cpts!
I miss an autoload to the library as I use the package via Packagist in a WP Roots Bedrock installation.
Or do you have any example to load the lib when going via Composer?

Errors when pretty permalinks aren't enabled

Running Extended CPTs without pretty permalinks enabled results in a bunch of notices, and sometimes a fatal error. They all come from the Extended_CPT_Rewrite_Testing class.

Catchable fatal error: Argument 1 passed to Extended_Rewrite_Testing::get_rewrites() must be of the type array, null given, called in ~/extended-cpts.php on line 2159 and defined in ~/extended-cpts.php on line 2061

Notice: Undefined index: {$post_type} in ~/extended-cpts.php on line 2131

Notice: Undefined index: feeds in ~/extended-cpts.php on line 2148

Notice: Undefined index: pages in ~/extended-cpts.php on line 2153

drag and drop custom post types

How about a feature request? It would be cool if extedded-cpts would provide venue of ordering post types via drag and drop.

Menu Position

Can you leave the menu position to the default NULL? I'm running into issues with the post types being overwritten by plugins.

My thinking is, it would be better to leave 'menu_position' to the default and let the developer choose if to specify the position to avoid conflicts with plugins.

Actually, it might be good to leave all the register_post_type() arguments to the defaults. Except public, having the default as false doesn't make sense.

It just seems unnecessary to have to add extra code just to set the defaults back up.

Select multiple

From @siamkreative on April 27, 2016 9:17

Hi John,

Thanks for the great library, it's extremely useful for developers like me who mainly do front-end stuff.

Explanations

I would like to know if it's possible to somehow add the multiple attribute to the existing select dropdown. It looks like you're using the wp_dropdown_categories function, but I see no option to turn it into a select multiple.

Why am I asking for this?

I prefer to use Select2 or Selectize.js rather the built-in default multiple checkbox thingy, mainly because I want it to be searchable.

image

Cheers

Copied from original issue: johnbillion/extended-taxos#23

composer: type of "wordpress-plugin"

this seems more like a library to me and like other libraries such as TLC Transients. I don't think it should have a type of wordpress-plugin as it causes the files to be installed into a specialized path defined by composer/installers thus making it harder to include this library via composer into plugins that support composer/installers.

Support for custom rewrite tags

I'm banging my head against a wall with custom rewrite tags. In my current situation i'm trying to add a connected CPT slug as a base in another CPT's permalink.

I'm wondering if it's somehow feasible to add a custom rewrite tag to the rewrite permastruct.
Something like:
'rewrite' => array( 'permastruct' => '/%connected_post_slug%/%cpt_slug%', ),

Then just use an additional post_type_link filter to define it. I've been trying this for 2 days now and only sometimes does it partially work, then continues to break for unknown (to me) reasons.

Has archive forced

Regardless of whether I set 'has_archive' to false or not, an archive is still created.

add_action('init', function(){
	register_extended_post_type( 'event',
		[
			'supports' => ['title', 'editor'],
			'public' => true,
			'show_in_admin_bar' => true,
			'show_in_menu' => true,
			'publicly_queryable' => true,
			'has_archive' => false,
			'archive' => false
		]
	);
});

Localization

Hi there,

Could you please let me know if this is translation-ready? If not, could you advise on how to localize it?

Cheers

Advanced options, initial terms, default term, multiple, editable

From @roborourke on May 31, 2017 14:47

Something I've implemented before would be the ability to define a taxonomy like post formats, I don't think it'd be hard to port over so I'll give it a go at some point but let's see what you think of the potential implementation, using regular taxonomy args:

register_taxonomy( 'name', 'post', [
   'terms' => [ 'slug' => 'Name', 'slug2' => 'Name 2' ], // Default terms
   'default' => 'slug', // mimics behaviour of 'Uncategorized'
   'multiple' => false, // Prevents selection of more than one term, sets walker to radio
   'editable' => false, // makes the terms uneditable via the admin, code only - if true forces 'terms' to exist & prevents their removal
] );

Copied from original issue: johnbillion/extended-taxos#30

Custom default sort order is ignored

Example:

register_extended_post_type( 'person', array(
    'site_sortables' => array(
        'test_site_sortables_post_name' => array(
            'post_field' => 'post_name',
            'default'    => 'asc',
        ),
    ),
) );

This should cause the person post type archive to be ordered by post name ascending by default, but the sort order is ignored and defaults to descending.

Custom default sort order in the admin area (via admin_cols) works as expected.

set order_by parameter for admin columns to meta_value_num

We are using this for all out projects. It's awesome. However, we would love the feature to sort set the order_by parameter for admin columns to meta_value_num.

I saw that there is a // @TODO meta_value_num on line 466. But I couldn't solve the problem to make a pull request. We would have to add another parameter to $sortables to make it work right? I couldn't figure out how to do that in the right manner.

P2P admin column error

In the admin column, the following error is displayed instead of my connected 'department' post-type.
Warning: Invalid argument supplied for foreach() in extended-cpts.php on line 1865
I'm doing just the basic registering from the examples for both the extended-post-type and the p2p connection. The front-end display of the connection is working fine..

Expose the CPT objects

There is times where we'd need to remove/add/alter some hooks, so far I've not found a way to catch a CPT object unless I save the reference somewhere on the time of registration, which isn't always the best way of doing that in a pluggable env.

Something along these lines would be useful:

add_filter( 'ext-cpts/{$cpt}/instance', function() use ( $instance ) { return $instance; } );

Admin columns, 'function' argument

So I've found the need to pass arguments to this function, therefore I'd suggest using call_user_func_array instead. Perhaps using is_callable to decide which to use? Anyhow the point is that I'm using namespaces and I'm adding custom admin columns after registering the post types and being able to provide arguments gives higher flexibility!

https://github.com/johnbillion/extended-cpts/blob/master/extended-cpts.php#L1610

Edit: oh I guess the same goes for "filters" and "sortables" but not sure, haven't looked

Edit2: on second though, maybe simply something like

if ( isset( $c[ $col ]['function'] ) ) {
    if ( count( $c[ $col ]['function'] ) > 1 ) {
        call_user_func_array( $c[ $col ]['function'][0], $c[ $col ]['function'][1] );
    }
    else {
        call_user_func( $c[ $col ]['function'] );
    }
} else if ( isset( $c[ $col ]['meta_key'] ) ) {
...

which in turn would mean I can do:

add_filter( 'ext-cpts/my-cpt/args', function( $args ) {
    $args['admin_cols']['my_custom_column'] = array(
        'title'         => __( 'Custom column name', 'textdomain' ),
        'function'      => array( array( __NAMESPACE__ . '\Foo', 'test' ), array( 'something_useful' ) )
    );
    
    return $args;
});

I think.

Fatal Error on Appearance > Menus

I have registered custom post types like so:

function tbc_register_custom_post_types() {

    register_extended_post_type(
        'tbc_treatment',
        array(
            'enter_title_here'  => 'Treatment Name',
            'featured_image'    => 'Treatment Image',
            'rewrite'           => array(
                'permastruct' => '/treatments/%tbc_treatment%'
            ),
            'menu_position'     => 28,
            'menu_icon'         => 'dashicons-universal-access-alt',
            'has_archive'       => true,
        ),
        array(
            'singular' => 'Treatment',
            'plural'   => 'Treatments',
            'slug'     => 'treatments'
        )
    );

    register_extended_post_type(
        'tbc_case_study',
        array(
            'enter_title_here'  => 'Case Study Title',
            'featured_image'    => 'Case Study Image',
            'rewrite'           => array(
                'permastruct' => '/success-story/%tbc_case_study%'
            ),
            'menu_position'     => 27,
            'menu_icon'         => 'dashicons-portfolio',
            'has_archive'       => true,
        ),
        array(
            'singular'  => 'Success Story',
            'plural'    => 'Success Stories',
            'slug'      => 'success-stories'
        )
    );

}

add_action( 'init', 'tbc_register_custom_post_types' );

However when I visit the Appearance > Menus section in the admin I get the following Fatal PHP error:

PHP Catchable fatal error:  Argument 3 passed to Extended_CPT_Admin::nav_menu_items() must be of the type array, object given in /Users/wpmark/local-sites/sitename/content/mu-plugins/extended-cpts.php on line 1957

Any ideas what I have probably done wrong please? Thanks in advance.

Permastructure additions

The permastructure stuff on the Keystone project should be merged into ExtCPTs and/or ExtTaxos.

Handle %postname% in custom permastruct

%postname% can't be used in a custom permastruct, due to the way WordPress constructs sample permalinks. %{post_type}% must be used instead.

Extended CPTs should either raise a doing_it_wrong(), or invisibly convert %postname% to %{post_type}%.

admin_cols meta_key modify displayed value

screen shot 2017-06-07 at 10 03 27 am

screen shot 2017-06-07 at 10 04 20 am

I want following logic:
a. if status = 0 display created
b. if status = 1 display claimed

I want to use callback function as stated in docs, but Wiki says that I need to use global $post here, seems excessive to do all the postmeta query manually. Is there a better way?

link -> edit causes error

I started playing around with your script found on github and I’m running into the issue below when adding the following:

'category' => array(
'title' => 'Categories',
'taxonomy' => 'knowledge_category',
'link' => 'edit'
),

link => edit causes the issue when I click on a category in the admin list or if you open categories

Am I missing something here or what could be the issue?

Thanks

Warning: sprintf(): Too few arguments in /Users/Marco/Sites/cms/wp-zementis/wp-content/themes/genesis-zementis/lib/extended-taxs.php on line 856

Warning: sprintf(): Too few arguments in /Users/Marco/Sites/cms/wp-zementis/wp-content/themes/genesis-zementis/lib/extended-taxs.php on line 857

Warning: sprintf(): Too few arguments in /Users/Marco/Sites/cms/wp-zementis/wp-content/themes/genesis-zementis/lib/extended-taxs.php on line 858

Warning: sprintf(): Too few arguments in /Users/Marco/Sites/cms/wp-zementis/wp-content/themes/genesis-zementis/lib/extended-taxs.php on line 859

Warning: sprintf(): Too few arguments in /Users/Marco/Sites/cms/wp-zementis/wp-content/themes/genesis-zementis/lib/extended-taxs.php on line 860

Warning: sprintf(): Too few arguments in /Users/Marco/Sites/cms/wp-zementis/wp-content/themes/genesis-zementis/lib/extended-taxs.php on line 861

Warning: sprintf(): Too few arguments in /Users/Marco/Sites/cms/wp-zementis/wp-content/themes/genesis-zementis/lib/extended-taxs.php on line 856

Warning: sprintf(): Too few arguments in /Users/Marco/Sites/cms/wp-zementis/wp-content/themes/genesis-zementis/lib/extended-taxs.php on line 857

Warning: sprintf(): Too few arguments in /Users/Marco/Sites/cms/wp-zementis/wp-content/themes/genesis-zementis/lib/extended-taxs.php on line 858

Warning: sprintf(): Too few arguments in /Users/Marco/Sites/cms/wp-zementis/wp-content/themes/genesis-zementis/lib/extended-taxs.php on line 859

Warning: sprintf(): Too few arguments in /Users/Marco/Sites/cms/wp-zementis/wp-content/themes/genesis-zementis/lib/extended-taxs.php on line 860

Warning: sprintf(): Too few arguments in /Users/Marco/Sites/cms/wp-zementis/wp-content/themes/genesis-zementis/lib/extended-taxs.php on line 861

Change Taxonomy Template

From @christianmagill on September 22, 2016 19:53

How about an option to change the default taxonomy template. Often I'll have a taxonomy for one particular post type, and I like to use the same archive for both the main post type archive and the related taxonomy.

Copied from original issue: johnbillion/extended-taxos#26

`has_archive` remains true for non-public post types

ExtendedCPTs sets the has_archive property to true here, but this means non-public post types also get has_archive set to true. The end result is that get_post_type_archive() returns an invalid URL instead of boolean false.

This needs to switch to being a conditional default.

Incorrect rewrite rule tests generated for certain permastructs

Seems to affect permastructs which use something other than the post type slug as a prefix. Needs investigating further.

Example:

register_extended_post_type( 'foo', array(
    'rewrite' => array(
        'permastruct' => '/bar/%foo%/%post_id%'
    ),
) );

Two of the generated tests fail:

Rewrite Test: index.php?foo=$matches[1]&paged=$matches[2]
Rewrite Result: index.php?foo=$matches[1]&p=$matches[2]&page=$matches[3]
Matched: bar/(.+?)/([0-9]+)(/[0-9]+)?/?$

Rewrite Test: index.php?foo=$matches[1]&page=$matches[2]
Rewrite Result: index.php?foo=$matches[1]&p=$matches[2]&page=$matches[3]
Matched: bar/(.+?)/([0-9]+)(/[0-9]+)?/?$

And one rewrite rule is missing a test:

bar/(.+?)/page/?([0-9]{1,})/?$

Post updated messages to be omitted if default labels are provided

Hi,

So I've manually added labels as per 'standard' register_post_type() args, so they're in Swedish and all fine. However, since "post_updated_messages" and "bulk_post_updated_messages" are hard-coded they do not translate well at all. The default behavior of WP would manage this if the set language of WP is sv_SE, the plugin does not.

As I see it, if one has provided labels manually AND WP language isn't English, don't add_filters() on line https://github.com/johnbillion/extended-cpts/blob/master/extended-cpts.php#L874 and https://github.com/johnbillion/extended-cpts/blob/master/extended-cpts.php#L875

Right now I've filtered them and added "my own" even though if they were never added I wouldn't have needed to. Se essentially I go from Swedish to English back to Swedish again which is kind of weird. I understand it's due to the 'ease' of just doing register_extended_post_type( 'article' ) and the plugin will magically do everything, but in this case magic isn't wanted.

Maybe check WP_LANG/get_locale() or similar as well as if default args ARE passed, skip applying the filters? Just a thought.

if( substr( get_locale(), 0, 3 ) == 'en_' && !$this->args['labels']['singular_name'] )

or simply add a new argument which is true by default but when false it won't apply the filters?

Edit: seems like this might need more work with internationalization as default WP will basically assume any CPT is a 'post' so Post updated vs. Article updated vs. custom filtered Artikel uppdaterad.

I'll leave my filters in but I guess this is 'food for thought'!

Filterable arguments

As demonstrated on the Keystone project at CFTP, it can sometimes be really handy to have a filter on the post type arguments so something else can hook in independently.

Let's apply a filter to $args at as late a point as possible.

P2P admin column showing connection when none exists

I'm using 3.0.1 of Extended CPTs.

I have 2 CPT's with a one-to-many connection via:
p2p_register_connection_type( array( 'name' => 'programs_to_steps', 'from' => 'wampum_program', 'to' => 'wampum_step', 'cardinality' => 'one-to-many', 'can_create_post' => false, 'sortable' => 'any', 'admin_box' => array( 'show' => 'any', 'context' => 'side', ), 'admin_column' => true, ) );

When viewing the 'wampum_step' CPT archive in admin, the connected post results are off. See screenshot.

screen_shot_2016-06-13_at_2_58_45_pm

The correct column is on the right, but I would like to show these columns via Extended CPTs rather than default p2p.

Warning for taxonomy filter in admin UI

I'm trying to include an admin_filter in my CPT for a taxo set up. I'm getting this warning:

Warning: The "Walker_ExtendedTaxonomyDropdown" class is required in order to display taxonomy filters in /app/vendor/johnbillion/extended-cpts/src/class-extended-cpt-admin.php on line 217

Here's my file:

<?php
$downloads = register_extended_post_type( 'downloads', array(

	# Add the post type to the site's main RSS feed:
	'show_in_feed' => true,

	'menu_icon' => 'dashicons-download',

	# Add some custom columns to the admin screen:
	'admin_cols' => array(
		'title' => array(),
		'file_name' => array(
			'title'       => 'File Name',
			'post_field'    => 'file_name',
		),
		'category' => array(
			'taxonomy' => 'download_category'
		)
	),

	'supports' => array('author'),

	# Add a dropdown filter to the admin screen:
	'admin_filters' => array(
		'download_category' => array(
			'title'    => 'Category',
			'taxonomy' => 'download_category',
		),
	),

), array(

	# Override the base names used for labels:
	'singular' => 'Download',
	'plural'   => 'Downloads',
	'slug'     => 'download',
) );

$downloads->add_taxonomy( 'download_category', array(
# Use radio buttons in the meta box for this taxonomy on the post editing screen:
//'meta_box' => 'checkbox',

# Show this taxonomy in the 'At a Glance' dashboard widget:
	'dashboard_glance' => true,

# Add a custom column to the admin screen:
	'admin_cols'       => array(
		'updated' => array(
			'title'       => 'Updated',
			'meta_key'    => 'updated_date',
			'date_format' => 'd/m/Y'
		),
	),

), array(

# Override the base names used for labels:
		'singular' => 'Category',
		'plural'   => 'Categories',
		'slug'     => 'download_category'

	)
);

Any idea what I'm doing wrong? I'm using just the Extended CPT lib.

Thanks!

Featured image error in 4.3 when re-registering 'post' post type

I use Extended CPTs to re-register the post post type to change the label and add admin columns and filters.

In WordPress 4.3 however, this is causing the featured image metabox to disappear with the following errors reported by Query Monitor:

extended-cpts-qm-errors

Adding 'supports' => array( 'title', 'editor', 'thumbnail' ) makes no difference.

This only affects the post post type, all other CPTs are fine.

Format numbers in Dashboard columns and keep sorting

Hi John,

I'm stuck on something that might seem a bit ridiculous. How to format numbers in the columns without removing the sorting feature? For instance, I want to format the price properly (add currency and comma) but let ability to sort by price.

screenshot-realestate dev 2016-05-02 16-30-00

If I use a custom function, then the sorting is disabled:

<?php
# Add some custom columns to the admin screen:
'admin_cols'    => array(
    'price'          => array(
        'title'    => 'Price',
        'meta_key' => 'price',
    ),
    'price_psf'      => array(
        'title'    => 'PSF Price',
        'function' => function () {
            $price = intval(get_field('price'));
            $sqm   = intval(get_field('sqm'));
            if ($price && $sqm) {
                $price_psf = round($price / $sqm, 1);
                echo $price_psf . " Baht / sqm";
            } else {
                echo 'NA';
            }
        },
    ),
),

I'd be grateful if you could help me find a solution.

Thanks

Setting custom key value options for admin_filters doesn't work as intended

When I tried setting custom options for an admin filter, instead of using the key value for the value and the value for the label it used the label for both. So in the following example:

'admin_filters' => array(
    'sticky' => array(
        'title' => __( 'View Sticky' ),
        'meta_key' => Loader::META_PREFIX . 'sticky',
        'options'  => array(
            'on' => __( 'Sticky' ),
        ),
    ),
),

the output option was be <option value="Sticky">Sticky</option> when it should have been <option value="on">Sticky</option>.

If I get a chance I'll find the cause and submit a PR- in the meantime I wanted to report this issue so it was tracked.

posts_per_page parameters

Would you be up for adding a parameter that would set the default number of posts displayed per page for that CPT? Even better would be one parameter for the front-end and one for the back-end.

Something like:

register_extended_post_type(
    'event',
    array(
        'public'               => true,
        'posts_per_page'       => 20,
        'admin_posts_per_page' => 50
        )
    );

Happy to submit a pull request if you like the idea.

Improve extending any previously registered post type

Related discussion on WP Slack, Apr 21st

My use case was: a plugin register a post type, where I'd like to quickly change labels, slugs etc on using extended-cpt, but keep whatever other functionality the plugin implements

register_post_type() can be called multiple times. Last one to arrive wins and will overwrite previous parameters.

https://github.com/johnbillion/extended-cpts/blob/master/extended-cpts.php#L690 checks for existing post types and if exists, falls back to only changing labels, when in fact it's possible to change whatever else you want as well.

In my particular case, the plugin sends its register_post_type $args through a filter, so I'm able to easily capture and store them, also doing stuff like array_replace_recursive() or whatever fits to merge with my own desired parameters.

get_post_type_object() returns an object, which to me looks needs conversion to array() for merging with whatever the user passes into register_extended_post_type().

My current recommendation is to drop ->extend() and enhance merging algorithm of our incoming $args with the result value of get_post_type_object().

Option to control admin columns order?

Hi,

Im extending an existing post type to add a few admin columns. By default it seems that the columns added by extended-cpts are placed first in the post list:
screenshot 2016-08-12 11 34 14

The brand column was created with the library. Do we have an option to control how the added columns are displayed on the list?

Search for CPT created using extend-cpts

Im seeing a problem in my Dashboard, where a CPT created using this library never returns any results in the posts list, no matter whatever I search for in the search input.

The post type i've created is called "Docs" and can be seen in this screenshot (sorry, the contents on the list are in Portuguese but I think you get the ideia);
screenshot 2015-07-29 16 26 08

It was created with the following code:

        register_extended_post_type( 'doc', array(
            'menu_icon' => 'dashicons-welcome-learn-more',
            'taxonomies' => array('post_tag'),

            # Add some custom columns to the admin screen:
            'admin_cols' => array(
                'topic' => array(
                    'taxonomy' => 'topic'
                )
            ),

            # Add a dropdown filter to the admin screen:
            'admin_filters' => array(
                'topic' => array(
                    'taxonomy' => 'topic'
                )
            )
        ) );

Considering the first post in the list, with the title "Formatação de textos", if I search for "textos" i get no results:
screenshot 2015-07-29 16 27 51

This CPT also has a custom taxonomy "Topics" which I created using your library https://github.com/johnbillion/extended-taxos

This taxonomy can be seen as the second column in the list. I used extended-cpts to add that column and the respective filter above, but if I try to filter de list for the topic "Escrever e Editar" which is assigned to several posts, including that first one given as an example, I still get no results:
screenshot 2015-07-29 16 32 18

But if instead of using the select box above the list, I filter for that taxonomy term by pressing one of its occurrences in the list, I do get the expected behaviour:
screenshot 2015-07-29 16 33 34

Have you seen this problem before, anything I am missing?
Thanks again.

walk_dirs arg for add_permastruct()

It looks like you are currently calling add_permastruct without setting $args['walk_dirs'] which means you end up using the core default of true.

Because of this, when setting a permastruct like /slug/%year%/%monthnum%/%postname% you also get the following rules:

slug/([0-9]{4})/([0-9]{1,2})/?$ - index.php?year=$matches[1]&monthnum=$matches[2] - slug
slug/([0-9]{4})/?$ - index.php?year=$matches[1] - slug

While it would be great to have date based archives for custom post types, we are not actually setting the post_type query var so we end up with a second URL where we can view the date archives for the core post post-type.

I don't see an easy way to force the post_type query variable short of filtering $this->post_type . '_rewrite_rules' and manually modifying it (though admittedly I am not very familiar with the rewrite API).

Anyway - I guess I am wondering what your thoughts are about all of this? At a minimum, I would think it would be beneficial to set $this->defaults['rewrite']['walk_dirs'] to false to avoid duplicate content.

At the same time, it would be great to further mimic some of the core functionality such as date based archives when the user sets a permastruct which includes date and time rewrite tags.

Custom Menus Break In WordPress 4.4

Custom menus no longer work when using the extended-cpts with WordPress 4.4

Registering is fine, once you add an actual new post within the custom post then the appearance > custom menus page basically doesn’t work, you can not add menu or even see the menus.

Delete the post you’ve created, empty the bin and the menus page come back in.

Happened since 4.4 was released.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.