first commit

This commit is contained in:
Manish
2024-04-18 15:32:23 +05:45
commit 7c93c87c53
3952 changed files with 1924754 additions and 0 deletions

View File

@ -0,0 +1,94 @@
<?php
global $title, $post_new_file, $post_type_object, $post;
$acf_title_placeholder = apply_filters( 'enter_title_here', __( 'Add title' ), $post );
$acf_title = $post->post_title;
$acf_post_type = is_object( $post_type_object ) ? $post_type_object->name : '';
$acf_publish_btn_name = 'save';
$acf_duplicated_from = '';
if ( 'publish' !== $post->post_status ) {
$acf_publish_btn_name = 'publish';
}
if ( 'acf-field-group' === $acf_post_type ) {
$acf_use_post_type = acf_get_post_type_from_request_args( 'add-fields' );
$acf_use_taxonomy = acf_get_taxonomy_from_request_args( 'add-fields' );
$acf_use_options_page = acf_get_ui_options_page_from_request_args( 'add-fields' );
/* translators: %s - singular label of post type/taxonomy, i.e. "Movie"/"Genre" */
$acf_prefilled_title = __( '%s fields', 'acf' );
/**
* Sets a default title to be prefilled (e.g. "Movies Fields") for a post type or taxonomy.
*
* @since 6.1.5
*
* @param string $acf_prefilled_title A string to define the prefilled title for a post type or taxonomy.
*/
$acf_prefilled_title = (string) apply_filters( 'acf/field_group/prefill_title', $acf_prefilled_title );
if ( $acf_use_post_type && ! empty( $acf_use_post_type['labels']['singular_name'] ) ) {
$acf_prefilled_title = sprintf( $acf_prefilled_title, $acf_use_post_type['labels']['singular_name'] );
} elseif ( $acf_use_taxonomy && ! empty( $acf_use_taxonomy['labels']['singular_name'] ) ) {
$acf_prefilled_title = sprintf( $acf_prefilled_title, $acf_use_taxonomy['labels']['singular_name'] );
} elseif ( $acf_use_options_page && ! empty( $acf_use_options_page['page_title'] ) ) {
$acf_prefilled_title = sprintf( $acf_prefilled_title, $acf_use_options_page['page_title'] );
} else {
$acf_prefilled_title = false;
}
if ( empty( $acf_title ) && $acf_prefilled_title ) {
$acf_title = $acf_prefilled_title;
}
} elseif ( in_array( $acf_post_type, array( 'acf-post-type', 'acf-taxonomy' ) ) ) {
$acf_duplicate_post_type = acf_get_post_type_from_request_args( 'acfduplicate' );
$acf_duplicate_taxonomy = acf_get_taxonomy_from_request_args( 'acfduplicate' );
$acf_duplicated_from_label = '';
if ( $acf_duplicate_post_type && ! empty( $acf_duplicate_post_type['labels']['singular_name'] ) ) {
$acf_duplicated_from_label = $acf_duplicate_post_type['labels']['singular_name'];
} elseif ( $acf_duplicate_taxonomy && ! empty( $acf_duplicate_taxonomy['labels']['singular_name'] ) ) {
$acf_duplicated_from_label = $acf_duplicate_taxonomy['labels']['singular_name'];
}
if ( ! empty( $acf_duplicated_from_label ) ) {
/* translators: %s - A singular label for a post type or taxonomy. */
$acf_duplicated_from = sprintf( __( ' (Duplicated from %s)', 'acf' ), $acf_duplicated_from_label );
}
}
?>
<div class="acf-headerbar acf-headerbar-field-editor">
<div class="acf-headerbar-inner">
<div class="acf-headerbar-content">
<h1 class="acf-page-title">
<?php
echo esc_html( $title );
if ( ! empty( $acf_duplicated_from ) ) {
echo '<span class="acf-duplicated-from">' . esc_html( $acf_duplicated_from ) . '</span>';
}
?>
</h1>
<?php if ( 'acf-field-group' === $acf_post_type ) : ?>
<div class="acf-title-wrap">
<label class="screen-reader-text" id="title-prompt-text" for="title"><?php echo esc_html( $acf_title_placeholder ); ?></label>
<input form="post" type="text" name="post_title" size="30" value="<?php echo esc_attr( $acf_title ); ?>" id="title" class="acf-headerbar-title-field" spellcheck="true" autocomplete="off" placeholder="<?php esc_attr_e( 'Field Group Title', 'acf' ); ?>" />
</div>
<?php endif; ?>
</div>
<div class="acf-headerbar-actions" id="submitpost">
<?php if ( 'acf-field-group' === $acf_post_type ) : ?>
<a href="#" class="acf-btn acf-btn-secondary add-field">
<i class="acf-icon acf-icon-plus"></i>
<?php esc_html_e( 'Add Field', 'acf' ); ?>
</a>
<?php endif; ?>
<button form="post" class="acf-btn acf-publish" name="<?php echo esc_attr( $acf_publish_btn_name ); ?>" type="submit">
<?php esc_html_e( 'Save Changes', 'acf' ); ?>
</button>
</div>
</div>
</div>

View File

@ -0,0 +1,45 @@
<?php
//phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- included template file.
global $post_type, $post_type_object, $acf_page_title;
$post_new_file = sprintf(
'post-new.php?post_type=%s',
is_string( $post_type ) ? $post_type : 'acf-field-group'
);
$acf_is_options_page_preview = acf_request_arg( 'page' ) === 'acf_options_preview';
$page_title = false;
if ( isset( $acf_page_title ) ) {
$page_title = $acf_page_title;
} elseif ( is_object( $post_type_object ) ) {
$page_title = $post_type_object->labels->name;
}
if ( $page_title ) {
?>
<div class="acf-headerbar">
<h1 class="acf-page-title">
<?php
echo esc_html( $page_title );
?>
<?php if ( $acf_is_options_page_preview ) { ?>
<div class="acf-pro-label">PRO</div>
<?php
}
?>
</h1>
<?php if ( $acf_is_options_page_preview ) { ?>
<a href="#" class="acf-btn acf-btn-sm disabled">
<i class="acf-icon acf-icon-plus"></i>
<?php esc_html_e( 'Add Options Page', 'acf' ); ?>
</a>
<?php } ?>
<?php
if ( ! empty( $post_type_object ) && current_user_can( $post_type_object->cap->create_posts ) ) {
echo ' <a href="' . esc_url( admin_url( $post_new_file ) ) . '" class="acf-btn acf-btn-sm"><i class="acf-icon acf-icon-plus"></i>' . esc_html( $post_type_object->labels->add_new ) . '</a>';
}
?>
</div>
<?php } ?>

View File

@ -0,0 +1,256 @@
<?php
//phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- included template file.
/**
* The template for displaying admin navigation.
*
* @date 27/3/20
* @since 5.9.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
global $submenu, $submenu_file, $plugin_page, $acf_page_title;
// Setup default vars and generate array of navigation items.
$parent_slug = 'edit.php?post_type=acf-field-group';
$core_tabs = array();
$acf_more_items = array();
$more_items = array();
$wpengine_more_items = array();
// Hardcoded since future ACF post types will likely live in the "More" menu.
$core_tabs_classes = array( 'acf-field-group', 'acf-post-type', 'acf-taxonomy' );
$acf_more_items_classes = array( 'acf-ui-options-page', 'acf-tools', 'acf-settings-updates' );
if ( isset( $submenu[ $parent_slug ] ) ) {
foreach ( $submenu[ $parent_slug ] as $i => $sub_item ) {
// Check user can access page.
if ( ! current_user_can( $sub_item[1] ) ) {
continue;
}
// Define tab.
$menu_item = array(
'text' => $sub_item[0],
'url' => $sub_item[2],
);
// Convert submenu slug "test" to "$parent_slug&page=test".
if ( ! strpos( $sub_item[2], '.php' ) ) {
$menu_item['url'] = add_query_arg( array( 'page' => $sub_item[2] ), $parent_slug );
$menu_item['class'] = $sub_item[2];
} else {
// Build class from URL.
$menu_item['class'] = str_replace( 'edit.php?post_type=', '', $sub_item[2] );
}
// Detect active state.
if ( $submenu_file === $sub_item[2] || $plugin_page === $sub_item[2] ) {
$menu_item['is_active'] = true;
}
// Handle "Add New" versions of edit page.
if ( str_replace( 'edit', 'post-new', $sub_item[2] ) === $submenu_file ) {
$menu_item['is_active'] = true;
}
// Organize the menu items.
if ( in_array( $menu_item['class'], $core_tabs_classes, true ) ) {
// Main ACF tabs.
$core_tabs[] = $menu_item;
// Add post types & taxonomies to the more menu as well so we can show them there on smaller screens.
if ( in_array( $menu_item['class'], array( 'acf-post-type', 'acf-taxonomy' ), true ) ) {
$acf_more_items[] = $menu_item;
}
} elseif ( in_array( $menu_item['class'], $acf_more_items_classes, true ) ) {
// ACF tabs moved to the "More" menu.
$acf_more_items[] = $menu_item;
} else {
// Third party tabs placed into the "More" menu.
if ( 'acf_options_preview' === $menu_item['class'] ) {
continue;
}
$more_items[] = $menu_item;
}
}
}
if ( ! acf_get_setting( 'pro' ) ) {
$acf_more_items[] = array(
'url' => 'edit.php?post_type=acf-field-group&page=acf_options_preview',
'text' => __( 'Options Pages', 'acf' ) . '<span class="acf-requires-pro">' . __( 'PRO', 'acf' ) . '</span>',
'target' => '_self',
);
}
if ( ! defined( 'PWP_NAME' ) ) {
$acf_wpengine_logo = acf_get_url( 'assets/images/wp-engine-horizontal-black.svg' );
$acf_wpengine_logo = sprintf( '<span><img class="acf-wp-engine-pro" src="%s" alt="WP Engine" /></span>', $acf_wpengine_logo );
$utm_content = acf_is_pro() ? 'acf_pro_plugin_topbar_dropdown_cta' : 'acf_free_plugin_topbar_dropdown_cta';
$wpengine_more_items[] = array(
'url' => acf_add_url_utm_tags( 'https://wpengine.com/plans/?coupon=freedomtocreate', 'bx_prod_referral', $utm_content, false, 'acf_plugin', 'referral' ),
'text' => $acf_wpengine_logo . '<span class="acf-wp-engine-upsell-pill">' . __( '4 Months Free', 'acf' ) . '</span>',
'target' => '_blank',
'li_class' => 'acf-wp-engine',
);
}
/**
* Filters the admin navigation more items.
*
* @since 5.9.0
*
* @param array $more_items The array of navigation tabs.
*/
$more_items = apply_filters( 'acf/admin/toolbar', $more_items );
// Bail early if set to false.
if ( $core_tabs === false ) {
return;
}
$acf_wpengine_logo_link = acf_add_url_utm_tags(
'https://wpengine.com/',
'bx_prod_referral',
acf_is_pro() ? 'acf_pro_plugin_topbar_logo' : 'acf_free_plugin_topbar_logo',
false,
'acf_plugin',
'referral'
);
/**
* Helper function for looping over the provided menu items
* and echoing out the necessary markup.
*
* @since 6.2
*
* @param array $menu_items An array of menu items to print.
* @param string $section The section being printed.
* @return void
*/
function acf_print_menu_section( $menu_items, $section = '' ) {
// Bail if no menu items.
if ( ! is_array( $menu_items ) || empty( $menu_items ) ) {
return;
}
$section_html = '';
foreach ( $menu_items as $menu_item ) {
$class = ! empty( $menu_item['class'] ) ? $menu_item['class'] : $menu_item['text'];
$target = ! empty( $menu_item['target'] ) ? ' target="' . esc_attr( $menu_item['target'] ) . '"' : '';
$li_class = ! empty( $menu_item['li_class'] ) ? $menu_item['li_class'] : '';
$html = sprintf(
'<a class="acf-tab%s %s" href="%s"%s><i class="acf-icon"></i>%s</a>',
! empty( $menu_item['is_active'] ) ? ' is-active' : '',
'acf-header-tab-' . acf_slugify( $class ),
esc_url( $menu_item['url'] ),
$target,
acf_esc_html( $menu_item['text'] )
);
if ( 'core' !== $section ) {
if ( $li_class === '' ) {
$html = '<li>' . $html . '</li>';
} else {
$html = sprintf( '<li class="%s">', $li_class ) . $html . '</li>';
}
}
$section_html .= $html;
}
echo $section_html;
}
?>
<div class="acf-admin-toolbar">
<div class="acf-admin-toolbar-inner">
<div class="acf-nav-wrap">
<a href="<?php echo admin_url( 'edit.php?post_type=acf-field-group' ); ?>" class="acf-logo">
<img src="<?php echo acf_get_url( 'assets/images/acf-logo.svg' ); ?>" alt="<?php esc_attr_e( 'Advanced Custom Fields logo', 'acf' ); ?>">
<?php if ( acf_is_pro() && acf_pro_is_license_active() ) { ?>
<div class="acf-pro-label">PRO</div>
<?php } ?>
</a>
<h2><?php echo acf_get_setting( 'name' ); ?></h2>
<?php acf_print_menu_section( $core_tabs, 'core' ); ?>
<?php if ( $acf_more_items || $more_items ) { ?>
<div class="acf-more acf-header-tab-acf-more" tabindex="0">
<span class="acf-tab acf-more-tab"><i class="acf-icon acf-icon-more"></i><?php esc_html_e( 'More', 'acf' ); ?> <i class="acf-icon acf-icon-dropdown"></i></span>
<ul>
<?php
if ( $acf_more_items ) {
if ( $more_items ) {
echo '<li class="acf-more-section-header"><span class="acf-tab acf-tab-header">ACF</span></li>';
}
acf_print_menu_section( $acf_more_items, 'acf' );
}
if ( $more_items ) {
echo '<li class="acf-more-section-header"><span class="acf-tab acf-tab-header">' . esc_html__( 'Other', 'acf' ) . ' </span></li>';
acf_print_menu_section( $more_items );
}
if ( $wpengine_more_items ) {
acf_print_menu_section( $wpengine_more_items );
}
?>
</ul>
</div>
<?php } ?>
</div>
<div class="acf-nav-upgrade-wrap">
<?php
if ( ! acf_is_pro() || ! acf_pro_is_license_active() ) {
$unlock_url = acf_add_url_utm_tags( 'https://www.advancedcustomfields.com/pro/', 'ACF upgrade', 'header' );
$unlock_target = '_blank';
$unlock_text = __( 'Unlock Extra Features with ACF PRO', 'acf' );
if ( acf_is_pro() ) {
if ( acf_is_updates_page_visible() ) {
$unlock_url = admin_url( 'edit.php?post_type=acf-field-group&page=acf-settings-updates#acf_pro_license' );
$unlock_target = '';
}
if ( acf_pro_is_license_expired() ) {
$unlock_url = acf_add_url_utm_tags( acf_pro_get_manage_license_url(), 'ACF renewal', 'header' );
$unlock_target = '_blank';
$unlock_text = __( 'Renew ACF PRO License', 'acf' );
}
}
?>
<a target="<?php echo esc_attr( $unlock_target ); ?>" href="<?php echo esc_url( $unlock_url ); ?>" class="btn-upgrade acf-admin-toolbar-upgrade-btn">
<i class="acf-icon acf-icon-stars"></i>
<p><?php echo esc_html( $unlock_text ); ?></p>
</a>
<?php
}
?>
<a href="<?php echo $acf_wpengine_logo_link; ?>" target="_blank" class="acf-nav-wpengine-logo">
<img src="<?php echo esc_url( acf_get_url( 'assets/images/wp-engine-horizontal-white.svg' ) ); ?>" alt="<?php esc_html_e( 'WP Engine logo', 'acf' ); ?>" />
</a>
</div>
</div>
</div>
<?php
global $plugin_page;
$screen = get_current_screen();
if ( ! in_array( $screen->id, acf_get_internal_post_types(), true ) ) {
if ( $plugin_page == 'acf-tools' ) {
$acf_page_title = __( 'Tools', 'acf' );
} elseif ( $plugin_page == 'acf-settings-updates' ) {
$acf_page_title = __( 'Updates', 'acf' );
} elseif ( $plugin_page == 'acf_options_preview' && ! acf_is_pro() ) {
$acf_page_title = __( 'Options Pages', 'acf' );
}
acf_get_view( 'global/header' );
}
?>