Instantly share code, notes, and snippets.
Last active
November 22, 2022 11:53
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
<?php | |
/** | |
* Plugin Name: Techie Options | |
* Plugin URI: https://github.com/yttechiepress/techie-options-page | |
* Author: Techiepress | |
* Author URI: https://github.com/yttechiepress/techie-options-page | |
* Description: This plugin adds an ACF Options Page to WP. | |
* Version: 0.1.0 | |
* License: GPL2 | |
* License URL: http://www.gnu.org/licenses/gpl-2.0.txt | |
* text-domain: techie-options-page | |
*/ | |
// Basic security. | |
defined( 'ABSPATH' ) or die( 'Unauthorized Access' ); | |
if ( function_exists( 'acf_add_options_page' ) ) { | |
// Add a top menu page | |
acf_add_options_page( | |
array( | |
'page_title' => 'Footer Options Page', | |
'menu_title' => 'Footer Options', | |
'menu_slug' => 'techie-options', | |
'redirect' => false, | |
'capability' => 'administrator', | |
'position' => 5.4 | |
) | |
); | |
// Add a Sub Page | |
acf_add_options_sub_page( | |
array( | |
'page_title' => 'Sub Footer Options Page', | |
'menu_title' => 'Sub Footer Options', | |
'parent_slug' => 'techie-options', | |
) | |
); | |
} | |
// Save the ACF fields in the plugin. | |
if( function_exists('acf_add_local_field_group') ): | |
acf_add_local_field_group(array( | |
'key' => 'group_6119db99a4fb1', | |
'title' => 'Footer Settings', | |
'fields' => array( | |
array( | |
'key' => 'field_6119dba3720c0', | |
'label' => 'Holding Company', | |
'name' => 'holding_company', | |
'type' => 'text', | |
'instructions' => '', | |
'required' => 0, | |
'conditional_logic' => 0, | |
'wrapper' => array( | |
'width' => '', | |
'class' => '', | |
'id' => '', | |
), | |
'default_value' => '', | |
'placeholder' => '', | |
'prepend' => '', | |
'append' => '', | |
'maxlength' => '', | |
), | |
), | |
'location' => array( | |
array( | |
array( | |
'param' => 'options_page', | |
'operator' => '==', | |
'value' => 'techie-options', | |
), | |
), | |
), | |
'menu_order' => 0, | |
'position' => 'normal', | |
'style' => 'default', | |
'label_placement' => 'top', | |
'instruction_placement' => 'label', | |
'hide_on_screen' => '', | |
'active' => true, | |
'description' => '', | |
)); | |
endif; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment