Added dependency plugins
This commit is contained in:
@@ -0,0 +1,179 @@
|
||||
<?php
|
||||
|
||||
if( !class_exists('acf_pro') ):
|
||||
|
||||
class acf_pro {
|
||||
|
||||
/*
|
||||
* __construct
|
||||
*
|
||||
*
|
||||
*
|
||||
* @type function
|
||||
* @date 23/06/12
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param N/A
|
||||
* @return N/A
|
||||
*/
|
||||
|
||||
function __construct() {
|
||||
|
||||
// constants
|
||||
acf()->define( 'ACF_PRO', true );
|
||||
|
||||
|
||||
// update setting
|
||||
acf_update_setting( 'pro', true );
|
||||
acf_update_setting( 'name', __('Advanced Custom Fields PRO', 'acf') );
|
||||
|
||||
|
||||
// includes
|
||||
acf_include('pro/options-page.php');
|
||||
acf_include('pro/updates.php');
|
||||
|
||||
if( is_admin() ) {
|
||||
|
||||
acf_include('pro/admin/admin-options-page.php');
|
||||
acf_include('pro/admin/admin-settings-updates.php');
|
||||
|
||||
}
|
||||
|
||||
|
||||
// actions
|
||||
add_action('init', array($this, 'register_assets'));
|
||||
add_action('acf/include_field_types', array($this, 'include_field_types'), 5);
|
||||
add_action('acf/include_location_rules', array($this, 'include_location_rules'), 5);
|
||||
add_action('acf/input/admin_enqueue_scripts', array($this, 'input_admin_enqueue_scripts'));
|
||||
add_action('acf/field_group/admin_enqueue_scripts', array($this, 'field_group_admin_enqueue_scripts'));
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* include_field_types
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @type function
|
||||
* @date 21/10/2015
|
||||
* @since 5.2.3
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function include_field_types() {
|
||||
|
||||
acf_include('pro/fields/class-acf-field-repeater.php');
|
||||
acf_include('pro/fields/class-acf-field-flexible-content.php');
|
||||
acf_include('pro/fields/class-acf-field-gallery.php');
|
||||
acf_include('pro/fields/class-acf-field-clone.php');
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* include_location_rules
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @type function
|
||||
* @date 10/6/17
|
||||
* @since 5.6.0
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function include_location_rules() {
|
||||
|
||||
acf_include('pro/locations/class-acf-location-options-page.php');
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* register_assets
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @type function
|
||||
* @date 4/11/2013
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function register_assets() {
|
||||
|
||||
// vars
|
||||
$version = acf_get_setting('version');
|
||||
$min = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
|
||||
|
||||
|
||||
// register scripts
|
||||
wp_register_script( 'acf-pro-input', acf_get_dir( "pro/assets/js/acf-pro-input{$min}.js" ), array('acf-input'), $version );
|
||||
wp_register_script( 'acf-pro-field-group', acf_get_dir( "pro/assets/js/acf-pro-field-group{$min}.js" ), array('acf-field-group'), $version );
|
||||
|
||||
|
||||
// register styles
|
||||
wp_register_style( 'acf-pro-input', acf_get_dir( 'pro/assets/css/acf-pro-input.css' ), array('acf-input'), $version );
|
||||
wp_register_style( 'acf-pro-field-group', acf_get_dir( 'pro/assets/css/acf-pro-field-group.css' ), array('acf-input'), $version );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* input_admin_enqueue_scripts
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @type function
|
||||
* @date 4/11/2013
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function input_admin_enqueue_scripts() {
|
||||
|
||||
wp_enqueue_script('acf-pro-input');
|
||||
wp_enqueue_style('acf-pro-input');
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* field_group_admin_enqueue_scripts
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @type function
|
||||
* @date 4/11/2013
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function field_group_admin_enqueue_scripts() {
|
||||
|
||||
wp_enqueue_script('acf-pro-field-group');
|
||||
wp_enqueue_style('acf-pro-field-group');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// instantiate
|
||||
new acf_pro();
|
||||
|
||||
|
||||
// end class
|
||||
endif;
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,367 @@
|
||||
<?php
|
||||
|
||||
if( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
if( ! class_exists('acf_admin_options_page') ) :
|
||||
|
||||
class acf_admin_options_page {
|
||||
|
||||
/** @var array Contains the current options page */
|
||||
var $page;
|
||||
|
||||
|
||||
/*
|
||||
* __construct
|
||||
*
|
||||
* Initialize filters, action, variables and includes
|
||||
*
|
||||
* @type function
|
||||
* @date 23/06/12
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function __construct() {
|
||||
|
||||
// add menu items
|
||||
add_action('admin_menu', array($this,'admin_menu'), 99, 0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* admin_menu
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @type function
|
||||
* @date 24/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
|
||||
function admin_menu() {
|
||||
|
||||
// vars
|
||||
$pages = acf_get_options_pages();
|
||||
|
||||
|
||||
// bail early if no pages
|
||||
if( empty($pages) ) return;
|
||||
|
||||
|
||||
// loop
|
||||
foreach( $pages as $page ) {
|
||||
|
||||
// vars
|
||||
$slug = '';
|
||||
|
||||
|
||||
// parent
|
||||
if( empty($page['parent_slug']) ) {
|
||||
|
||||
$slug = add_menu_page( $page['page_title'], $page['menu_title'], $page['capability'], $page['menu_slug'], array($this, 'html'), $page['icon_url'], $page['position'] );
|
||||
|
||||
// child
|
||||
} else {
|
||||
|
||||
$slug = add_submenu_page( $page['parent_slug'], $page['page_title'], $page['menu_title'], $page['capability'], $page['menu_slug'], array($this, 'html') );
|
||||
|
||||
}
|
||||
|
||||
|
||||
// actions
|
||||
add_action("load-{$slug}", array($this,'admin_load'));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* load
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @type function
|
||||
* @date 2/02/13
|
||||
* @since 3.6
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function admin_load() {
|
||||
|
||||
// globals
|
||||
global $plugin_page;
|
||||
|
||||
|
||||
// vars
|
||||
$this->page = acf_get_options_page( $plugin_page );
|
||||
|
||||
|
||||
// get post_id (allow lang modification)
|
||||
$this->page['post_id'] = acf_get_valid_post_id($this->page['post_id']);
|
||||
|
||||
|
||||
// verify and remove nonce
|
||||
if( acf_verify_nonce('options') ) {
|
||||
|
||||
// save data
|
||||
if( acf_validate_save_post(true) ) {
|
||||
|
||||
// set autoload
|
||||
acf_update_setting('autoload', $this->page['autoload']);
|
||||
|
||||
|
||||
// save
|
||||
acf_save_post( $this->page['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));
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* admin_enqueue_scripts
|
||||
*
|
||||
* This function will enqueue the 'post.js' script which adds support for 'Screen Options' column toggle
|
||||
*
|
||||
* @type function
|
||||
* @date 23/03/2016
|
||||
* @since 5.3.2
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
|
||||
function admin_enqueue_scripts() {
|
||||
|
||||
wp_enqueue_script('post');
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* admin_head
|
||||
*
|
||||
* This action will find and add field groups to the current edit page
|
||||
*
|
||||
* @type action (admin_head)
|
||||
* @date 23/06/12
|
||||
* @since 3.1.8
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function admin_head() {
|
||||
|
||||
// get field groups
|
||||
$field_groups = acf_get_field_groups(array(
|
||||
'options_page' => $this->page['menu_slug']
|
||||
));
|
||||
|
||||
|
||||
// notices
|
||||
if( !empty($_GET['message']) && $_GET['message'] == '1' ) {
|
||||
|
||||
acf_add_admin_notice( $this->page['updated_message'] );
|
||||
|
||||
}
|
||||
|
||||
|
||||
// add submit div
|
||||
add_meta_box('submitdiv', __('Publish','acf'), array($this, 'postbox_submitdiv'), 'acf_options_page', 'side', 'high');
|
||||
|
||||
|
||||
|
||||
if( empty($field_groups) ) {
|
||||
|
||||
acf_add_admin_notice( sprintf( __('No Custom Field Groups found for this options page. <a href="%s">Create a Custom Field Group</a>', 'acf'), admin_url() . 'post-new.php?post_type=acf-field-group' ), 'error');
|
||||
|
||||
} else {
|
||||
|
||||
foreach( $field_groups as $i => $field_group ) {
|
||||
|
||||
// vars
|
||||
$id = "acf-{$field_group['key']}";
|
||||
$title = $field_group['title'];
|
||||
$context = $field_group['position'];
|
||||
$priority = 'high';
|
||||
$args = array( 'field_group' => $field_group );
|
||||
|
||||
|
||||
// tweaks to vars
|
||||
if( $context == 'acf_after_title' ) {
|
||||
|
||||
$context = 'normal';
|
||||
|
||||
} elseif( $context == 'side' ) {
|
||||
|
||||
$priority = 'core';
|
||||
|
||||
}
|
||||
|
||||
|
||||
// filter for 3rd party customization
|
||||
$priority = apply_filters('acf/input/meta_box_priority', $priority, $field_group);
|
||||
|
||||
|
||||
// add meta box
|
||||
add_meta_box( $id, $title, array($this, 'postbox_acf'), 'acf_options_page', $context, $priority, $args );
|
||||
|
||||
|
||||
}
|
||||
// foreach
|
||||
|
||||
}
|
||||
// if
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* postbox_submitdiv
|
||||
*
|
||||
* This function will render the submitdiv metabox
|
||||
*
|
||||
* @type function
|
||||
* @date 23/03/2016
|
||||
* @since 5.3.2
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function postbox_submitdiv( $post, $args ) {
|
||||
|
||||
?>
|
||||
<div id="major-publishing-actions">
|
||||
|
||||
<div id="publishing-action">
|
||||
<span class="spinner"></span>
|
||||
<input type="submit" accesskey="p" value="<?php echo $this->page['update_button']; ?>" class="button button-primary button-large" id="publish" name="publish">
|
||||
</div>
|
||||
|
||||
<div class="clear"></div>
|
||||
|
||||
</div>
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* render_meta_box
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @type function
|
||||
* @date 24/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $post (object)
|
||||
* @param $args (array)
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function postbox_acf( $post, $args ) {
|
||||
|
||||
// extract args
|
||||
extract( $args ); // all variables from the add_meta_box function
|
||||
extract( $args ); // all variables from the args argument
|
||||
|
||||
|
||||
// vars
|
||||
$o = array(
|
||||
'id' => $id,
|
||||
'key' => $field_group['key'],
|
||||
'style' => $field_group['style'],
|
||||
'label' => $field_group['label_placement'],
|
||||
'edit_url' => '',
|
||||
'edit_title' => __('Edit field group', 'acf'),
|
||||
'visibility' => true
|
||||
);
|
||||
|
||||
|
||||
// edit_url
|
||||
if( $field_group['ID'] && acf_current_user_can_admin() ) {
|
||||
|
||||
$o['edit_url'] = admin_url('post.php?post=' . $field_group['ID'] . '&action=edit');
|
||||
|
||||
}
|
||||
|
||||
|
||||
// load fields
|
||||
$fields = acf_get_fields( $field_group );
|
||||
|
||||
|
||||
// render
|
||||
acf_render_fields( $this->page['post_id'], $fields, 'div', $field_group['instruction_placement'] );
|
||||
|
||||
|
||||
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
if( typeof acf !== 'undefined' ) {
|
||||
|
||||
acf.postbox.render(<?php echo json_encode($o); ?>);
|
||||
|
||||
}
|
||||
</script>
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* html
|
||||
*
|
||||
* @description:
|
||||
* @since: 2.0.4
|
||||
* @created: 5/12/12
|
||||
*/
|
||||
|
||||
function html() {
|
||||
|
||||
// load view
|
||||
acf_get_view(dirname(__FILE__) . '/views/html-options-page.php', $this->page);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
// initialize
|
||||
new acf_admin_options_page();
|
||||
|
||||
endif;
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,416 @@
|
||||
<?php
|
||||
|
||||
if( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
if( ! class_exists('acf_admin_settings_updates') ) :
|
||||
|
||||
class acf_admin_settings_updates {
|
||||
|
||||
// vars
|
||||
var $view = array();
|
||||
|
||||
|
||||
/*
|
||||
* __construct
|
||||
*
|
||||
* Initialize filters, action, variables and includes
|
||||
*
|
||||
* @type function
|
||||
* @date 23/06/12
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function __construct() {
|
||||
|
||||
// actions
|
||||
add_action('admin_menu', array($this, 'admin_menu'), 20 );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* show_notice
|
||||
*
|
||||
* This function will show a notice (only once)
|
||||
*
|
||||
* @type function
|
||||
* @date 11/4/17
|
||||
* @since 5.5.10
|
||||
*
|
||||
* @param $message (string)
|
||||
* @param class (string)
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function show_notice( $message = '', $class = '' ){
|
||||
|
||||
// only show one notice
|
||||
if( acf_has_done('acf_admin_settings_updates_notice') ) return false;
|
||||
|
||||
|
||||
// add notice
|
||||
acf_add_admin_notice( $message, $class );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* show_error
|
||||
*
|
||||
* This function will show an error notice (only once)
|
||||
*
|
||||
* @type function
|
||||
* @date 11/4/17
|
||||
* @since 5.5.10
|
||||
*
|
||||
* @param $error (mixed)
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function show_error( $error = '' ){
|
||||
|
||||
// error object
|
||||
if( is_wp_error($error) ) {
|
||||
|
||||
$error = __('<b>Error</b>. Could not connect to update server', 'acf') . ' <span class="description">(' . esc_html( $error->get_error_message() ) . ')</span>';
|
||||
|
||||
}
|
||||
|
||||
|
||||
// add notice
|
||||
$this->show_notice( $error, 'error' );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* get_changelog_section
|
||||
*
|
||||
* This function will find and return a section of content from a plugin changelog
|
||||
*
|
||||
* @type function
|
||||
* @date 11/4/17
|
||||
* @since 5.5.10
|
||||
*
|
||||
* @param $changelog (string)
|
||||
* @param $h4 (string)
|
||||
* @return (string)
|
||||
*/
|
||||
|
||||
function get_changelog_section( $changelog, $h4 = '' ) {
|
||||
|
||||
// explode
|
||||
$bits = array_filter( explode('<h4>', $changelog) );
|
||||
|
||||
|
||||
// loop
|
||||
foreach( $bits as $bit ) {
|
||||
|
||||
// vars
|
||||
$bit = explode('</h4>', $bit);
|
||||
$version = trim($bit[0]);
|
||||
$text = trim($bit[1]);
|
||||
|
||||
|
||||
// is relevant?
|
||||
if( version_compare($h4, $version, '==') ) {
|
||||
|
||||
return '<h4>' . esc_html($version) . '</h4>' . acf_esc_html($text);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// update
|
||||
return '';
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* admin_menu
|
||||
*
|
||||
* This function will add the ACF menu item to the WP admin
|
||||
*
|
||||
* @type action (admin_menu)
|
||||
* @date 28/09/13
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function admin_menu() {
|
||||
|
||||
// bail early if no show_admin
|
||||
if( !acf_get_setting('show_admin') ) return;
|
||||
|
||||
|
||||
// bail early if no show_updates
|
||||
if( !acf_get_setting('show_updates') ) return;
|
||||
|
||||
|
||||
// bail early if not a plugin (included in theme)
|
||||
if( !acf_is_plugin_active() ) return;
|
||||
|
||||
|
||||
// add page
|
||||
$page = add_submenu_page('edit.php?post_type=acf-field-group', __('Updates','acf'), __('Updates','acf'), acf_get_setting('capability'), 'acf-settings-updates', array($this,'html') );
|
||||
|
||||
|
||||
// actions
|
||||
add_action('load-' . $page, array($this,'load'));
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* load
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @type function
|
||||
* @date 7/01/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function load() {
|
||||
|
||||
// activate
|
||||
if( acf_verify_nonce('activate_pro_licence') ) {
|
||||
|
||||
$this->activate_pro_licence();
|
||||
|
||||
// deactivate
|
||||
} elseif( acf_verify_nonce('deactivate_pro_licence') ) {
|
||||
|
||||
$this->deactivate_pro_licence();
|
||||
|
||||
}
|
||||
|
||||
|
||||
// vars
|
||||
$license = acf_pro_get_license_key();
|
||||
$this->view = array(
|
||||
'license' => $license,
|
||||
'active' => $license ? 1 : 0,
|
||||
'current_version' => acf_get_setting('version'),
|
||||
'remote_version' => '',
|
||||
'update_available' => false,
|
||||
'changelog' => '',
|
||||
'upgrade_notice' => ''
|
||||
);
|
||||
|
||||
|
||||
// vars
|
||||
$info = acf_updates()->get_plugin_info('pro');
|
||||
|
||||
|
||||
// error
|
||||
if( is_wp_error($info) ) {
|
||||
|
||||
return $this->show_error( $info );
|
||||
|
||||
}
|
||||
|
||||
|
||||
// add info to view
|
||||
$this->view['remote_version'] = $info['version'];
|
||||
|
||||
|
||||
// add changelog if the remote version is '>' than the current version
|
||||
$version = acf_get_setting('version');
|
||||
|
||||
|
||||
// check if remote version is higher than current version
|
||||
if( version_compare($info['version'], $version, '>') ) {
|
||||
|
||||
// update view
|
||||
$this->view['update_available'] = true;
|
||||
$this->view['changelog'] = $this->get_changelog_section($info['changelog'], $info['version']);
|
||||
$this->view['upgrade_notice'] = $this->get_changelog_section($info['upgrade_notice'], $info['version']);
|
||||
|
||||
|
||||
// refresh transient
|
||||
// - avoids new version not available in plugin update list
|
||||
// - only request if license is active
|
||||
if( $license ) {
|
||||
|
||||
acf_updates()->refresh_plugins_transient();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* activate_pro_licence
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @type function
|
||||
* @date 16/01/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function activate_pro_licence() {
|
||||
|
||||
// connect
|
||||
$post = array(
|
||||
'acf_license' => $_POST['acf_pro_licence'],
|
||||
'acf_version' => acf_get_setting('version'),
|
||||
'wp_name' => get_bloginfo('name'),
|
||||
'wp_url' => home_url(),
|
||||
'wp_version' => get_bloginfo('version'),
|
||||
'wp_language' => get_bloginfo('language'),
|
||||
'wp_timezone' => get_option('timezone_string'),
|
||||
);
|
||||
|
||||
|
||||
// connect
|
||||
$response = acf_updates()->request('v2/plugins/activate?p=pro', $post);
|
||||
|
||||
|
||||
// ensure response is expected JSON array (not string)
|
||||
if( is_string($response) ) {
|
||||
$response = new WP_Error( 'server_error', esc_html($response) );
|
||||
}
|
||||
|
||||
|
||||
// error
|
||||
if( is_wp_error($response) ) {
|
||||
|
||||
return $this->show_error( $response );
|
||||
|
||||
}
|
||||
|
||||
|
||||
// success
|
||||
if( $response['status'] == 1 ) {
|
||||
|
||||
// update license
|
||||
acf_pro_update_license( $response['license'] );
|
||||
|
||||
|
||||
// show message
|
||||
$this->show_notice( $response['message'] );
|
||||
|
||||
} else {
|
||||
|
||||
// show error
|
||||
$this->show_error( $response['message'] );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* deactivate_pro_licence
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @type function
|
||||
* @date 16/01/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function deactivate_pro_licence() {
|
||||
|
||||
// vars
|
||||
$license = acf_pro_get_license_key();
|
||||
|
||||
|
||||
// bail early if no key
|
||||
if( !$license ) return;
|
||||
|
||||
|
||||
// connect
|
||||
$post = array(
|
||||
'acf_license' => $license,
|
||||
'wp_url' => home_url(),
|
||||
);
|
||||
|
||||
|
||||
// connect
|
||||
$response = acf_updates()->request('v2/plugins/deactivate?p=pro', $post);
|
||||
|
||||
|
||||
// ensure response is expected JSON array (not string)
|
||||
if( is_string($response) ) {
|
||||
$response = new WP_Error( 'server_error', esc_html($response) );
|
||||
}
|
||||
|
||||
|
||||
// error
|
||||
if( is_wp_error($response) ) {
|
||||
|
||||
return $this->show_error( $response );
|
||||
|
||||
}
|
||||
|
||||
|
||||
// clear DB
|
||||
acf_pro_update_license('');
|
||||
|
||||
|
||||
// success
|
||||
if( $response['status'] == 1 ) {
|
||||
|
||||
// show message
|
||||
$this->show_notice( $response['message'] );
|
||||
|
||||
} else {
|
||||
|
||||
// show error
|
||||
$this->show_error( $response['message'] );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* html
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @type function
|
||||
* @date 7/01/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function html() {
|
||||
|
||||
// load view
|
||||
acf_get_view( dirname(__FILE__) . '/views/html-settings-updates.php', $this->view);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// initialize
|
||||
new acf_admin_settings_updates();
|
||||
|
||||
endif; // class_exists check
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,44 @@
|
||||
<div class="wrap acf-settings-wrap">
|
||||
|
||||
<h1><?php echo $page_title; ?></h1>
|
||||
|
||||
<form id="post" method="post" name="post">
|
||||
|
||||
<?php
|
||||
|
||||
// render post data
|
||||
acf_form_data(array(
|
||||
'post_id' => $post_id,
|
||||
'nonce' => 'options',
|
||||
));
|
||||
|
||||
wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
|
||||
wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
|
||||
|
||||
?>
|
||||
|
||||
<div id="poststuff">
|
||||
|
||||
<div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>">
|
||||
|
||||
<div id="postbox-container-1" class="postbox-container">
|
||||
|
||||
<?php do_meta_boxes('acf_options_page', 'side', null); ?>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="postbox-container-2" class="postbox-container">
|
||||
|
||||
<?php do_meta_boxes('acf_options_page', 'normal', null); ?>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<br class="clear">
|
||||
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
@@ -0,0 +1,142 @@
|
||||
<?php
|
||||
|
||||
// vars
|
||||
$active = $license ? true : false;
|
||||
$nonce = $active ? 'deactivate_pro_licence' : 'activate_pro_licence';
|
||||
$input = $active ? 'password' : 'text';
|
||||
$button = $active ? __('Deactivate License', 'acf') : __('Activate License', 'acf');
|
||||
$readonly = $active ? 1 : 0;
|
||||
|
||||
?>
|
||||
<div class="wrap acf-settings-wrap">
|
||||
|
||||
<h1><?php _e('Updates', 'acf'); ?></h1>
|
||||
|
||||
<div class="acf-box" id="acf-license-information">
|
||||
<div class="title">
|
||||
<h3><?php _e('License Information', 'acf'); ?></h3>
|
||||
</div>
|
||||
<div class="inner">
|
||||
<p><?php printf(__('To unlock updates, please enter your license key below. If you don\'t have a licence key, please see <a href="%s" target="_blank">details & pricing</a>.','acf'), esc_url('https://www.advancedcustomfields.com/pro')); ?></p>
|
||||
<form action="" method="post">
|
||||
<div class="acf-hidden">
|
||||
<?php acf_nonce_input($nonce); ?>
|
||||
</div>
|
||||
<table class="form-table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>
|
||||
<label for="acf-field-acf_pro_licence"><?php _e('License Key', 'acf'); ?></label>
|
||||
</th>
|
||||
<td>
|
||||
<?php
|
||||
|
||||
// render field
|
||||
acf_render_field(array(
|
||||
'type' => $input,
|
||||
'name' => 'acf_pro_licence',
|
||||
'value' => str_repeat('*', strlen($license)),
|
||||
'readonly' => $readonly
|
||||
));
|
||||
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th></th>
|
||||
<td>
|
||||
<input type="submit" value="<?php echo $button; ?>" class="button button-primary">
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="acf-box" id="acf-update-information">
|
||||
<div class="title">
|
||||
<h3><?php _e('Update Information', 'acf'); ?></h3>
|
||||
</div>
|
||||
<div class="inner">
|
||||
<table class="form-table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>
|
||||
<label><?php _e('Current Version', 'acf'); ?></label>
|
||||
</th>
|
||||
<td>
|
||||
<?php echo esc_html( $current_version ); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
<label><?php _e('Latest Version', 'acf'); ?></label>
|
||||
</th>
|
||||
<td>
|
||||
<?php echo esc_html( $remote_version ); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
<label><?php _e('Update Available', 'acf'); ?></label>
|
||||
</th>
|
||||
<td>
|
||||
<?php if( $update_available ): ?>
|
||||
|
||||
<span style="margin-right: 5px;"><?php _e('Yes', 'acf'); ?></span>
|
||||
|
||||
<?php if( $active ): ?>
|
||||
<a class="button button-primary" href="<?php echo admin_url('plugins.php?s=Advanced+Custom+Fields+Pro'); ?>"><?php _e('Update Plugin', 'acf'); ?></a>
|
||||
<?php else: ?>
|
||||
<a class="button" disabled="disabled" href="#"><?php _e('Please enter your license key above to unlock updates', 'acf'); ?></a>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php else: ?>
|
||||
|
||||
<span style="margin-right: 5px;"><?php _e('No', 'acf'); ?></span>
|
||||
<a class="button" href="<?php echo add_query_arg('force-check', 1); ?>"><?php _e('Check Again', 'acf'); ?></a>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php if( $changelog ): ?>
|
||||
<tr>
|
||||
<th>
|
||||
<label><?php _e('Changelog', 'acf'); ?></label>
|
||||
</th>
|
||||
<td>
|
||||
<?php echo acf_esc_html( $changelog ); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<?php if( $upgrade_notice ): ?>
|
||||
<tr>
|
||||
<th>
|
||||
<label><?php _e('Upgrade Notice', 'acf'); ?></label>
|
||||
</th>
|
||||
<td>
|
||||
<?php echo acf_esc_html( $upgrade_notice ); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<style type="text/css">
|
||||
#acf_pro_licence {
|
||||
width: 75%;
|
||||
}
|
||||
|
||||
#acf-update-information td h4 {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,67 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
*
|
||||
* Flexible Content
|
||||
*
|
||||
*---------------------------------------------------------------------------------------------*/
|
||||
.acf-fc-meta {
|
||||
margin: 0 0 10px;
|
||||
padding: 0;
|
||||
}
|
||||
.acf-fc-meta li {
|
||||
margin: 0 0 10px;
|
||||
padding: 0;
|
||||
}
|
||||
.acf-fc-meta .acf-fc-meta-key {
|
||||
display: none;
|
||||
}
|
||||
.acf-fc-meta .acf-fc-meta-display,
|
||||
.acf-fc-meta .acf-fc-meta-min {
|
||||
float: left;
|
||||
width: 33%;
|
||||
padding-right: 10px;
|
||||
}
|
||||
.acf-input-wrap.select {
|
||||
border-radius: 0 3px 3px 0 !important;
|
||||
border: #DFDFDF solid 1px;
|
||||
}
|
||||
.acf-input-wrap.select select {
|
||||
margin: 0;
|
||||
border: 0 none;
|
||||
padding: 3px;
|
||||
height: 26px;
|
||||
}
|
||||
.acf-fc-meta-label .acf-input-prepend,
|
||||
.acf-fc-meta-name .acf-input-prepend,
|
||||
.acf-fc-meta-display .acf-input-prepend {
|
||||
min-width: 45px;
|
||||
}
|
||||
.acf-fl-actions {
|
||||
visibility: hidden;
|
||||
}
|
||||
.acf-field:hover .acf-fl-actions {
|
||||
visibility: visible;
|
||||
}
|
||||
.acf-fl-actions a {
|
||||
display: block;
|
||||
line-height: 20px;
|
||||
padding: 1px 0;
|
||||
font-size: 13px;
|
||||
}
|
||||
.acf-fl-actions a.ui-sortable-handle {
|
||||
cursor: move;
|
||||
}
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
*
|
||||
* Clone
|
||||
*
|
||||
*---------------------------------------------------------------------------------------------*/
|
||||
.acf-field-object-clone {
|
||||
/* group */
|
||||
/* seamless */
|
||||
}
|
||||
.acf-field-object-clone[data-display="seamless"] .acf-field-setting-instructions,
|
||||
.acf-field-object-clone[data-display="seamless"] .acf-field-setting-layout,
|
||||
.acf-field-object-clone[data-display="seamless"] .acf-field-setting-wrapper,
|
||||
.acf-field-object-clone[data-display="seamless"] .acf-field-setting-conditional_logic {
|
||||
display: none;
|
||||
}
|
||||
@@ -0,0 +1,670 @@
|
||||
/*--------------------------------------------------------------------------------------------
|
||||
*
|
||||
* Vars
|
||||
*
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
/* colors */
|
||||
/* acf-field */
|
||||
/* responsive */
|
||||
/*--------------------------------------------------------------------------------------------
|
||||
*
|
||||
* Mixins
|
||||
*
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
*
|
||||
* Repeater
|
||||
*
|
||||
*---------------------------------------------------------------------------------------------*/
|
||||
.acf-repeater {
|
||||
/* table */
|
||||
/* row handle (add/remove) */
|
||||
/* add in spacer to th (force correct width) */
|
||||
/* row */
|
||||
/* sortable */
|
||||
/* layouts */
|
||||
/*
|
||||
&.-row > table > tbody > tr:before,
|
||||
&.-block > table > tbody > tr:before {
|
||||
content: "";
|
||||
display: table-row;
|
||||
height: 2px;
|
||||
background: #f00;
|
||||
}
|
||||
*/
|
||||
/* empty */
|
||||
/* collapsed */
|
||||
/* collapsed (block layout) */
|
||||
/* collapsed (table layout) */
|
||||
}
|
||||
.acf-repeater > table {
|
||||
margin: 0 0 8px;
|
||||
background: #F9F9F9;
|
||||
}
|
||||
.acf-repeater .acf-row-handle {
|
||||
width: 16px;
|
||||
text-align: center !important;
|
||||
vertical-align: middle !important;
|
||||
position: relative;
|
||||
/* icons */
|
||||
/* .order */
|
||||
/* remove */
|
||||
}
|
||||
.acf-repeater .acf-row-handle .acf-icon {
|
||||
display: none;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
margin: -8px 0 0 -2px;
|
||||
/* minus icon */
|
||||
}
|
||||
.acf-repeater .acf-row-handle .acf-icon.-minus {
|
||||
top: 50%;
|
||||
/* ie fix */
|
||||
}
|
||||
body.browser-msie .acf-repeater .acf-row-handle .acf-icon.-minus {
|
||||
top: 25px;
|
||||
}
|
||||
.acf-repeater .acf-row-handle.order {
|
||||
background: #f4f4f4;
|
||||
cursor: move;
|
||||
color: #aaa;
|
||||
text-shadow: #fff 0 1px 0;
|
||||
}
|
||||
.acf-repeater .acf-row-handle.order:hover {
|
||||
color: #666;
|
||||
}
|
||||
.acf-repeater .acf-row-handle.order + td {
|
||||
border-left-color: #DFDFDF;
|
||||
}
|
||||
.acf-repeater .acf-row-handle.remove {
|
||||
background: #F9F9F9;
|
||||
border-left-color: #DFDFDF;
|
||||
}
|
||||
.acf-repeater th.acf-row-handle:before {
|
||||
content: "";
|
||||
width: 16px;
|
||||
display: block;
|
||||
height: 1px;
|
||||
}
|
||||
.acf-repeater .acf-row {
|
||||
/* hide clone */
|
||||
/* hover */
|
||||
}
|
||||
.acf-repeater .acf-row.acf-clone {
|
||||
display: none !important;
|
||||
}
|
||||
.acf-repeater .acf-row:hover,
|
||||
.acf-repeater .acf-row.-hover {
|
||||
/* icons */
|
||||
}
|
||||
.acf-repeater .acf-row:hover > .acf-row-handle .acf-icon,
|
||||
.acf-repeater .acf-row.-hover > .acf-row-handle .acf-icon {
|
||||
display: block;
|
||||
}
|
||||
.acf-repeater > table > tbody > tr.ui-sortable-helper {
|
||||
box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
.acf-repeater > table > tbody > tr.ui-sortable-placeholder {
|
||||
visibility: visible !important;
|
||||
}
|
||||
.acf-repeater > table > tbody > tr.ui-sortable-placeholder td {
|
||||
background: #F9F9F9;
|
||||
}
|
||||
.acf-repeater.-row > table > tbody > tr > td,
|
||||
.acf-repeater.-block > table > tbody > tr > td {
|
||||
border-top-color: #E1E1E1;
|
||||
}
|
||||
.acf-repeater.-empty > table {
|
||||
border-bottom: 0 none;
|
||||
}
|
||||
.acf-repeater.-empty.-row > table,
|
||||
.acf-repeater.-empty.-block > table {
|
||||
display: none;
|
||||
}
|
||||
.acf-repeater .acf-row.-collapsed > .acf-field {
|
||||
display: none !important;
|
||||
}
|
||||
.acf-repeater .acf-row.-collapsed > td.acf-field.-collapsed-target {
|
||||
display: table-cell !important;
|
||||
}
|
||||
.acf-repeater .acf-row.-collapsed > .acf-fields > * {
|
||||
display: none !important;
|
||||
}
|
||||
.acf-repeater .acf-row.-collapsed > .acf-fields > .acf-field.-collapsed-target {
|
||||
display: block !important;
|
||||
}
|
||||
.acf-repeater.-table .acf-row.-collapsed .acf-field.-collapsed-target {
|
||||
border-left-color: #dfdfdf;
|
||||
}
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
*
|
||||
* Flexible Content
|
||||
*
|
||||
*---------------------------------------------------------------------------------------------*/
|
||||
.acf-flexible-content {
|
||||
position: relative;
|
||||
}
|
||||
.acf-flexible-content > .no-value-message {
|
||||
padding: 19px;
|
||||
border: #ccc dashed 2px;
|
||||
text-align: center;
|
||||
}
|
||||
.acf-flexible-content > .clones {
|
||||
display: none;
|
||||
}
|
||||
.acf-flexible-content > .values {
|
||||
margin: 0 0 8px;
|
||||
}
|
||||
.acf-flexible-content .layout {
|
||||
position: relative;
|
||||
margin: 20px 0 0;
|
||||
background: #fff;
|
||||
border: 1px solid #e1e1e1;
|
||||
}
|
||||
.acf-flexible-content .layout:first-child {
|
||||
margin-top: 0;
|
||||
}
|
||||
.acf-flexible-content .layout .acf-fc-layout-handle {
|
||||
display: block;
|
||||
position: relative;
|
||||
padding: 8px 10px;
|
||||
cursor: move;
|
||||
border-bottom: #E1E1E1 solid 1px;
|
||||
color: #333333;
|
||||
font-size: 14px;
|
||||
line-height: 1.4em;
|
||||
}
|
||||
.acf-flexible-content .layout .acf-fc-layout-order {
|
||||
display: block;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
border-radius: 10px;
|
||||
display: inline-block;
|
||||
text-align: center;
|
||||
line-height: 20px;
|
||||
margin: 0 2px 0 0;
|
||||
background: #F1F1F1;
|
||||
font-size: 12px;
|
||||
color: #666;
|
||||
}
|
||||
/* controlls*/
|
||||
.acf-flexible-content {
|
||||
/* layout */
|
||||
}
|
||||
.acf-flexible-content .layout {
|
||||
/* controlls */
|
||||
/* hover */
|
||||
}
|
||||
.acf-flexible-content .layout .acf-fc-layout-controlls {
|
||||
position: absolute;
|
||||
top: 8px;
|
||||
right: 8px;
|
||||
}
|
||||
.acf-flexible-content .layout .acf-fc-layout-controlls .acf-icon {
|
||||
display: block;
|
||||
float: left;
|
||||
margin: 0 0 0 5px;
|
||||
}
|
||||
.acf-flexible-content .layout .acf-fc-layout-controlls .acf-icon.-plus,
|
||||
.acf-flexible-content .layout .acf-fc-layout-controlls .acf-icon.-minus {
|
||||
visibility: hidden;
|
||||
}
|
||||
.acf-flexible-content .layout .acf-fc-layout-controlls .acf-icon.-collapse {
|
||||
color: #72777c;
|
||||
border-color: transparent;
|
||||
}
|
||||
.acf-flexible-content .layout .acf-fc-layout-controlls .acf-icon.-collapse:hover {
|
||||
color: #23282d;
|
||||
background: transparent;
|
||||
}
|
||||
.acf-flexible-content .layout:hover .acf-fc-layout-controlls .acf-icon.-plus,
|
||||
.acf-flexible-content .layout.-open .acf-fc-layout-controlls .acf-icon.-plus,
|
||||
.acf-flexible-content .layout:hover .acf-fc-layout-controlls .acf-icon.-minus,
|
||||
.acf-flexible-content .layout.-open .acf-fc-layout-controlls .acf-icon.-minus {
|
||||
visibility: visible;
|
||||
}
|
||||
.acf-flexible-content > .values > .ui-sortable-placeholder {
|
||||
visibility: visible !important;
|
||||
border: 1px dashed #b4b9be;
|
||||
box-shadow: none;
|
||||
background: transparent;
|
||||
}
|
||||
/* collapsed */
|
||||
.acf-flexible-content .layout.-collapsed .acf-fc-layout-handle {
|
||||
border-bottom-width: 0;
|
||||
}
|
||||
.acf-flexible-content .layout.-collapsed > .acf-fields,
|
||||
.acf-flexible-content .layout.-collapsed > .acf-table {
|
||||
display: none;
|
||||
}
|
||||
/* table */
|
||||
.acf-flexible-content .layout > .acf-table {
|
||||
border: 0 none;
|
||||
box-shadow: none;
|
||||
}
|
||||
.acf-flexible-content .layout > .acf-table > tbody > tr {
|
||||
background: #fff;
|
||||
}
|
||||
.acf-flexible-content .layout > .acf-table > thead > tr > th {
|
||||
background: #F9F9F9;
|
||||
}
|
||||
/* popup */
|
||||
.acf-fc-popup {
|
||||
background: #2F353E;
|
||||
border-radius: 5px;
|
||||
color: #fff;
|
||||
padding: 7px 0;
|
||||
position: absolute;
|
||||
font-size: 13px;
|
||||
z-index: 900000;
|
||||
min-width: 135px;
|
||||
/* tip */
|
||||
/* positions */
|
||||
/* list */
|
||||
}
|
||||
.acf-fc-popup:before {
|
||||
border: solid;
|
||||
border-color: transparent;
|
||||
border-width: 6px;
|
||||
content: "";
|
||||
position: absolute;
|
||||
}
|
||||
.acf-fc-popup.-top {
|
||||
margin-top: -8px;
|
||||
}
|
||||
.acf-fc-popup.-top:before {
|
||||
top: 100%;
|
||||
left: 50%;
|
||||
margin-left: -6px;
|
||||
border-top-color: #2F353E;
|
||||
border-bottom-width: 0;
|
||||
}
|
||||
.acf-fc-popup.-bottom {
|
||||
margin-bottom: -8px;
|
||||
}
|
||||
.acf-fc-popup.-bottom:before {
|
||||
bottom: 100%;
|
||||
left: 50%;
|
||||
margin-left: -6px;
|
||||
border-bottom-color: #2F353E;
|
||||
border-top-width: 0;
|
||||
}
|
||||
.acf-fc-popup.-right:before {
|
||||
left: 18px;
|
||||
}
|
||||
.acf-fc-popup.-left:before {
|
||||
left: auto;
|
||||
right: 18px;
|
||||
}
|
||||
.acf-fc-popup ul,
|
||||
.acf-fc-popup li {
|
||||
list-style: none;
|
||||
display: block;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
.acf-fc-popup li {
|
||||
position: relative;
|
||||
float: none;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.acf-fc-popup .badge {
|
||||
display: inline-block;
|
||||
border-radius: 8px;
|
||||
font-size: 9px;
|
||||
line-height: 15px;
|
||||
padding: 0 7px;
|
||||
background: #d54e21;
|
||||
text-align: center;
|
||||
color: #fff;
|
||||
vertical-align: top;
|
||||
margin: 0 0 0 5px;
|
||||
}
|
||||
.acf-fc-popup a {
|
||||
color: #eee;
|
||||
font-size: 13px;
|
||||
line-height: 16px;
|
||||
padding: 7px 12px;
|
||||
display: block;
|
||||
text-decoration: none;
|
||||
position: relative;
|
||||
}
|
||||
.acf-fc-popup a:hover {
|
||||
background: #0073aa;
|
||||
color: #fff;
|
||||
}
|
||||
.acf-fc-popup a.disabled {
|
||||
color: #888;
|
||||
background: transparent;
|
||||
}
|
||||
.acf-fc-popup ul li a:hover .status {
|
||||
border-color: #fff;
|
||||
color: #fff;
|
||||
}
|
||||
/* rtl */
|
||||
html[dir="rtl"] .acf-flexible-content .layout .acf-fc-layout-order {
|
||||
float: right;
|
||||
margin-right: 0;
|
||||
margin-left: 5px;
|
||||
}
|
||||
html[dir="rtl"] .acf-flexible-content .layout .acf-fc-layout-controlls {
|
||||
right: auto;
|
||||
left: 9px;
|
||||
}
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
*
|
||||
* Galery
|
||||
*
|
||||
*---------------------------------------------------------------------------------------------*/
|
||||
.acf-gallery {
|
||||
border: #DFDFDF solid 1px;
|
||||
height: 400px;
|
||||
position: relative;
|
||||
/* main */
|
||||
/* attachments */
|
||||
/* attachment */
|
||||
/* toolbar */
|
||||
/* sidebar */
|
||||
/* side info */
|
||||
/* side data */
|
||||
/* column widths */
|
||||
/* resizable */
|
||||
}
|
||||
.acf-gallery .acf-gallery-main {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
background: #fff;
|
||||
z-index: 2;
|
||||
}
|
||||
.acf-gallery .acf-gallery-attachments {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 48px;
|
||||
left: 0;
|
||||
padding: 5px;
|
||||
overflow: auto;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
.acf-gallery .acf-gallery-attachment {
|
||||
width: 25%;
|
||||
float: left;
|
||||
cursor: pointer;
|
||||
position: relative;
|
||||
/* hover */
|
||||
/* sortable */
|
||||
/* active */
|
||||
/* icon */
|
||||
/* rtl */
|
||||
}
|
||||
.acf-gallery .acf-gallery-attachment .margin {
|
||||
margin: 5px;
|
||||
border: #DFDFDF solid 1px;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
background: #eee;
|
||||
}
|
||||
.acf-gallery .acf-gallery-attachment .margin:before {
|
||||
content: "";
|
||||
display: block;
|
||||
padding-top: 100%;
|
||||
}
|
||||
.acf-gallery .acf-gallery-attachment .thumbnail {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
transform: translate(50%, 50%);
|
||||
}
|
||||
html[dir="rtl"] .acf-gallery .acf-gallery-attachment .thumbnail {
|
||||
transform: translate(-50%, 50%);
|
||||
}
|
||||
.acf-gallery .acf-gallery-attachment .thumbnail img {
|
||||
display: block;
|
||||
height: auto;
|
||||
max-height: 100%;
|
||||
width: auto;
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
html[dir="rtl"] .acf-gallery .acf-gallery-attachment .thumbnail img {
|
||||
transform: translate(50%, -50%);
|
||||
}
|
||||
.acf-gallery .acf-gallery-attachment .filename {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
padding: 5%;
|
||||
background: #F4F4F4;
|
||||
background: rgba(255, 255, 255, 0.8);
|
||||
border-top: #DFDFDF solid 1px;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
word-wrap: break-word;
|
||||
max-height: 90%;
|
||||
overflow: hidden;
|
||||
}
|
||||
.acf-gallery .acf-gallery-attachment .actions {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
display: none;
|
||||
}
|
||||
.acf-gallery .acf-gallery-attachment:hover .actions {
|
||||
display: block;
|
||||
}
|
||||
.acf-gallery .acf-gallery-attachment.ui-sortable-helper .margin {
|
||||
border: none;
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
.acf-gallery .acf-gallery-attachment.ui-sortable-placeholder .margin {
|
||||
background: #F1F1F1;
|
||||
border: none;
|
||||
}
|
||||
.acf-gallery .acf-gallery-attachment.ui-sortable-placeholder .margin * {
|
||||
display: none !important;
|
||||
}
|
||||
.acf-gallery .acf-gallery-attachment.active .margin {
|
||||
box-shadow: 0 0 0 1px #FFFFFF, 0 0 0 5px #1E8CBE;
|
||||
}
|
||||
.acf-gallery .acf-gallery-attachment.-icon .thumbnail img {
|
||||
transform: translate(-50%, -70%);
|
||||
}
|
||||
html[dir="rtl"] .acf-gallery .acf-gallery-attachment {
|
||||
float: right;
|
||||
}
|
||||
.acf-gallery.sidebar-open {
|
||||
/* hide attachment actions when sidebar is open */
|
||||
/* allow sidebar to move over main for small widths (widget edit box) */
|
||||
}
|
||||
.acf-gallery.sidebar-open .acf-gallery-attachment .actions {
|
||||
display: none;
|
||||
}
|
||||
.acf-gallery.sidebar-open .acf-gallery-side {
|
||||
z-index: 2;
|
||||
}
|
||||
.acf-gallery .acf-gallery-toolbar {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
padding: 10px;
|
||||
border-top: #DFDFDF solid 1px;
|
||||
background: #fff;
|
||||
min-height: 28px;
|
||||
}
|
||||
.acf-gallery .acf-gallery-toolbar .acf-hl li {
|
||||
line-height: 24px;
|
||||
}
|
||||
.acf-gallery .acf-gallery-toolbar .bulk-actions-select {
|
||||
width: auto;
|
||||
margin: 0 1px 0 0;
|
||||
}
|
||||
.acf-gallery .acf-gallery-side {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
width: 0;
|
||||
background: #F9F9F9;
|
||||
border-left: #DFDFDF solid 1px;
|
||||
z-index: 1;
|
||||
overflow: hidden;
|
||||
}
|
||||
.acf-gallery .acf-gallery-side .acf-gallery-side-inner {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
width: 349px;
|
||||
}
|
||||
.acf-gallery .acf-gallery-side-info {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
margin: -10px 0 15px -10px;
|
||||
background: #F1F1F1;
|
||||
border-bottom: #DFDFDF solid 1px;
|
||||
}
|
||||
.acf-gallery .acf-gallery-side-info:after {
|
||||
clear: both;
|
||||
content: "";
|
||||
display: table;
|
||||
}
|
||||
html[dir="rtl"] .acf-gallery .acf-gallery-side-info {
|
||||
margin-left: 0;
|
||||
margin-right: -10px;
|
||||
}
|
||||
.acf-gallery .acf-gallery-side-info img {
|
||||
float: left;
|
||||
width: auto;
|
||||
max-width: 65px;
|
||||
max-height: 65px;
|
||||
margin: 0 10px 1px 0;
|
||||
background: #FFFFFF;
|
||||
padding: 3px;
|
||||
border: #DFDFDF solid 1px;
|
||||
border-radius: 1px;
|
||||
/* rtl */
|
||||
}
|
||||
html[dir="rtl"] .acf-gallery .acf-gallery-side-info img {
|
||||
float: right;
|
||||
margin: 0 0 0 10px;
|
||||
}
|
||||
.acf-gallery .acf-gallery-side-info p {
|
||||
font-size: 13px;
|
||||
line-height: 15px;
|
||||
margin: 3px 0;
|
||||
word-break: break-all;
|
||||
color: #999999;
|
||||
}
|
||||
.acf-gallery .acf-gallery-side-info p strong {
|
||||
color: #000;
|
||||
}
|
||||
.acf-gallery .acf-gallery-side-info a {
|
||||
text-decoration: none;
|
||||
}
|
||||
.acf-gallery .acf-gallery-side-info a.acf-gallery-edit {
|
||||
color: #21759b;
|
||||
}
|
||||
.acf-gallery .acf-gallery-side-info a.acf-gallery-remove {
|
||||
color: #bc0b0b;
|
||||
}
|
||||
.acf-gallery .acf-gallery-side-info a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
.acf-gallery .acf-gallery-side-data {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 48px;
|
||||
left: 0;
|
||||
overflow: auto;
|
||||
overflow-x: inherit;
|
||||
padding: 10px;
|
||||
}
|
||||
.acf-gallery .acf-gallery-side-data .acf-label,
|
||||
.acf-gallery .acf-gallery-side-data th.label {
|
||||
color: #666666;
|
||||
font-size: 12px;
|
||||
line-height: 25px;
|
||||
padding: 0 4px 8px 0 !important;
|
||||
width: auto !important;
|
||||
vertical-align: top;
|
||||
}
|
||||
html[dir="rtl"] .acf-gallery .acf-gallery-side-data .acf-label,
|
||||
html[dir="rtl"] .acf-gallery .acf-gallery-side-data th.label {
|
||||
padding: 0 0 8px 4px !important;
|
||||
}
|
||||
.acf-gallery .acf-gallery-side-data .acf-label label,
|
||||
.acf-gallery .acf-gallery-side-data th.label label {
|
||||
font-weight: normal;
|
||||
}
|
||||
.acf-gallery .acf-gallery-side-data .acf-input,
|
||||
.acf-gallery .acf-gallery-side-data td.field {
|
||||
padding: 0 0 8px !important;
|
||||
}
|
||||
.acf-gallery .acf-gallery-side-data textarea {
|
||||
min-height: 0;
|
||||
height: 60px;
|
||||
}
|
||||
.acf-gallery .acf-gallery-side-data p.help {
|
||||
font-size: 12px;
|
||||
}
|
||||
.acf-gallery .acf-gallery-side-data p.help:hover {
|
||||
font-weight: normal;
|
||||
}
|
||||
.acf-gallery[data-columns="1"] .acf-gallery-attachment {
|
||||
width: 100%;
|
||||
}
|
||||
.acf-gallery[data-columns="2"] .acf-gallery-attachment {
|
||||
width: 50%;
|
||||
}
|
||||
.acf-gallery[data-columns="3"] .acf-gallery-attachment {
|
||||
width: 33.333%;
|
||||
}
|
||||
.acf-gallery[data-columns="4"] .acf-gallery-attachment {
|
||||
width: 25%;
|
||||
}
|
||||
.acf-gallery[data-columns="5"] .acf-gallery-attachment {
|
||||
width: 20%;
|
||||
}
|
||||
.acf-gallery[data-columns="6"] .acf-gallery-attachment {
|
||||
width: 16.666%;
|
||||
}
|
||||
.acf-gallery[data-columns="7"] .acf-gallery-attachment {
|
||||
width: 14.285%;
|
||||
}
|
||||
.acf-gallery[data-columns="8"] .acf-gallery-attachment {
|
||||
width: 12.5%;
|
||||
}
|
||||
.acf-gallery .ui-resizable-handle {
|
||||
display: block;
|
||||
position: absolute;
|
||||
}
|
||||
.acf-gallery .ui-resizable-s {
|
||||
bottom: -5px;
|
||||
cursor: ns-resize;
|
||||
height: 7px;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
}
|
||||
/* media modal selected */
|
||||
.acf-media-modal .attachment.acf-selected {
|
||||
box-shadow: 0 0 0 3px #fff inset, 0 0 0 7px #0073aa inset !important;
|
||||
}
|
||||
.acf-media-modal .attachment.acf-selected .check {
|
||||
display: none !important;
|
||||
}
|
||||
.acf-media-modal .attachment.acf-selected .thumbnail {
|
||||
opacity: 0.25 !important;
|
||||
}
|
||||
.acf-media-modal .attachment.acf-selected .attachment-preview:before {
|
||||
background: rgba(0, 0, 0, 0.15);
|
||||
z-index: 1;
|
||||
position: relative;
|
||||
}
|
||||
@@ -0,0 +1,573 @@
|
||||
(function($){
|
||||
|
||||
/*
|
||||
* Repeater
|
||||
*
|
||||
* This field type requires some extra logic for its settings
|
||||
*
|
||||
* @type function
|
||||
* @date 24/10/13
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
var acf_settings_repeater = acf.field_group.field_object.extend({
|
||||
|
||||
type: 'repeater',
|
||||
|
||||
actions: {
|
||||
'render_settings': 'render'
|
||||
},
|
||||
|
||||
events: {
|
||||
'change .acf-field-setting-layout input': '_change_layout',
|
||||
'focus .acf-field-setting-collapsed select': '_focus_collapsed'
|
||||
},
|
||||
|
||||
focus: function(){
|
||||
|
||||
this.$fields = this.$field.find('.acf-field-list:first');
|
||||
|
||||
},
|
||||
|
||||
render: function(){
|
||||
|
||||
this.render_layout();
|
||||
this.render_collapsed();
|
||||
|
||||
},
|
||||
|
||||
render_layout: function(){
|
||||
|
||||
// vars
|
||||
var layout = this.setting('layout input:checked').val();
|
||||
|
||||
|
||||
// update data
|
||||
this.$fields.attr('data-layout', layout);
|
||||
|
||||
},
|
||||
|
||||
render_collapsed: function(){
|
||||
|
||||
// vars
|
||||
var $select = this.setting('collapsed select');
|
||||
|
||||
|
||||
// collapsed
|
||||
var choices = [];
|
||||
|
||||
|
||||
// keep 'null' choice
|
||||
choices.push({
|
||||
'label': $select.find('option[value=""]').text(),
|
||||
'value': ''
|
||||
});
|
||||
|
||||
|
||||
// loop
|
||||
this.$fields.children('.acf-field-object').each(function(){
|
||||
|
||||
// vars
|
||||
var $field = $(this);
|
||||
|
||||
|
||||
// append
|
||||
choices.push({
|
||||
'label': $field.find('.field-label:first').val(),
|
||||
'value': $field.attr('data-key')
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
// render
|
||||
acf.render_select( $select, choices );
|
||||
|
||||
},
|
||||
|
||||
_change_layout: function( e ){
|
||||
|
||||
this.render_layout();
|
||||
|
||||
},
|
||||
|
||||
_focus_collapsed: function( e ){
|
||||
|
||||
this.render_collapsed();
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
/*
|
||||
* flexible_content
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @type function
|
||||
* @date 25/09/2015
|
||||
* @since 5.2.3
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
var acf_settings_flexible_content = acf.field_group.field_object.extend({
|
||||
|
||||
type: 'flexible_content',
|
||||
|
||||
actions: {
|
||||
'render_settings': 'render'
|
||||
},
|
||||
|
||||
render: function(){
|
||||
|
||||
// reference
|
||||
var self = this,
|
||||
$field = this.$field;
|
||||
|
||||
|
||||
// sortable
|
||||
if( ! this.$settings.hasClass('ui-sortable') ) {
|
||||
|
||||
// add sortable
|
||||
this.$settings.sortable({
|
||||
items: '> .acf-field-setting-fc_layout',
|
||||
handle: '[data-name="acf-fc-reorder"]',
|
||||
forceHelperSize: true,
|
||||
forcePlaceholderSize: true,
|
||||
scroll: true,
|
||||
stop: function (event, ui) {
|
||||
|
||||
// save flexible content (layout order has changed)
|
||||
acf.field_group.save_field( $field );
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
// render layouts
|
||||
this.$settings.children('.acf-field-setting-fc_layout').each(function(){
|
||||
|
||||
self.layout.render( $(this) );
|
||||
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
|
||||
layout: null
|
||||
|
||||
});
|
||||
|
||||
|
||||
acf_settings_flexible_content.layout = acf.model.extend({
|
||||
|
||||
actions: {
|
||||
'update_field_parent': 'update_field_parent'
|
||||
},
|
||||
|
||||
events: {
|
||||
'change .acf-fc-meta-display select': '_change_display',
|
||||
'blur .acf-fc-meta-label input': '_blur_label',
|
||||
'click a[data-name="acf-fc-add"]': '_add',
|
||||
'click a[data-name="acf-fc-duplicate"]': '_duplicate',
|
||||
'click a[data-name="acf-fc-delete"]': '_delete'
|
||||
},
|
||||
|
||||
event: function( e ){
|
||||
|
||||
return e.$el.closest('.acf-field-setting-fc_layout');
|
||||
|
||||
},
|
||||
|
||||
update_meta: function( $field, $layout ){
|
||||
|
||||
acf.field_group.update_field_meta( $field, 'parent_layout', $layout.attr('data-id') );
|
||||
|
||||
},
|
||||
|
||||
delete_meta: function( $field ){
|
||||
|
||||
acf.field_group.delete_field_meta( $field, 'parent_layout' );
|
||||
|
||||
},
|
||||
|
||||
|
||||
/*
|
||||
* update_field_parent
|
||||
*
|
||||
* this function will update a sub field's 'parent_layout' meta data
|
||||
*
|
||||
* @type function
|
||||
* @date 16/11/16
|
||||
* @since 5.5.0
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
update_field_parent: function( $el, $parent ){
|
||||
|
||||
// vars
|
||||
var $layout = $el.closest('.acf-field-setting-fc_layout');
|
||||
|
||||
|
||||
// bail early if not a sub field of a flexible content field
|
||||
// - don't save field as lack of 'parent' will avoid any issues with field's 'parent_layout' setting
|
||||
if( !$layout.exists() ) {
|
||||
|
||||
return this.delete_meta( $el );
|
||||
|
||||
}
|
||||
|
||||
|
||||
// update meta
|
||||
this.update_meta( $el, $layout );
|
||||
|
||||
|
||||
// save field
|
||||
// - parent_layout meta needs to be saved within the post_content serialized array
|
||||
acf.field_group.save_field( $el );
|
||||
|
||||
},
|
||||
|
||||
|
||||
/*
|
||||
* render
|
||||
*
|
||||
* This function will update the field list class
|
||||
*
|
||||
* @type function
|
||||
* @date 8/04/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $field_list
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
render: function( $el ){
|
||||
|
||||
// reference
|
||||
var self = this;
|
||||
|
||||
|
||||
// vars
|
||||
var $key = $el.find('.acf-fc-meta-key:first input'),
|
||||
$fields = $el.find('.acf-field-list:first'),
|
||||
display = $el.find('.acf-fc-meta-display:first select').val();
|
||||
|
||||
|
||||
// update key
|
||||
// - both duplicate and add function need this
|
||||
$key.val( $el.attr('data-id') );
|
||||
|
||||
|
||||
// update data
|
||||
$fields.attr('data-layout', display);
|
||||
|
||||
|
||||
// update meta
|
||||
$fields.children('.acf-field-object').each(function(){
|
||||
|
||||
self.update_meta( $(this), $el );
|
||||
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
|
||||
/*
|
||||
* events
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @type function
|
||||
* @date 25/09/2015
|
||||
* @since 5.2.3
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
_change_display: function( $el ){
|
||||
|
||||
this.render( $el );
|
||||
|
||||
},
|
||||
|
||||
_blur_label: function( $el ){
|
||||
|
||||
// vars
|
||||
var $label = $el.find('.acf-fc-meta-label:first input'),
|
||||
$name = $el.find('.acf-fc-meta-name:first input');
|
||||
|
||||
|
||||
// only if name is empty
|
||||
if( $name.val() == '' ) {
|
||||
|
||||
// vars
|
||||
var s = $label.val();
|
||||
|
||||
|
||||
// sanitize
|
||||
s = acf.str_sanitize(s);
|
||||
|
||||
|
||||
// update name
|
||||
$name.val( s ).trigger('change');
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
_add: function( $el ){
|
||||
|
||||
// duplicate
|
||||
var $el2 = acf.duplicate({
|
||||
$el: $el,
|
||||
after: function( $el, $el2 ){
|
||||
|
||||
// remove sub fields
|
||||
$el2.find('.acf-field-object').remove();
|
||||
|
||||
|
||||
// show add new message
|
||||
$el2.find('.no-fields-message').show();
|
||||
|
||||
|
||||
// reset layout meta values
|
||||
$el2.find('.acf-fc-meta input').val('');
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// render layout
|
||||
this.render( $el2 );
|
||||
|
||||
|
||||
// save field
|
||||
acf.field_group.save_field( $el.closest('.acf-field-object') );
|
||||
|
||||
},
|
||||
|
||||
_duplicate: function( $el ){
|
||||
|
||||
// duplicate
|
||||
$el2 = acf.duplicate( $el );
|
||||
|
||||
|
||||
// fire action 'duplicate_field' and allow acf.pro logic to clean sub fields
|
||||
acf.do_action('duplicate_field', $el2);
|
||||
|
||||
|
||||
// render layout
|
||||
this.render( $el2 );
|
||||
|
||||
|
||||
// save field
|
||||
acf.field_group.save_field( $el.closest('.acf-field-object') );
|
||||
|
||||
},
|
||||
|
||||
_delete: function( $el ){
|
||||
|
||||
// validate
|
||||
if( $el.siblings('.acf-field-setting-fc_layout').length == 0 ) {
|
||||
|
||||
alert( acf._e('flexible_content','layout_warning') );
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// delete fields
|
||||
$el.find('.acf-field-object').each(function(){
|
||||
|
||||
// delete without animation
|
||||
acf.field_group.delete_field( $(this), false );
|
||||
|
||||
});
|
||||
|
||||
|
||||
// remove tr
|
||||
acf.remove_tr( $el );
|
||||
|
||||
|
||||
// save field
|
||||
acf.field_group.save_field( $el.closest('.acf-field-object') );
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
/*
|
||||
* clone
|
||||
*
|
||||
* This field type requires some extra logic for its settings
|
||||
*
|
||||
* @type function
|
||||
* @date 24/10/13
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
var acf_settings_clone = acf.field_group.field_object.extend({
|
||||
|
||||
type: 'clone',
|
||||
|
||||
actions: {
|
||||
'render_settings': 'render'
|
||||
},
|
||||
|
||||
events: {
|
||||
'change .acf-field-setting-display select': 'render_display',
|
||||
'change .acf-field-setting-prefix_label input': 'render_prefix_label',
|
||||
'change .acf-field-setting-prefix_name input': 'render_prefix_name'
|
||||
},
|
||||
|
||||
render: function(){
|
||||
|
||||
// render
|
||||
this.render_display();
|
||||
this.render_prefix_label();
|
||||
this.render_prefix_name();
|
||||
|
||||
},
|
||||
|
||||
render_display: function(){
|
||||
|
||||
// vars
|
||||
var display = this.setting('display select').val()
|
||||
|
||||
|
||||
// update data
|
||||
this.$field.attr('data-display', display);
|
||||
|
||||
},
|
||||
|
||||
render_prefix_label: function(){
|
||||
|
||||
// vars
|
||||
var s = '%field_label%';
|
||||
|
||||
|
||||
// is checked
|
||||
if( this.setting('prefix_label input[type="checkbox"]').prop('checked') ) {
|
||||
|
||||
s = this.setting('label input[type="text"]').val() + ' ' + s;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// update code
|
||||
this.setting('prefix_label code').html( s );
|
||||
|
||||
},
|
||||
|
||||
render_prefix_name: function(){
|
||||
|
||||
// vars
|
||||
var s = '%field_name%';
|
||||
|
||||
|
||||
// is checked
|
||||
if( this.setting('prefix_name input[type="checkbox"]').prop('checked') ) {
|
||||
|
||||
s = this.setting('name input[type="text"]').val() + '_' + s;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// update code
|
||||
this.setting('prefix_name code').html( s );
|
||||
|
||||
},
|
||||
|
||||
select2: null
|
||||
|
||||
});
|
||||
|
||||
acf_settings_clone.select2 = acf.model.extend({
|
||||
|
||||
filters: {
|
||||
'select2_args': 'select2_args',
|
||||
'select2_ajax_data': 'select2_ajax_data'
|
||||
},
|
||||
|
||||
select2_args: function( select2_args, $select, args ){
|
||||
|
||||
// bail early if not clone
|
||||
if( args.ajax_action !== 'acf/fields/clone/query' ) return select2_args;
|
||||
|
||||
|
||||
// remain open on select
|
||||
select2_args.closeOnSelect = false;
|
||||
|
||||
|
||||
// return
|
||||
return select2_args;
|
||||
},
|
||||
|
||||
select2_ajax_data: function( data, args, params ){
|
||||
|
||||
// bail early if not clone
|
||||
if( args.ajax_action !== 'acf/fields/clone/query' ) return data;
|
||||
|
||||
|
||||
// find current fields
|
||||
var fields = {};
|
||||
|
||||
|
||||
// loop
|
||||
$('.acf-field-object').each(function(){
|
||||
|
||||
// vars
|
||||
var $el = $(this),
|
||||
key = $el.data('key'),
|
||||
type = $el.data('type'),
|
||||
label = $el.find('.field-label:first').val(),
|
||||
$ancestors = $el.parents('.acf-field-object');
|
||||
|
||||
|
||||
// label
|
||||
fields[ key ] = {
|
||||
'key': key,
|
||||
'type': type,
|
||||
'label': label,
|
||||
'ancestors': $ancestors.length
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
|
||||
// append fields
|
||||
data.fields = fields;
|
||||
|
||||
|
||||
// append title
|
||||
data.title = $('#title').val();
|
||||
|
||||
|
||||
// return
|
||||
return data;
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
|
||||
// @codekit-prepend "../js/field-group.js";
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
!function($){var e=acf.field_group.field_object.extend({type:"repeater",actions:{render_settings:"render"},events:{"change .acf-field-setting-layout input":"_change_layout","focus .acf-field-setting-collapsed select":"_focus_collapsed"},focus:function(){this.$fields=this.$field.find(".acf-field-list:first")},render:function(){this.render_layout(),this.render_collapsed()},render_layout:function(){var e=this.setting("layout input:checked").val();this.$fields.attr("data-layout",e)},render_collapsed:function(){var e=this.setting("collapsed select"),t=[];t.push({label:e.find('option[value=""]').text(),value:""}),this.$fields.children(".acf-field-object").each(function(){var e=$(this);t.push({label:e.find(".field-label:first").val(),value:e.attr("data-key")})}),acf.render_select(e,t)},_change_layout:function(e){this.render_layout()},_focus_collapsed:function(e){this.render_collapsed()}});acf.field_group.field_object.extend({type:"flexible_content",actions:{render_settings:"render"},render:function(){var e=this,t=this.$field;this.$settings.hasClass("ui-sortable")||this.$settings.sortable({items:"> .acf-field-setting-fc_layout",handle:'[data-name="acf-fc-reorder"]',forceHelperSize:!0,forcePlaceholderSize:!0,scroll:!0,stop:function(e,a){acf.field_group.save_field(t)}}),this.$settings.children(".acf-field-setting-fc_layout").each(function(){e.layout.render($(this))})},layout:null}).layout=acf.model.extend({actions:{update_field_parent:"update_field_parent"},events:{"change .acf-fc-meta-display select":"_change_display","blur .acf-fc-meta-label input":"_blur_label",'click a[data-name="acf-fc-add"]':"_add",'click a[data-name="acf-fc-duplicate"]':"_duplicate",'click a[data-name="acf-fc-delete"]':"_delete"},event:function(e){return e.$el.closest(".acf-field-setting-fc_layout")},update_meta:function(e,t){acf.field_group.update_field_meta(e,"parent_layout",t.attr("data-id"))},delete_meta:function(e){acf.field_group.delete_field_meta(e,"parent_layout")},update_field_parent:function(e,t){var a=e.closest(".acf-field-setting-fc_layout");if(!a.exists())return this.delete_meta(e);this.update_meta(e,a),acf.field_group.save_field(e)},render:function(e){var t=this,a=e.find(".acf-fc-meta-key:first input"),i=e.find(".acf-field-list:first"),l=e.find(".acf-fc-meta-display:first select").val();a.val(e.attr("data-id")),i.attr("data-layout",l),i.children(".acf-field-object").each(function(){t.update_meta($(this),e)})},_change_display:function(e){this.render(e)},_blur_label:function(e){var t=e.find(".acf-fc-meta-label:first input"),a=e.find(".acf-fc-meta-name:first input");if(""==a.val()){var i=t.val();i=acf.str_sanitize(i),a.val(i).trigger("change")}},_add:function(e){var t=acf.duplicate({$el:e,after:function(e,t){t.find(".acf-field-object").remove(),t.find(".no-fields-message").show(),t.find(".acf-fc-meta input").val("")}});this.render(t),acf.field_group.save_field(e.closest(".acf-field-object"))},_duplicate:function(e){$el2=acf.duplicate(e),acf.do_action("duplicate_field",$el2),this.render($el2),acf.field_group.save_field(e.closest(".acf-field-object"))},_delete:function(e){if(0==e.siblings(".acf-field-setting-fc_layout").length)return alert(acf._e("flexible_content","layout_warning")),!1;e.find(".acf-field-object").each(function(){acf.field_group.delete_field($(this),!1)}),acf.remove_tr(e),acf.field_group.save_field(e.closest(".acf-field-object"))}}),acf.field_group.field_object.extend({type:"clone",actions:{render_settings:"render"},events:{"change .acf-field-setting-display select":"render_display","change .acf-field-setting-prefix_label input":"render_prefix_label","change .acf-field-setting-prefix_name input":"render_prefix_name"},render:function(){this.render_display(),this.render_prefix_label(),this.render_prefix_name()},render_display:function(){var e=this.setting("display select").val();this.$field.attr("data-display",e)},render_prefix_label:function(){var e="%field_label%";this.setting('prefix_label input[type="checkbox"]').prop("checked")&&(e=this.setting('label input[type="text"]').val()+" "+e),this.setting("prefix_label code").html(e)},render_prefix_name:function(){var e="%field_name%";this.setting('prefix_name input[type="checkbox"]').prop("checked")&&(e=this.setting('name input[type="text"]').val()+"_"+e),this.setting("prefix_name code").html(e)},select2:null}).select2=acf.model.extend({filters:{select2_args:"select2_args",select2_ajax_data:"select2_ajax_data"},select2_args:function(e,t,a){return"acf/fields/clone/query"!==a.ajax_action?e:(e.closeOnSelect=!1,e)},select2_ajax_data:function(e,t,a){if("acf/fields/clone/query"!==t.ajax_action)return e;var i={};return $(".acf-field-object").each(function(){var e=$(this),t=e.data("key"),a=e.data("type"),l=e.find(".field-label:first").val(),n=e.parents(".acf-field-object");i[t]={key:t,type:a,label:l,ancestors:n.length}}),e.fields=i,e.title=$("#title").val(),e}})}(jQuery);
|
||||
File diff suppressed because it is too large
Load Diff
1
wordpress/wp-content/plugins/advanced-custom-fields-pro/pro/assets/js/acf-pro-input.min.js
vendored
Normal file
1
wordpress/wp-content/plugins/advanced-custom-fields-pro/pro/assets/js/acf-pro-input.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,891 @@
|
||||
<?php
|
||||
|
||||
if( ! class_exists('acf_field_gallery') ) :
|
||||
|
||||
class acf_field_gallery extends acf_field {
|
||||
|
||||
|
||||
/*
|
||||
* __construct
|
||||
*
|
||||
* This function will setup the field type data
|
||||
*
|
||||
* @type function
|
||||
* @date 5/03/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function initialize() {
|
||||
|
||||
// vars
|
||||
$this->name = 'gallery';
|
||||
$this->label = __("Gallery",'acf');
|
||||
$this->category = 'content';
|
||||
$this->defaults = array(
|
||||
'library' => 'all',
|
||||
'min' => 0,
|
||||
'max' => 0,
|
||||
'min_width' => 0,
|
||||
'min_height' => 0,
|
||||
'min_size' => 0,
|
||||
'max_width' => 0,
|
||||
'max_height' => 0,
|
||||
'max_size' => 0,
|
||||
'mime_types' => '',
|
||||
'insert' => 'append'
|
||||
);
|
||||
$this->l10n = array(
|
||||
'select' => __("Add Image to Gallery",'acf'),
|
||||
'edit' => __("Edit Image",'acf'),
|
||||
'update' => __("Update Image",'acf'),
|
||||
'uploadedTo' => __("Uploaded to this post",'acf'),
|
||||
'max' => __("Maximum selection reached",'acf')
|
||||
);
|
||||
|
||||
|
||||
// actions
|
||||
add_action('wp_ajax_acf/fields/gallery/get_attachment', array($this, 'ajax_get_attachment'));
|
||||
add_action('wp_ajax_nopriv_acf/fields/gallery/get_attachment', array($this, 'ajax_get_attachment'));
|
||||
|
||||
add_action('wp_ajax_acf/fields/gallery/update_attachment', array($this, 'ajax_update_attachment'));
|
||||
add_action('wp_ajax_nopriv_acf/fields/gallery/update_attachment', array($this, 'ajax_update_attachment'));
|
||||
|
||||
add_action('wp_ajax_acf/fields/gallery/get_sort_order', array($this, 'ajax_get_sort_order'));
|
||||
add_action('wp_ajax_nopriv_acf/fields/gallery/get_sort_order', array($this, 'ajax_get_sort_order'));
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* ajax_get_attachment
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @type function
|
||||
* @date 13/12/2013
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function ajax_get_attachment() {
|
||||
|
||||
// options
|
||||
$options = acf_parse_args( $_POST, array(
|
||||
'post_id' => 0,
|
||||
'attachment' => 0,
|
||||
'id' => 0,
|
||||
'field_key' => '',
|
||||
'nonce' => '',
|
||||
));
|
||||
|
||||
|
||||
// validate
|
||||
if( !wp_verify_nonce($options['nonce'], 'acf_nonce') ) die();
|
||||
|
||||
|
||||
// bail early if no id
|
||||
if( !$options['id'] ) die();
|
||||
|
||||
|
||||
// load field
|
||||
$field = acf_get_field( $options['field_key'] );
|
||||
|
||||
|
||||
// bali early if no field
|
||||
if( !$field ) die();
|
||||
|
||||
|
||||
// render
|
||||
$this->render_attachment( $options['id'], $field );
|
||||
die;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* ajax_update_attachment
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @type function
|
||||
* @date 13/12/2013
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function ajax_update_attachment() {
|
||||
|
||||
// validate nonce
|
||||
if( !wp_verify_nonce($_POST['nonce'], 'acf_nonce') ) {
|
||||
|
||||
wp_send_json_error();
|
||||
|
||||
}
|
||||
|
||||
|
||||
// bail early if no attachments
|
||||
if( empty($_POST['attachments']) ) {
|
||||
|
||||
wp_send_json_error();
|
||||
|
||||
}
|
||||
|
||||
|
||||
// loop over attachments
|
||||
foreach( $_POST['attachments'] as $id => $changes ) {
|
||||
|
||||
if ( !current_user_can( 'edit_post', $id ) )
|
||||
wp_send_json_error();
|
||||
|
||||
$post = get_post( $id, ARRAY_A );
|
||||
|
||||
if ( 'attachment' != $post['post_type'] )
|
||||
wp_send_json_error();
|
||||
|
||||
if ( isset( $changes['title'] ) )
|
||||
$post['post_title'] = $changes['title'];
|
||||
|
||||
if ( isset( $changes['caption'] ) )
|
||||
$post['post_excerpt'] = $changes['caption'];
|
||||
|
||||
if ( isset( $changes['description'] ) )
|
||||
$post['post_content'] = $changes['description'];
|
||||
|
||||
if ( isset( $changes['alt'] ) ) {
|
||||
$alt = wp_unslash( $changes['alt'] );
|
||||
if ( $alt != get_post_meta( $id, '_wp_attachment_image_alt', true ) ) {
|
||||
$alt = wp_strip_all_tags( $alt, true );
|
||||
update_post_meta( $id, '_wp_attachment_image_alt', wp_slash( $alt ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// save post
|
||||
wp_update_post( $post );
|
||||
|
||||
|
||||
/** This filter is documented in wp-admin/includes/media.php */
|
||||
// - seems off to run this filter AFTER the update_post function, but there is a reason
|
||||
// - when placed BEFORE, an empty post_title will be populated by WP
|
||||
// - this filter will still allow 3rd party to save extra image data!
|
||||
$post = apply_filters( 'attachment_fields_to_save', $post, $changes );
|
||||
|
||||
|
||||
// save meta
|
||||
acf_save_post( $id );
|
||||
|
||||
}
|
||||
|
||||
|
||||
// return
|
||||
wp_send_json_success();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* ajax_get_sort_order
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @type function
|
||||
* @date 13/12/2013
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function ajax_get_sort_order() {
|
||||
|
||||
// vars
|
||||
$r = array();
|
||||
$order = 'DESC';
|
||||
$args = acf_parse_args( $_POST, array(
|
||||
'ids' => 0,
|
||||
'sort' => 'date',
|
||||
'field_key' => '',
|
||||
'nonce' => '',
|
||||
));
|
||||
|
||||
|
||||
// validate
|
||||
if( ! wp_verify_nonce($args['nonce'], 'acf_nonce') ) {
|
||||
|
||||
wp_send_json_error();
|
||||
|
||||
}
|
||||
|
||||
|
||||
// reverse
|
||||
if( $args['sort'] == 'reverse' ) {
|
||||
|
||||
$ids = array_reverse($args['ids']);
|
||||
|
||||
wp_send_json_success($ids);
|
||||
|
||||
}
|
||||
|
||||
|
||||
if( $args['sort'] == 'title' ) {
|
||||
|
||||
$order = 'ASC';
|
||||
|
||||
}
|
||||
|
||||
|
||||
// find attachments (DISTINCT POSTS)
|
||||
$ids = get_posts(array(
|
||||
'post_type' => 'attachment',
|
||||
'numberposts' => -1,
|
||||
'post_status' => 'any',
|
||||
'post__in' => $args['ids'],
|
||||
'order' => $order,
|
||||
'orderby' => $args['sort'],
|
||||
'fields' => 'ids'
|
||||
));
|
||||
|
||||
|
||||
// success
|
||||
if( !empty($ids) ) {
|
||||
|
||||
wp_send_json_success($ids);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// failure
|
||||
wp_send_json_error();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* render_attachment
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @type function
|
||||
* @date 13/12/2013
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function render_attachment( $id = 0, $field ) {
|
||||
|
||||
// vars
|
||||
$attachment = wp_prepare_attachment_for_js( $id );
|
||||
$compat = get_compat_media_markup( $id );
|
||||
$compat = $compat['item'];
|
||||
$prefix = 'attachments[' . $id . ']';
|
||||
$thumb = '';
|
||||
$dimentions = '';
|
||||
|
||||
|
||||
// thumb
|
||||
if( isset($attachment['thumb']['src']) ) {
|
||||
|
||||
// video
|
||||
$thumb = $attachment['thumb']['src'];
|
||||
|
||||
} elseif( isset($attachment['sizes']['thumbnail']['url']) ) {
|
||||
|
||||
// image
|
||||
$thumb = $attachment['sizes']['thumbnail']['url'];
|
||||
|
||||
} elseif( $attachment['type'] === 'image' ) {
|
||||
|
||||
// svg
|
||||
$thumb = $attachment['url'];
|
||||
|
||||
} else {
|
||||
|
||||
// fallback (perhaps attachment does not exist)
|
||||
$thumb = wp_mime_type_icon();
|
||||
|
||||
}
|
||||
|
||||
|
||||
// dimentions
|
||||
if( $attachment['type'] === 'audio' ) {
|
||||
|
||||
$dimentions = __('Length', 'acf') . ': ' . $attachment['fileLength'];
|
||||
|
||||
} elseif( !empty($attachment['width']) ) {
|
||||
|
||||
$dimentions = $attachment['width'] . ' x ' . $attachment['height'];
|
||||
|
||||
}
|
||||
|
||||
if( !empty($attachment['filesizeHumanReadable']) ) {
|
||||
|
||||
$dimentions .= ' (' . $attachment['filesizeHumanReadable'] . ')';
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
<div class="acf-gallery-side-info">
|
||||
<img src="<?php echo $thumb; ?>" alt="<?php echo $attachment['alt']; ?>" />
|
||||
<p class="filename"><strong><?php echo $attachment['filename']; ?></strong></p>
|
||||
<p class="uploaded"><?php echo $attachment['dateFormatted']; ?></p>
|
||||
<p class="dimensions"><?php echo $dimentions; ?></p>
|
||||
<p class="actions">
|
||||
<a href="#" class="acf-gallery-edit" data-id="<?php echo $id; ?>"><?php _e('Edit', 'acf'); ?></a>
|
||||
<a href="#" class="acf-gallery-remove" data-id="<?php echo $id; ?>"><?php _e('Remove', 'acf'); ?></a>
|
||||
</p>
|
||||
</div>
|
||||
<table class="form-table">
|
||||
<tbody>
|
||||
<?php
|
||||
|
||||
acf_render_field_wrap(array(
|
||||
//'key' => "{$field['key']}-title",
|
||||
'name' => 'title',
|
||||
'prefix' => $prefix,
|
||||
'type' => 'text',
|
||||
'label' => __('Title', 'acf'),
|
||||
'value' => $attachment['title']
|
||||
), 'tr');
|
||||
|
||||
acf_render_field_wrap(array(
|
||||
//'key' => "{$field['key']}-caption",
|
||||
'name' => 'caption',
|
||||
'prefix' => $prefix,
|
||||
'type' => 'textarea',
|
||||
'label' => __('Caption', 'acf'),
|
||||
'value' => $attachment['caption']
|
||||
), 'tr');
|
||||
|
||||
acf_render_field_wrap(array(
|
||||
//'key' => "{$field['key']}-alt",
|
||||
'name' => 'alt',
|
||||
'prefix' => $prefix,
|
||||
'type' => 'text',
|
||||
'label' => __('Alt Text', 'acf'),
|
||||
'value' => $attachment['alt']
|
||||
), 'tr');
|
||||
|
||||
acf_render_field_wrap(array(
|
||||
//'key' => "{$field['key']}-description",
|
||||
'name' => 'description',
|
||||
'prefix' => $prefix,
|
||||
'type' => 'textarea',
|
||||
'label' => __('Description', 'acf'),
|
||||
'value' => $attachment['description']
|
||||
), 'tr');
|
||||
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php
|
||||
|
||||
echo $compat;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* get_attachments
|
||||
*
|
||||
* This function will return an array of attachments for a given field value
|
||||
*
|
||||
* @type function
|
||||
* @date 13/06/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $value (array)
|
||||
* @return $value
|
||||
*/
|
||||
|
||||
function get_attachments( $value ) {
|
||||
|
||||
// bail early if no value
|
||||
if( empty($value) ) return false;
|
||||
|
||||
|
||||
// force value to array
|
||||
$post__in = acf_get_array( $value );
|
||||
|
||||
|
||||
// get posts
|
||||
$posts = acf_get_posts(array(
|
||||
'post_type' => 'attachment',
|
||||
'post__in' => $post__in
|
||||
));
|
||||
|
||||
|
||||
// return
|
||||
return $posts;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* render_field()
|
||||
*
|
||||
* Create the HTML interface for your field
|
||||
*
|
||||
* @param $field - an array holding all the field's data
|
||||
*
|
||||
* @type action
|
||||
* @since 3.6
|
||||
* @date 23/01/13
|
||||
*/
|
||||
|
||||
function render_field( $field ) {
|
||||
|
||||
// enqueue
|
||||
acf_enqueue_uploader();
|
||||
|
||||
|
||||
// vars
|
||||
$atts = array(
|
||||
'id' => $field['id'],
|
||||
'class' => "acf-gallery {$field['class']}",
|
||||
'data-library' => $field['library'],
|
||||
'data-min' => $field['min'],
|
||||
'data-max' => $field['max'],
|
||||
'data-mime_types' => $field['mime_types'],
|
||||
'data-insert' => $field['insert'],
|
||||
'data-columns' => 4
|
||||
);
|
||||
|
||||
|
||||
// set gallery height
|
||||
$height = acf_get_user_setting('gallery_height', 400);
|
||||
$height = max( $height, 200 ); // minimum height is 200
|
||||
$atts['style'] = "height:{$height}px";
|
||||
|
||||
|
||||
// get posts
|
||||
$value = $this->get_attachments( $field['value'] );
|
||||
|
||||
?>
|
||||
<div <?php acf_esc_attr_e($atts); ?>>
|
||||
|
||||
<div class="acf-hidden">
|
||||
<?php acf_hidden_input(array( 'name' => $field['name'], 'value' => '' )); ?>
|
||||
</div>
|
||||
|
||||
<div class="acf-gallery-main">
|
||||
|
||||
<div class="acf-gallery-attachments">
|
||||
|
||||
<?php if( $value ): ?>
|
||||
|
||||
<?php foreach( $value as $i => $v ):
|
||||
|
||||
// bail early if no value
|
||||
if( !$v ) continue;
|
||||
|
||||
|
||||
// vars
|
||||
$a = array(
|
||||
'ID' => $v->ID,
|
||||
'title' => $v->post_title,
|
||||
'filename' => wp_basename($v->guid),
|
||||
'type' => acf_maybe_get(explode('/', $v->post_mime_type), 0),
|
||||
'class' => 'acf-gallery-attachment'
|
||||
);
|
||||
|
||||
|
||||
// thumbnail
|
||||
$thumbnail = acf_get_post_thumbnail($a['ID'], 'medium');
|
||||
|
||||
|
||||
// remove filename if is image
|
||||
if( $a['type'] == 'image' ) $a['filename'] = '';
|
||||
|
||||
|
||||
// class
|
||||
$a['class'] .= ' -' . $a['type'];
|
||||
|
||||
if( $thumbnail['type'] == 'icon' ) {
|
||||
|
||||
$a['class'] .= ' -icon';
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
<div class="<?php echo $a['class']; ?>" data-id="<?php echo $a['ID']; ?>">
|
||||
<?php acf_hidden_input(array( 'name' => $field['name'].'[]', 'value' => $a['ID'] )); ?>
|
||||
<div class="margin">
|
||||
<div class="thumbnail">
|
||||
<img src="<?php echo $thumbnail['url']; ?>" alt="" title="<?php echo $a['title']; ?>"/>
|
||||
</div>
|
||||
<?php if( $a['filename'] ): ?>
|
||||
<div class="filename"><?php echo acf_get_truncated($a['filename'], 30); ?></div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<a class="acf-icon -cancel dark acf-gallery-remove" href="#" data-id="<?php echo $a['ID']; ?>" title="<?php _e('Remove', 'acf'); ?>"></a>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="acf-gallery-toolbar">
|
||||
|
||||
<ul class="acf-hl">
|
||||
<li>
|
||||
<a href="#" class="acf-button button button-primary acf-gallery-add"><?php _e('Add to gallery', 'acf'); ?></a>
|
||||
</li>
|
||||
<li class="acf-fr">
|
||||
<select class="acf-gallery-sort">
|
||||
<option value=""><?php _e('Bulk actions', 'acf'); ?></option>
|
||||
<option value="date"><?php _e('Sort by date uploaded', 'acf'); ?></option>
|
||||
<option value="modified"><?php _e('Sort by date modified', 'acf'); ?></option>
|
||||
<option value="title"><?php _e('Sort by title', 'acf'); ?></option>
|
||||
<option value="reverse"><?php _e('Reverse current order', 'acf'); ?></option>
|
||||
</select>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="acf-gallery-side">
|
||||
<div class="acf-gallery-side-inner">
|
||||
|
||||
<div class="acf-gallery-side-data"></div>
|
||||
|
||||
<div class="acf-gallery-toolbar">
|
||||
|
||||
<ul class="acf-hl">
|
||||
<li>
|
||||
<a href="#" class="acf-button button acf-gallery-close"><?php _e('Close', 'acf'); ?></a>
|
||||
</li>
|
||||
<li class="acf-fr">
|
||||
<a class="acf-button button button-primary acf-gallery-update" href="#"><?php _e('Update', 'acf'); ?></a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* render_field_settings()
|
||||
*
|
||||
* Create extra options for your field. This is rendered when editing a field.
|
||||
* The value of $field['name'] can be used (like bellow) to save extra data to the $field
|
||||
*
|
||||
* @type action
|
||||
* @since 3.6
|
||||
* @date 23/01/13
|
||||
*
|
||||
* @param $field - an array holding all the field's data
|
||||
*/
|
||||
|
||||
function render_field_settings( $field ) {
|
||||
|
||||
// clear numeric settings
|
||||
$clear = array(
|
||||
'min',
|
||||
'max',
|
||||
'min_width',
|
||||
'min_height',
|
||||
'min_size',
|
||||
'max_width',
|
||||
'max_height',
|
||||
'max_size'
|
||||
);
|
||||
|
||||
foreach( $clear as $k ) {
|
||||
|
||||
if( empty($field[$k]) ) $field[$k] = '';
|
||||
|
||||
}
|
||||
|
||||
|
||||
// min
|
||||
acf_render_field_setting( $field, array(
|
||||
'label' => __('Minimum Selection','acf'),
|
||||
'instructions' => '',
|
||||
'type' => 'number',
|
||||
'name' => 'min'
|
||||
));
|
||||
|
||||
|
||||
// max
|
||||
acf_render_field_setting( $field, array(
|
||||
'label' => __('Maximum Selection','acf'),
|
||||
'instructions' => '',
|
||||
'type' => 'number',
|
||||
'name' => 'max'
|
||||
));
|
||||
|
||||
|
||||
// insert
|
||||
acf_render_field_setting( $field, array(
|
||||
'label' => __('Insert','acf'),
|
||||
'instructions' => __('Specify where new attachments are added','acf'),
|
||||
'type' => 'select',
|
||||
'name' => 'insert',
|
||||
'choices' => array(
|
||||
'append' => __('Append to the end', 'acf'),
|
||||
'prepend' => __('Prepend to the beginning', 'acf')
|
||||
)
|
||||
));
|
||||
|
||||
|
||||
// library
|
||||
acf_render_field_setting( $field, array(
|
||||
'label' => __('Library','acf'),
|
||||
'instructions' => __('Limit the media library choice','acf'),
|
||||
'type' => 'radio',
|
||||
'name' => 'library',
|
||||
'layout' => 'horizontal',
|
||||
'choices' => array(
|
||||
'all' => __('All', 'acf'),
|
||||
'uploadedTo' => __('Uploaded to post', 'acf')
|
||||
)
|
||||
));
|
||||
|
||||
|
||||
// min
|
||||
acf_render_field_setting( $field, array(
|
||||
'label' => __('Minimum','acf'),
|
||||
'instructions' => __('Restrict which images can be uploaded','acf'),
|
||||
'type' => 'text',
|
||||
'name' => 'min_width',
|
||||
'prepend' => __('Width', 'acf'),
|
||||
'append' => 'px',
|
||||
));
|
||||
|
||||
acf_render_field_setting( $field, array(
|
||||
'label' => '',
|
||||
'type' => 'text',
|
||||
'name' => 'min_height',
|
||||
'prepend' => __('Height', 'acf'),
|
||||
'append' => 'px',
|
||||
'_append' => 'min_width'
|
||||
));
|
||||
|
||||
acf_render_field_setting( $field, array(
|
||||
'label' => '',
|
||||
'type' => 'text',
|
||||
'name' => 'min_size',
|
||||
'prepend' => __('File size', 'acf'),
|
||||
'append' => 'MB',
|
||||
'_append' => 'min_width'
|
||||
));
|
||||
|
||||
|
||||
// max
|
||||
acf_render_field_setting( $field, array(
|
||||
'label' => __('Maximum','acf'),
|
||||
'instructions' => __('Restrict which images can be uploaded','acf'),
|
||||
'type' => 'text',
|
||||
'name' => 'max_width',
|
||||
'prepend' => __('Width', 'acf'),
|
||||
'append' => 'px',
|
||||
));
|
||||
|
||||
acf_render_field_setting( $field, array(
|
||||
'label' => '',
|
||||
'type' => 'text',
|
||||
'name' => 'max_height',
|
||||
'prepend' => __('Height', 'acf'),
|
||||
'append' => 'px',
|
||||
'_append' => 'max_width'
|
||||
));
|
||||
|
||||
acf_render_field_setting( $field, array(
|
||||
'label' => '',
|
||||
'type' => 'text',
|
||||
'name' => 'max_size',
|
||||
'prepend' => __('File size', 'acf'),
|
||||
'append' => 'MB',
|
||||
'_append' => 'max_width'
|
||||
));
|
||||
|
||||
|
||||
// allowed type
|
||||
acf_render_field_setting( $field, array(
|
||||
'label' => __('Allowed file types','acf'),
|
||||
'instructions' => __('Comma separated list. Leave blank for all types','acf'),
|
||||
'type' => 'text',
|
||||
'name' => 'mime_types',
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* format_value()
|
||||
*
|
||||
* This filter is appied to the $value after it is loaded from the db and before it is returned to the template
|
||||
*
|
||||
* @type filter
|
||||
* @since 3.6
|
||||
* @date 23/01/13
|
||||
*
|
||||
* @param $value (mixed) the value which was loaded from the database
|
||||
* @param $post_id (mixed) the $post_id from which the value was loaded
|
||||
* @param $field (array) the field array holding all the field options
|
||||
*
|
||||
* @return $value (mixed) the modified value
|
||||
*/
|
||||
|
||||
function format_value( $value, $post_id, $field ) {
|
||||
|
||||
// bail early if no value
|
||||
if( empty($value) ) return false;
|
||||
|
||||
|
||||
// get posts
|
||||
$posts = $this->get_attachments($value);
|
||||
|
||||
|
||||
// update value to include $post
|
||||
foreach( array_keys($posts) as $i ) {
|
||||
|
||||
$posts[ $i ] = acf_get_attachment( $posts[ $i ] );
|
||||
|
||||
}
|
||||
|
||||
|
||||
// return
|
||||
return $posts;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* validate_value
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @type function
|
||||
* @date 11/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function validate_value( $valid, $value, $field, $input ){
|
||||
|
||||
if( empty($value) || !is_array($value) ) {
|
||||
|
||||
$value = array();
|
||||
|
||||
}
|
||||
|
||||
|
||||
if( count($value) < $field['min'] ) {
|
||||
|
||||
$valid = _n( '%s requires at least %s selection', '%s requires at least %s selections', $field['min'], 'acf' );
|
||||
$valid = sprintf( $valid, $field['label'], $field['min'] );
|
||||
|
||||
}
|
||||
|
||||
|
||||
return $valid;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* update_value()
|
||||
*
|
||||
* This filter is appied to the $value before it is updated in the db
|
||||
*
|
||||
* @type filter
|
||||
* @since 3.6
|
||||
* @date 23/01/13
|
||||
*
|
||||
* @param $value - the value which will be saved in the database
|
||||
* @param $post_id - the $post_id of which the value will be saved
|
||||
* @param $field - the field array holding all the field options
|
||||
*
|
||||
* @return $value - the modified value
|
||||
*/
|
||||
|
||||
function update_value( $value, $post_id, $field ) {
|
||||
|
||||
// bail early if no value
|
||||
if( empty($value) || !is_array($value) ) return false;
|
||||
|
||||
|
||||
// loop
|
||||
foreach( $value as $i => $v ) {
|
||||
|
||||
$value[ $i ] = $this->update_single_value( $v );
|
||||
|
||||
}
|
||||
|
||||
|
||||
// return
|
||||
return $value;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* update_single_value()
|
||||
*
|
||||
* This filter is appied to the $value before it is updated in the db
|
||||
*
|
||||
* @type filter
|
||||
* @since 3.6
|
||||
* @date 23/01/13
|
||||
*
|
||||
* @param $value - the value which will be saved in the database
|
||||
* @param $post_id - the $post_id of which the value will be saved
|
||||
* @param $field - the field array holding all the field options
|
||||
*
|
||||
* @return $value - the modified value
|
||||
*/
|
||||
|
||||
function update_single_value( $value ) {
|
||||
|
||||
// numeric
|
||||
if( is_numeric($value) ) return $value;
|
||||
|
||||
|
||||
// array?
|
||||
if( is_array($value) && isset($value['ID']) ) return $value['ID'];
|
||||
|
||||
|
||||
// object?
|
||||
if( is_object($value) && isset($value->ID) ) return $value->ID;
|
||||
|
||||
|
||||
// return
|
||||
return $value;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
// initialize
|
||||
acf_register_field_type( 'acf_field_gallery' );
|
||||
|
||||
endif; // class_exists check
|
||||
|
||||
?>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
if( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
if( ! class_exists('acf_location_options_page') ) :
|
||||
|
||||
class acf_location_options_page extends acf_location {
|
||||
|
||||
/*
|
||||
* __construct
|
||||
*
|
||||
* This function will setup the class functionality
|
||||
*
|
||||
* @type function
|
||||
* @date 5/03/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function initialize() {
|
||||
|
||||
// vars
|
||||
$this->name = 'options_page';
|
||||
$this->label = __("Options Page",'acf');
|
||||
$this->category = 'forms';
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* rule_match
|
||||
*
|
||||
* This function is used to match this location $rule to the current $screen
|
||||
*
|
||||
* @type function
|
||||
* @date 3/01/13
|
||||
* @since 3.5.7
|
||||
*
|
||||
* @param $match (boolean)
|
||||
* @param $rule (array)
|
||||
* @return $options (array)
|
||||
*/
|
||||
|
||||
function rule_match( $result, $rule, $screen ) {
|
||||
|
||||
$options_page = acf_maybe_get( $screen, 'options_page' );
|
||||
return $this->compare( $options_page, $rule );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* rule_operators
|
||||
*
|
||||
* This function returns the available values for this rule type
|
||||
*
|
||||
* @type function
|
||||
* @date 30/5/17
|
||||
* @since 5.6.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return (array)
|
||||
*/
|
||||
|
||||
function rule_values( $choices, $rule ) {
|
||||
|
||||
// vars
|
||||
$pages = acf_get_options_pages();
|
||||
|
||||
|
||||
// populate
|
||||
if( !empty($pages) ) {
|
||||
foreach( $pages as $page ) {
|
||||
$choices[ $page['menu_slug'] ] = $page['menu_title'];
|
||||
}
|
||||
} else {
|
||||
$choices[''] = __('No options pages exist', 'acf');
|
||||
}
|
||||
|
||||
|
||||
// return
|
||||
return $choices;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// initialize
|
||||
acf_register_location_rule( 'acf_location_options_page' );
|
||||
|
||||
endif; // class_exists check
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,628 @@
|
||||
<?php
|
||||
|
||||
if( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
if( ! class_exists('acf_options_page') ) :
|
||||
|
||||
class acf_options_page {
|
||||
|
||||
/** @var array Contains an array of optiions page settings */
|
||||
var $pages = array();
|
||||
|
||||
|
||||
/*
|
||||
* __construct
|
||||
*
|
||||
* Initialize filters, action, variables and includes
|
||||
*
|
||||
* @type function
|
||||
* @date 23/06/12
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function __construct() {
|
||||
|
||||
/* do nothing */
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* validate_page
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @type function
|
||||
* @date 28/2/17
|
||||
* @since 5.5.8
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function validate_page( $page ) {
|
||||
|
||||
// default
|
||||
if( empty($page) ) {
|
||||
|
||||
$page_title = __('Options', 'acf');
|
||||
$page = array(
|
||||
'page_title' => $page_title,
|
||||
'menu_title' => $page_title,
|
||||
'menu_slug' => 'acf-options'
|
||||
);
|
||||
|
||||
// string
|
||||
} elseif( is_string($page) ) {
|
||||
|
||||
$page_title = $page;
|
||||
$page = array(
|
||||
'page_title' => $page_title,
|
||||
'menu_title' => $page_title
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// defaults
|
||||
$page = wp_parse_args($page, array(
|
||||
'page_title' => '',
|
||||
'menu_title' => '',
|
||||
'menu_slug' => '',
|
||||
'capability' => 'edit_posts',
|
||||
'parent_slug' => '',
|
||||
'position' => false,
|
||||
'icon_url' => false,
|
||||
'redirect' => true,
|
||||
'post_id' => 'options',
|
||||
'autoload' => false,
|
||||
'update_button' => __('Update', 'acf'),
|
||||
'updated_message' => __("Options Updated", 'acf'),
|
||||
));
|
||||
|
||||
|
||||
// ACF4 compatibility
|
||||
$migrate = array(
|
||||
'title' => 'page_title',
|
||||
'menu' => 'menu_title',
|
||||
'slug' => 'menu_slug',
|
||||
'parent' => 'parent_slug'
|
||||
);
|
||||
|
||||
foreach( $migrate as $old => $new ) {
|
||||
if( !empty($page[$old]) ) {
|
||||
$page[ $new ] = $page[ $old ];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// page_title (allows user to define page with just page_title or title)
|
||||
if( empty($page['menu_title']) ) {
|
||||
$page['menu_title'] = $page['page_title'];
|
||||
}
|
||||
|
||||
|
||||
// menu_slug
|
||||
if( empty($page['menu_slug']) ) {
|
||||
$page['menu_slug'] = 'acf-options-' . sanitize_title( $page['menu_title'] );
|
||||
}
|
||||
|
||||
|
||||
// filter
|
||||
$page = apply_filters('acf/validate_options_page', $page);
|
||||
|
||||
|
||||
// return
|
||||
return $page;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* add_page
|
||||
*
|
||||
* This function will store an options page settings
|
||||
*
|
||||
* @type function
|
||||
* @date 9/6/17
|
||||
* @since 5.6.0
|
||||
*
|
||||
* @param $page (array)
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function add_page( $page ) {
|
||||
|
||||
// validate
|
||||
$page = $this->validate_page( $page );
|
||||
$slug = $page['menu_slug'];
|
||||
|
||||
|
||||
// bail ealry if already exists
|
||||
if( isset($this->pages[$slug]) ) return false;
|
||||
|
||||
|
||||
// append
|
||||
$this->pages[$slug] = $page;
|
||||
|
||||
|
||||
// return
|
||||
return $page;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* add_sub_page
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @type function
|
||||
* @date 9/6/17
|
||||
* @since 5.6.0
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function add_sub_page( $page ) {
|
||||
|
||||
// validate
|
||||
$page = $this->validate_page( $page );
|
||||
|
||||
|
||||
// default parent
|
||||
if( !$page['parent_slug'] ) {
|
||||
$page['parent_slug'] = 'acf-options';
|
||||
}
|
||||
|
||||
|
||||
// create default parent if not yet exists
|
||||
if( $page['parent_slug'] == 'acf-options' && !$this->get_page('acf-options') ) {
|
||||
|
||||
$this->add_page( '' );
|
||||
|
||||
}
|
||||
|
||||
|
||||
// return
|
||||
return $this->add_page( $page );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* update_page
|
||||
*
|
||||
* This function will update an options page settings
|
||||
*
|
||||
* @type function
|
||||
* @date 9/6/17
|
||||
* @since 5.6.0
|
||||
*
|
||||
* @param $slug (string)
|
||||
* @param $data (array)
|
||||
* @return (array)
|
||||
*/
|
||||
|
||||
function update_page( $slug = '', $data = array() ) {
|
||||
|
||||
// vars
|
||||
$page = $this->get_page( $slug );
|
||||
|
||||
|
||||
// bail early if no page
|
||||
if( !$page ) return false;
|
||||
|
||||
|
||||
// loop
|
||||
$page = array_merge( $page, $data );
|
||||
|
||||
|
||||
// set
|
||||
$this->pages[ $slug ] = $page;
|
||||
|
||||
|
||||
// return
|
||||
return $page;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* get_page
|
||||
*
|
||||
* This function will return an options page settings
|
||||
*
|
||||
* @type function
|
||||
* @date 6/07/2016
|
||||
* @since 5.4.0
|
||||
*
|
||||
* @param $slug (string)
|
||||
* @return (mixed)
|
||||
*/
|
||||
|
||||
function get_page( $slug ) {
|
||||
|
||||
return isset( $this->pages[$slug] ) ? $this->pages[$slug] : null;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* get_pages
|
||||
*
|
||||
* This function will return all options page settings
|
||||
*
|
||||
* @type function
|
||||
* @date 6/07/2016
|
||||
* @since 5.4.0
|
||||
*
|
||||
* @param $slug (string)
|
||||
* @return (mixed)
|
||||
*/
|
||||
|
||||
function get_pages() {
|
||||
|
||||
return $this->pages;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_options_page
|
||||
*
|
||||
* This function will return the options page instance
|
||||
*
|
||||
* @type function
|
||||
* @date 9/6/17
|
||||
* @since 5.6.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return (object)
|
||||
*/
|
||||
|
||||
function acf_options_page() {
|
||||
|
||||
global $acf_options_page;
|
||||
|
||||
if( !isset($acf_options_page) ) {
|
||||
|
||||
$acf_options_page = new acf_options_page();
|
||||
|
||||
}
|
||||
|
||||
return $acf_options_page;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// remove Options Page add-on conflict
|
||||
unset($GLOBALS['acf_options_page']);
|
||||
|
||||
|
||||
// initialize
|
||||
acf_options_page();
|
||||
|
||||
|
||||
endif; // class_exists check
|
||||
|
||||
|
||||
/*
|
||||
* acf_add_options_page
|
||||
*
|
||||
* alias of acf_options_page()->add_page()
|
||||
*
|
||||
* @type function
|
||||
* @date 24/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $page (mixed)
|
||||
* @return (array)
|
||||
*/
|
||||
|
||||
if( !function_exists('acf_add_options_page') ):
|
||||
|
||||
function acf_add_options_page( $page = '' ) {
|
||||
|
||||
return acf_options_page()->add_page( $page );
|
||||
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
|
||||
/*
|
||||
* acf_add_options_sub_page
|
||||
*
|
||||
* alias of acf_options_page()->add_sub_page()
|
||||
*
|
||||
* @type function
|
||||
* @date 24/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $page (mixed)
|
||||
* @return (array)
|
||||
*/
|
||||
|
||||
if( !function_exists('acf_add_options_sub_page') ):
|
||||
|
||||
function acf_add_options_sub_page( $page = '' ) {
|
||||
|
||||
return acf_options_page()->add_sub_page( $page );
|
||||
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
|
||||
/*
|
||||
* acf_update_options_page
|
||||
*
|
||||
* alias of acf_options_page()->update_page()
|
||||
*
|
||||
* @type function
|
||||
* @date 24/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $slug (string)
|
||||
* @param $page (mixed)
|
||||
* @return (array)
|
||||
*/
|
||||
|
||||
if( !function_exists('acf_update_options_page') ):
|
||||
|
||||
function acf_update_options_page( $slug = '', $data = array() ) {
|
||||
|
||||
return acf_options_page()->update_page( $slug, $data );
|
||||
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
|
||||
/*
|
||||
* acf_get_options_page
|
||||
*
|
||||
* This function will return an options page settings
|
||||
*
|
||||
* @type function
|
||||
* @date 24/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param $slug (string)
|
||||
* @return (array)
|
||||
*/
|
||||
|
||||
if( !function_exists('acf_get_options_page') ):
|
||||
|
||||
function acf_get_options_page( $slug ) {
|
||||
|
||||
// vars
|
||||
$page = acf_options_page()->get_page( $slug );
|
||||
|
||||
|
||||
// bail early if no page
|
||||
if( !$page ) return false;
|
||||
|
||||
|
||||
// filter
|
||||
$page = apply_filters('acf/get_options_page', $page, $slug);
|
||||
|
||||
|
||||
// return
|
||||
return $page;
|
||||
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
|
||||
/*
|
||||
* acf_get_options_pages
|
||||
*
|
||||
* This function will return all options page settings
|
||||
*
|
||||
* @type function
|
||||
* @date 24/02/2014
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return (array)
|
||||
*/
|
||||
|
||||
if( !function_exists('acf_get_options_pages') ):
|
||||
|
||||
function acf_get_options_pages() {
|
||||
|
||||
// global
|
||||
global $_wp_last_utility_menu;
|
||||
|
||||
|
||||
// vars
|
||||
$pages = acf_options_page()->get_pages();
|
||||
|
||||
|
||||
// bail early if no pages
|
||||
if( empty($pages) ) return false;
|
||||
|
||||
|
||||
// apply filter to each page
|
||||
foreach( $pages as $slug => &$page ) {
|
||||
|
||||
$page = acf_get_options_page( $slug );
|
||||
|
||||
}
|
||||
|
||||
|
||||
// calculate parent => child redirectes
|
||||
foreach( $pages as $slug => &$page ) {
|
||||
|
||||
// bail early if is child
|
||||
if( $page['parent_slug'] ) continue;
|
||||
|
||||
|
||||
// add missing position
|
||||
if( !$page['position']) {
|
||||
|
||||
$_wp_last_utility_menu++;
|
||||
$page['position'] = $_wp_last_utility_menu;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// bail early if no redirect
|
||||
if( !$page['redirect'] ) continue;
|
||||
|
||||
|
||||
// vars
|
||||
$parent = $page['menu_slug'];
|
||||
$child = '';
|
||||
|
||||
|
||||
// update children
|
||||
foreach( $pages as &$sub_page ) {
|
||||
|
||||
// bail early if not child of this parent
|
||||
if( $sub_page['parent_slug'] !== $parent ) continue;
|
||||
|
||||
|
||||
// set child (only once)
|
||||
if( !$child ) {
|
||||
$child = $sub_page['menu_slug'];
|
||||
}
|
||||
|
||||
|
||||
// update parent_slug to the first child
|
||||
$sub_page['parent_slug'] = $child;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// finally update parent menu_slug
|
||||
if( $child ) {
|
||||
$page['menu_slug'] = $child;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// filter
|
||||
$pages = apply_filters('acf/get_options_pages', $pages);
|
||||
|
||||
|
||||
// return
|
||||
return $pages;
|
||||
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
|
||||
/*
|
||||
* acf_set_options_page_title
|
||||
*
|
||||
* This function is used to customize the options page admin menu title
|
||||
*
|
||||
* @type function
|
||||
* @date 13/07/13
|
||||
* @since 4.0.0
|
||||
*
|
||||
* @param $title (string)
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
if( ! function_exists('acf_set_options_page_title') ):
|
||||
|
||||
function acf_set_options_page_title( $title = 'Options' ) {
|
||||
|
||||
acf_update_options_page('acf-options', array(
|
||||
'page_title' => $title,
|
||||
'menu_title' => $title
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
|
||||
/*
|
||||
* acf_set_options_page_menu
|
||||
*
|
||||
* This function is used to customize the options page admin menu name
|
||||
*
|
||||
* @type function
|
||||
* @date 13/07/13
|
||||
* @since 4.0.0
|
||||
*
|
||||
* @param $title (string)
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
if( ! function_exists('acf_set_options_page_menu') ):
|
||||
|
||||
function acf_set_options_page_menu( $title = 'Options' ) {
|
||||
|
||||
acf_update_options_page('acf-options', array(
|
||||
'menu_title' => $title
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
|
||||
/*
|
||||
* acf_set_options_page_capability
|
||||
*
|
||||
* This function is used to customize the options page capability. Defaults to 'edit_posts'
|
||||
*
|
||||
* @type function
|
||||
* @date 13/07/13
|
||||
* @since 4.0.0
|
||||
*
|
||||
* @param $title (string)
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
if( ! function_exists('acf_set_options_page_capability') ):
|
||||
|
||||
function acf_set_options_page_capability( $capability = 'edit_posts' ) {
|
||||
|
||||
acf_update_options_page('acf-options', array(
|
||||
'capability' => $capability
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
|
||||
/*
|
||||
* register_options_page()
|
||||
*
|
||||
* This is an old function which is now referencing the new 'acf_add_options_sub_page' function
|
||||
*
|
||||
* @type function
|
||||
* @since 3.0.0
|
||||
* @date 29/01/13
|
||||
*
|
||||
* @param {string} $title
|
||||
* @return N/A
|
||||
*/
|
||||
|
||||
if( ! function_exists('register_options_page') ):
|
||||
|
||||
function register_options_page( $page = '' ) {
|
||||
|
||||
acf_add_options_sub_page( $page );
|
||||
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,231 @@
|
||||
<?php
|
||||
|
||||
if( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
if( ! class_exists('acf_pro_updates') ) :
|
||||
|
||||
class acf_pro_updates {
|
||||
|
||||
|
||||
/*
|
||||
* __construct
|
||||
*
|
||||
* Initialize filters, action, variables and includes
|
||||
*
|
||||
* @type function
|
||||
* @date 23/06/12
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function __construct() {
|
||||
|
||||
// actions
|
||||
add_action('init', array($this, 'init'), 20);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* init
|
||||
*
|
||||
* description
|
||||
*
|
||||
* @type function
|
||||
* @date 10/4/17
|
||||
* @since 5.5.10
|
||||
*
|
||||
* @param $post_id (int)
|
||||
* @return $post_id (int)
|
||||
*/
|
||||
|
||||
function init() {
|
||||
|
||||
// bail early if no show_updates
|
||||
if( !acf_get_setting('show_updates') ) return;
|
||||
|
||||
|
||||
// bail early if not a plugin (included in theme)
|
||||
if( !acf_is_plugin_active() ) return;
|
||||
|
||||
|
||||
// register update
|
||||
acf_register_plugin_update(array(
|
||||
'id' => 'pro',
|
||||
'key' => acf_pro_get_license_key(),
|
||||
'slug' => acf_get_setting('slug'),
|
||||
'basename' => acf_get_setting('basename'),
|
||||
'version' => acf_get_setting('version'),
|
||||
));
|
||||
|
||||
|
||||
// admin
|
||||
if( is_admin() ) {
|
||||
|
||||
add_action('in_plugin_update_message-' . acf_get_setting('basename'), array($this, 'modify_plugin_update_message'), 10, 2 );
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* modify_plugin_update_message
|
||||
*
|
||||
* Displays an update message for plugin list screens.
|
||||
*
|
||||
* @type function
|
||||
* @date 14/06/2016
|
||||
* @since 5.3.8
|
||||
*
|
||||
* @param $message (string)
|
||||
* @param $plugin_data (array)
|
||||
* @param $r (object)
|
||||
* @return $message
|
||||
*/
|
||||
|
||||
function modify_plugin_update_message( $plugin_data, $response ) {
|
||||
|
||||
// bail ealry if has key
|
||||
if( acf_pro_get_license_key() ) return;
|
||||
|
||||
|
||||
// display message
|
||||
echo '<br />' . sprintf( __('To enable updates, please enter your license key on the <a href="%s">Updates</a> page. If you don\'t have a licence key, please see <a href="%s">details & pricing</a>.', 'acf'), admin_url('edit.php?post_type=acf-field-group&page=acf-settings-updates'), 'https://www.advancedcustomfields.com/pro' );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// initialize
|
||||
new acf_pro_updates();
|
||||
|
||||
endif; // class_exists check
|
||||
|
||||
|
||||
/*
|
||||
* acf_pro_get_license
|
||||
*
|
||||
* This function will return the license
|
||||
*
|
||||
* @type function
|
||||
* @date 20/09/2016
|
||||
* @since 5.4.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function acf_pro_get_license() {
|
||||
|
||||
// get option
|
||||
$license = get_option('acf_pro_license');
|
||||
|
||||
|
||||
// bail early if no value
|
||||
if( !$license ) return false;
|
||||
|
||||
|
||||
// decode
|
||||
$license = maybe_unserialize(base64_decode($license));
|
||||
|
||||
|
||||
// bail early if corrupt
|
||||
if( !is_array($license) ) return false;
|
||||
|
||||
|
||||
// return
|
||||
return $license;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_pro_get_license_key
|
||||
*
|
||||
* This function will return the license key
|
||||
*
|
||||
* @type function
|
||||
* @date 20/09/2016
|
||||
* @since 5.4.0
|
||||
*
|
||||
* @param n/a
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function acf_pro_get_license_key() {
|
||||
|
||||
// vars
|
||||
$license = acf_pro_get_license();
|
||||
$home_url = home_url();
|
||||
|
||||
|
||||
// bail early if empty
|
||||
if( !$license || !$license['key'] ) return false;
|
||||
|
||||
|
||||
// bail early if url has changed
|
||||
if( acf_strip_protocol($license['url']) !== acf_strip_protocol($home_url) ) return false;
|
||||
|
||||
|
||||
// return
|
||||
return $license['key'];
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* acf_pro_update_license
|
||||
*
|
||||
* This function will update the DB license
|
||||
*
|
||||
* @type function
|
||||
* @date 20/09/2016
|
||||
* @since 5.4.0
|
||||
*
|
||||
* @param $key (string)
|
||||
* @return n/a
|
||||
*/
|
||||
|
||||
function acf_pro_update_license( $key = '' ) {
|
||||
|
||||
// vars
|
||||
$value = '';
|
||||
|
||||
|
||||
// key
|
||||
if( $key ) {
|
||||
|
||||
// vars
|
||||
$data = array(
|
||||
'key' => $key,
|
||||
'url' => home_url()
|
||||
);
|
||||
|
||||
|
||||
// encode
|
||||
$value = base64_encode(maybe_serialize($data));
|
||||
|
||||
}
|
||||
|
||||
|
||||
// re-register update (key has changed)
|
||||
acf_register_plugin_update(array(
|
||||
'id' => 'pro',
|
||||
'key' => $key,
|
||||
'slug' => acf_get_setting('slug'),
|
||||
'basename' => acf_get_setting('basename'),
|
||||
'version' => acf_get_setting('version'),
|
||||
));
|
||||
|
||||
|
||||
// update
|
||||
return update_option('acf_pro_license', $value);
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user