Skip to content

Commit

Permalink
add exception for all acf options page
Browse files Browse the repository at this point in the history
  • Loading branch information
herewithme committed Mar 31, 2020
1 parent f059631 commit eaf76ab
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions inc/services/acf.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,18 +105,22 @@ public function init() {
}

/**
* @param $parameters
* Add Option Page
*
* @return bool
*
* @param $parameters
*
*/
public function acf_add_options_page( $parameters ) {
/**
* Add Option Page
*/
if ( ! function_exists( 'acf_add_options_page' ) ) {
return false;
}

if ( ! isset( $parameters['menu_slug'] ) ) {
throw new InvalidArgumentException( 'You must specify menu slug for ACF options page.' );
}

return acf_add_options_page( $parameters );

}
Expand Down Expand Up @@ -150,17 +154,18 @@ public function get_files() {
/**
* Add options Subpage
*
* @return bool
*
* @param $parameters
*
* @return bool
*/
public function acf_add_options_sub_page( $parameters ) {
if ( ! function_exists( 'acf_add_options_sub_page' ) ) {
return false;
}

if ( ! isset( $parameters['menu_slug'] ) ) {
throw new Exception( 'You must specify menu slug for ACF options page.' );
throw new InvalidArgumentException( 'You must specify menu slug for ACF options page.' );
}

return acf_add_options_sub_page( $parameters );
Expand Down

0 comments on commit eaf76ab

Please sign in to comment.