Skip to content

Commit

Permalink
disable if no acf options page
Browse files Browse the repository at this point in the history
  • Loading branch information
Hube2 committed Dec 3, 2020
1 parent 4876b14 commit bc450bf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
16 changes: 14 additions & 2 deletions options-pages.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Description: Allows easy creation of options pages using Advanced Custom Fields Pro without needing to do any PHP coding. Requires that ACF Pro is installed.
Author: John A. Huebner II
Author URI: https://github.com/Hube2
Version: 3.9.5
Version: 3.9.6
*/

// If this file is called directly, abort.
Expand All @@ -16,7 +16,7 @@

class acfOptionsPageAdder {

private $version = '3.9.5';
private $version = '3.9.6';
private $post_type = 'acf-options-page';
private $parent_menus = array();
private $exclude_locations = array('',
Expand Down Expand Up @@ -163,6 +163,9 @@ public function set_title_field($value, $post_id, $field) {
} // end public function set_title_field

public function after_setup_theme() {
if (!function_exists('acf_add_options_page')) {
return;
}
// check to see if acf5 is installed
// if not then do not run anything else in this plugin
// move all other actions to this function except text domain since this is too late
Expand All @@ -185,12 +188,18 @@ public function after_setup_theme() {
} // end public function after_setup_theme

public function init() {
if (!function_exists('acf_add_options_page')) {
return;
}
$this->register_post_type();
$this->acf_add_options_pages();
do_action('acf_options_page/init');
} // end public function init

public function acf_include_fields() {
if (!function_exists('acf_add_options_page')) {
return;
}
// this function is called when ACF5 is installed
$field_group = array(
'key' => 'acf_options-page-details',
Expand Down Expand Up @@ -752,6 +761,9 @@ private function build_options_page_settings($post_id, $title='') {
} // end private function build_options_page_settings

public function add_hooks() {
if (!function_exists('acf_add_options_page')) {
return;
}
//echo '<pre>'; print_r($this->options_pages); die;
foreach($this->options_pages as $id => $options_page) {
if (isset($options_page['customize']) && !$options_page['customize']) {
Expand Down
5 changes: 4 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Contributors: Hube2
Tags: Options Page, ACF
Requires at least: 3.5
Tested up to: 5.5
Stable tag: 3.9.5
Stable tag: 3.9.6
Donate link:
License:
License URI:
Expand Down Expand Up @@ -166,6 +166,9 @@ add_filter('remove_hube2_nag', '__return_true');

== Changelog ==

= 3.9.6 =
* disable all functionality if acf options page functions do not exist

= 3.9.5 =
* moved acf/include_fields to __construct due to change is ACF timing

Expand Down

0 comments on commit bc450bf

Please sign in to comment.