Пример #1
0
 function acf_add_options_sub_page($page = '')
 {
     // validate
     $page = acf_get_valid_options_page($page);
     // parent
     if (!$page['parent_slug']) {
         // set parent slug
         $page['parent_slug'] = 'acf-options';
     }
     // create default parent if not yet exists
     if ($page['parent_slug'] === 'acf-options') {
         if (!acf_get_options_page('acf-options')) {
             acf_add_options_page();
         }
     }
     // return
     return acf_add_options_page($page);
 }
Пример #2
0
 /**
  * Get field group filters based on active screen.
  */
 public function get_acf_field_group_filters()
 {
     global $post, $pagenow, $typenow, $plugin_page;
     $filter = array();
     if ($pagenow === 'post.php' || $pagenow === 'post-new.php') {
         if ($typenow !== 'acf') {
             $filter['post_id'] = $post->ID;
             $filter['post_type'] = $typenow;
         }
     } elseif ($pagenow === 'admin.php' && isset($plugin_page)) {
         if (acf_get_options_page($plugin_page)) {
             $filter['post_id'] = acf_get_valid_post_id('options');
         }
     } elseif ($pagenow === 'edit-tags.php' && isset($_GET['taxonomy'])) {
         $filter['taxonomy'] = filter_var($_GET['taxonomy'], FILTER_SANITIZE_STRING);
     } elseif ($pagenow === 'profile.php') {
         $filter['user_id'] = get_current_user_id();
         $filter['user_form'] = 'edit';
     } elseif ($pagenow === 'user-edit.php' && isset($_GET['user_id'])) {
         $filter['user_id'] = filter_var($_GET['user_id'], FILTER_SANITIZE_NUMBER_INT);
         $filter['user_form'] = 'edit';
     } elseif ($pagenow === 'user-new.php') {
         $filter['user_id'] = 'new';
         $filter['user_form'] = 'edit';
     } elseif ($pagenow === 'media.php' || $pagenow === 'upload.php') {
         $filter['attachment'] = 'All';
     } elseif (acf_is_screen('widgets') || acf_is_screen('customize')) {
         $filter['widget'] = 'all';
     }
     return $filter;
 }
Пример #3
0
<?php

// extract
extract($args);
// page
$page = acf_get_options_page($slug);
?>
<div class="wrap acf-settings-wrap">
	
	<h2><?php 
echo $page['page_title'];
?>
</h2>
	
	<form id="post" method="post" name="post">
		
		<?php 
// render post data
acf_form_data(array('post_id' => 'options', 'nonce' => 'options'));
wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
?>
		
		<div id="poststuff">
			
			<div id="post-body" class="metabox-holder columns-2">
			
				<!-- Main -->
				<div id="post-body-content">
					
					<div id="normal-sortables" class="meta-box-sortables ui-sortable">
						
Пример #4
0
 function admin_load()
 {
     // globals
     global $plugin_page;
     // vars
     $this->page = acf_get_options_page($plugin_page);
     // verify and remove nonce
     if (acf_verify_nonce('options')) {
         // save data
         if (acf_validate_save_post(true)) {
             // get post_id (allow lang modification)
             $post_id = acf_get_valid_post_id($this->page['post_id']);
             // set autoload
             acf_update_setting('autoload', $this->page['autoload']);
             // save
             acf_save_post($post_id);
             // redirect
             wp_redirect(admin_url("admin.php?page={$plugin_page}&message=1"));
             exit;
         }
     }
     // actions
     add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'));
 }
Пример #5
0
 function admin_load()
 {
     // globals
     global $plugin_page;
     // vars
     $this->page = acf_get_options_page($plugin_page);
     // verify and remove nonce
     if (acf_verify_nonce('options')) {
         // save data
         if (acf_validate_save_post(true)) {
             // get post_id (allow lang modification)
             $post_id = acf_get_valid_post_id($this->page['post_id']);
             // set autoload
             acf_update_setting('autoload', $this->page['autoload']);
             // save
             acf_save_post($post_id);
             // redirect
             wp_redirect(add_query_arg(array('message' => '1')));
             exit;
         }
     }
     // load acf scripts
     acf_enqueue_scripts();
     // actions
     add_action('acf/input/admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'));
     add_action('acf/input/admin_head', array($this, 'admin_head'));
     // add columns support
     add_screen_option('layout_columns', array('max' => 2, 'default' => 2));
 }
Пример #6
0
 function acf_add_options_page($page = '')
 {
     // validate
     $page = acf_get_valid_options_page($page);
     // instantiate globals
     if (empty($GLOBALS['acf_options_pages'])) {
         $GLOBALS['acf_options_pages'] = array();
     }
     // update if already exists
     if (acf_get_options_page($page['menu_slug'])) {
         return acf_update_options_page($page);
     }
     // append
     $GLOBALS['acf_options_pages'][$page['menu_slug']] = $page;
     // return
     return $page;
 }