This repository has been archived by the owner on Mar 31, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add the acf component * Add demo content
- Loading branch information
Showing
3 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
<?php | ||
/** | ||
* Lhplugin\ACF\Component class | ||
* | ||
* @package lhpbp | ||
*/ | ||
|
||
namespace WpMunich\lhpbp\ACF; | ||
use WpMunich\lhpbp\Component_Interface; | ||
use function add_action; | ||
use function wp_get_environment_type; | ||
use function acf_add_options_page; | ||
|
||
/** | ||
* A class to handle acf related logic.. | ||
*/ | ||
class Component implements Component_Interface { | ||
|
||
/** | ||
* Gets the unique identifier for the plugin component. | ||
* | ||
* @return string Component slug. | ||
*/ | ||
public function get_slug() { | ||
return 'acf'; | ||
} | ||
|
||
/** | ||
* Adds the action and filter hooks to integrate with WordPress. | ||
*/ | ||
public function initialize() { | ||
if ( wp_get_environment_type() === 'development' && defined( 'LH_CURRENTLY_EDITING' ) && LH_CURRENTLY_EDITING === 'lhpbp' ) { | ||
add_filter( 'acf/settings/save_json', array( $this, 'acf_json_save_point' ) ); | ||
} | ||
|
||
add_filter( 'acf/settings/load_json', array( $this, 'acf_json_load_point' ) ); | ||
|
||
add_action( 'acf/init', array( $this, 'add_options_page' ) ); | ||
} | ||
|
||
/** | ||
* Add the json save point for acf. | ||
* | ||
* @param string $path Save path. | ||
* | ||
* @return string Save path. | ||
*/ | ||
public function acf_json_save_point( $path ) { | ||
$path = LHTHEME_PATH . 'acf-json'; | ||
return $path; | ||
} | ||
|
||
/** | ||
* Add the json load point for acf. | ||
* | ||
* @param array $paths An array of paths. | ||
* | ||
* @return array An array of paths. | ||
*/ | ||
public function acf_json_load_point( $paths ) { | ||
$paths[] = LHPLUGIN_PATH . 'acf-json'; | ||
|
||
return $paths; | ||
} | ||
|
||
/** | ||
* Hide the acf admin | ||
* | ||
* @return void | ||
*/ | ||
private function hide_acf_admin() { | ||
add_filter( 'acf/settings/show_admin', '__return_false' ); | ||
} | ||
|
||
/** | ||
* Add a theme options page. | ||
*/ | ||
public function add_options_page() { | ||
if ( ! function_exists( 'acf_add_options_page' ) ) { | ||
return; | ||
} | ||
|
||
$option_page = acf_add_options_page( | ||
array( | ||
'page_title' => __( 'Theme General Settings', 'lhpbp' ), | ||
'menu_title' => __( 'Theme Settings', 'lhpbp' ), | ||
'menu_slug' => 'theme-general-settings', | ||
'capability' => 'edit_posts', | ||
'redirect' => false, | ||
) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters