Closed nickcernis closed 7 years ago
@nickcernis I'd rather keep the constant in the plugin because if that constant is changed in Genesis, the plugin will catch it. The plugin isn't defining this, it is defined in Genesis.
As such, the constant should be available as long as Genesis is.
Thanks, @NicktheGeek — I missed that it was a Genesis constant.
@dreamwhisper Looks like GENESIS_CPT_ARCHIVE_SETTINGS_FIELD_PREFIX
can be assumed for Genesis themes, so theme devs can do this:
add_action( 'after_switch_theme', 'sp_theme_portfolio_pro_defaults' );
/**
* Update Portfolio Pro posts per page setting.
*
* @since 1.0.0
*/
function sp_theme_portfolio_pro_defaults() {
$portfolio_options = (array) get_option( GENESIS_CPT_ARCHIVE_SETTINGS_FIELD_PREFIX . 'portfolio' );
$portfolio_options['posts_per_page'] = 9;
update_option( GENESIS_CPT_ARCHIVE_SETTINGS_FIELD_PREFIX . 'portfolio', $portfolio_options );
}
I tested this and it's working in the above scenarios with 1.1 for me.
If that seems okay, I think it's fine to close this.
I didn't try it, but it looks ok. Thanks @nickcernis and @NicktheGeek!
We'll need a way to change the new
posts_per_page
portfolio archive setting upon theme activation. It has to work:Adding this code to the theme works if the plugin is already active when the new theme is activated:
But it won't work if the plugin is not yet active.
Could we drop the
GENESIS_CPT_ARCHIVE_SETTINGS_FIELD_PREFIX
from the plugin and hard-code the option name instead? That way we could do this and the option will be set even if the plugin isn't active, ready for the first time it's activated.Paging @NicktheGeek as you may have smarter ideas about how this should work.