Skip to content

Commit

Permalink
added admin notice
Browse files Browse the repository at this point in the history
  • Loading branch information
Tusko committed Nov 7, 2015
1 parent 486fddf commit a7254cd
Showing 1 changed file with 42 additions and 34 deletions.
76 changes: 42 additions & 34 deletions cpt-acf.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,42 +26,50 @@

defined( 'ABSPATH' ) or die( 'No script kiddies please!' );

function ctpacf_admin_error_notice() {
echo '<div class="update-nag"><p>The plugin <strong>Advanced Custom Fields : CPT Options Pages</strong> is not standalone plugin.<br />Please buy <a href="http://www.advancedcustomfields.com/add-ons/options-page/">ACF Options Page Addon</a> or <a href="http://www.advancedcustomfields.com/pro/">ACF PRO</a> and install it.</p></div>';
}

function ctpacf_options_pages() {

if( function_exists('acf_add_options_page') ) { //Check if installed acf

$ctpacf_post_types = get_post_types( array(
'_builtin' => false,
'has_archive' => true
) ); //get post types

foreach ( $ctpacf_post_types as $cpt ) {

if( post_type_exists( $cpt ) ) {

$cpt_acf_page = array(
'page_title' => ucfirst($cpt) . ' ACF',
'menu_title' => ucfirst($cpt) . ' ACF',
'menu_slug' => 'ctpacf-' . $cpt,
'capability' => 'edit_posts',
'position' => false,
'parent_slug' => 'edit.php?post_type=' . $cpt,
'icon_url' => false,
'redirect' => false,
'post_id' => 'cpt_' . $cpt,
'autoload' => false
);

acf_add_options_page( $cpt_acf_page );

} // end if

}

}

if( function_exists('acf_add_options_page') ) { //Check if installed acf

$ctpacf_post_types = get_post_types( array(
'_builtin' => false,
'has_archive' => true
) ); //get post types

foreach ( $ctpacf_post_types as $cpt ) {

if( post_type_exists( $cpt ) ) {

$cpt_acf_page = array(
'page_title' => ucfirst($cpt) . ' ACF',
'menu_title' => ucfirst($cpt) . ' ACF',
'menu_slug' => 'ctpacf-' . $cpt,
'capability' => 'edit_posts',
'position' => false,
'parent_slug' => 'edit.php?post_type=' . $cpt,
'icon_url' => false,
'redirect' => false,
'post_id' => 'cpt_' . $cpt,
'autoload' => false
);

acf_add_options_page( $cpt_acf_page );

} // end if

}

} else { //activation warning

add_action( 'admin_notices', 'ctpacf_admin_error_notice' );

}

}

add_action( 'init', 'ctpacf_options_pages', 99 );

?>
?>

0 comments on commit a7254cd

Please sign in to comment.