<?php /** * Advanced Custom Fields PRO * * @package ACF * @author WP Engine * * @wordpress-plugin * Plugin Name: Advanced Custom Fields PRO * Plugin URI: https://www.advancedcustomfields.com * Description: Customize WordPress with powerful, professional and intuitive fields. * Version: 6.7.1 * Author: WP Engine * Author URI: https://wpengine.com/?utm_source=wordpress.org&utm_medium=referral&utm_campaign=plugin_directory&utm_content=advanced_custom_fields * Update URI: https://www.advancedcustomfields.com/pro * Text Domain: acf * Domain Path: /lang * Requires PHP: 7.4 * Requires at least: 6.2 */ /** * @package ACF * @author WP Engine * * © 2026 Advanced Custom Fields (ACF®). All rights reserved. * "ACF" is a trademark of WP Engine. * Licensed under the GNU General Public License v2 or later. * https://www.gnu.org/licenses/gpl-2.0.html */ if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } if ( ! class_exists( 'ACF' ) ) { /** * The main ACF class */ class ACF { /** * The plugin version number. * * @var string */ public $version = '6.7.1'; /** * The plugin settings array. * * @var array */ public $settings = array(); /** * The plugin data array. * * @var array */ public $data = array(); /** * Storage for class instances. * * @var array */ public $instances = array(); /** * The loop instance. * * @var acf_loop */ public $loop; /** * The revisions instance. * * @var acf_revisions */ public $revisions; /** * The fields instance. * * @var acf_fields */ public $fields; /** * The form front instance. * * @var acf_form_front */ public $form_front; /** * The validation instance. * * @var acf_validation */ public $validation; /** * The admin tools instance. * * @var acf_admin_tools */ public $admin_tools; /** * A dummy constructor to ensure ACF is only setup once. * * @date 23/06/12 * @since 5.0.0 */ public function __construct() { // Do nothing. } /** * Sets up the ACF plugin. * * @date 28/09/13 * @since 5.0.0 */ public function initialize() { // Define constants. $this->define( 'ACF', true ); $this->define( 'ACF_PATH', plugin_dir_path( __FILE__ ) ); $this->define( 'ACF_BASENAME', plugin_basename( __FILE__ ) ); $this->define( 'ACF_VERSION', $this->version ); $this->define( 'ACF_MAJOR_VERSION', 6 ); $this->define( 'ACF_FIELD_API_VERSION', 5 ); $this->define( 'ACF_UPGRADE_VERSION', '5.5.0' ); // Highest version with an upgrade routine. See upgrades.php. // Register activation hook. register_activation_hook( __FILE__, array( $this, 'acf_plugin_activated' ) ); // Define settings. $this->settings = array( 'name' => 'Advanced Custom Fields', 'slug' => dirname( ACF_BASENAME ), 'version' => ACF_VERSION, 'basename' => ACF_BASENAME, 'path' => ACF_PATH, 'file' => __FILE__, 'url' => plugin_dir_url( __FILE__ ), 'show_admin' => true, 'show_updates' => true, 'enable_post_types' => true, 'enable_options_pages_ui' => true, 'stripslashes' => false, 'local' => true, 'json' => true, 'save_json' => '', 'load_json' => array(), 'default_language' => '', 'current_language' => '', 'capability' => 'manage_options', 'uploader' => 'wp', 'autoload' => false, 'l10n' => true, 'l10n_textdomain' => '', 'google_api_key' => '', 'google_api_client' => '', 'enqueue_google_maps' => true, 'enqueue_select2' => true, 'enqueue_datepicker' => true, 'enqueue_datetimepicker' => true, 'select2_version' => 4, 'row_index_offset' => 1, 'remove_wp_meta_box' => true, 'rest_api_enabled' => true, 'rest_api_format' => 'light', 'rest_api_embed_links' => true, 'preload_blocks' => true, 'enable_shortcode' => true, 'enable_bidirection' => true, 'enable_block_bindings' => true, 'enable_meta_box_cb_edit' => true, ); // Include autoloader. include_once __DIR__ . '/vendor/autoload.php'; // Include utility functions. include_once ACF_PATH . 'includes/acf-utility-functions.php'; // Include previous API functions. acf_include( 'includes/api/api-helpers.php' ); acf_include( 'includes/api/api-template.php' ); acf_include( 'includes/api/api-term.php' ); // Include classes. acf_include( 'includes/class-acf-data.php' ); acf_include( 'includes/class-acf-internal-post-type.php' ); acf_include( 'includes/fields/class-acf-field.php' ); acf_include( 'includes/locations/abstract-acf-legacy-location.php' ); acf_include( 'includes/locations/abstract-acf-location.php' ); // Initialise autoloaded classes. new ACF\Site_Health\Site_Health(); // Include functions. acf_include( 'includes/acf-helper-functions.php' ); acf_new_instance( 'ACF\Meta\Comment' ); acf_new_instance( 'ACF\Meta\Post' ); acf_new_instance( 'ACF\Meta\Term' ); acf_new_instance( 'ACF\Meta\User' ); acf_new_instance( 'ACF\Meta\Option' ); acf_include( 'includes/acf-hook-functions.php' ); acf_include( 'includes/acf-field-functions.php' ); acf_include( 'includes/acf-bidirectional-functions.php' ); acf_include( 'includes/acf-internal-post-type-functions.php' ); acf_include( 'includes/acf-post-type-functions.php' ); acf_include( 'includes/acf-taxonomy-functions.php' ); acf_include( 'includes/acf-field-group-functions.php' ); acf_include( 'includes/acf-form-functions.php' ); acf_include( 'includes/acf-meta-functions.php' ); acf_include( 'includes/acf-post-functions.php' ); acf_include( 'includes/acf-user-functions.php' ); acf_include( 'includes/acf-value-functions.php' ); acf_include( 'includes/acf-input-functions.php' ); acf_include( 'includes/acf-wp-functions.php' ); // Override the shortcode default value based on the version when installed. $first_activated_version = acf_get_version_when_first_activated(); // Only enable shortcode by default for versions prior to 6.3 if ( $first_activated_version && version_compare( $first_activated_version, '6.3', '>=' ) ) { $this->settings['enable_shortcode'] = false; } // Include core. acf_include( 'includes/fields.php' ); acf_include( 'includes/locations.php' ); acf_include( 'includes/assets.php' ); acf_include( 'includes/compatibility.php' ); acf_include( 'includes/deprecated.php' ); acf_include( 'includes/l10n.php' ); acf_include( 'includes/local-fields.php' ); acf_include( 'includes/local-meta.php' ); acf_include( 'includes/local-json.php' ); acf_include( 'includes/loop.php' ); acf_include( 'includes/media.php' ); acf_include( 'includes/revisions.php' ); acf_include( 'includes/upgrades.php' ); acf_include( 'includes/validation.php' ); acf_include( 'includes/rest-api.php' ); // Include field group class. acf_include( 'includes/post-types/class-acf-field-group.php' ); // Include ajax. acf_include( 'includes/ajax/class-acf-ajax.php' ); acf_include( 'includes/ajax/class-acf-ajax-check-screen.php' ); acf_include( 'includes/ajax/class-acf-ajax-user-setting.php' ); acf_include( 'includes/ajax/class-acf-ajax-upgrade.php' ); acf_include( 'includes/ajax/class-acf-ajax-query.php' ); acf_include( 'includes/ajax/class-acf-ajax-query-users.php' ); acf_include( 'includes/ajax/class-acf-ajax-local-json-diff.php' ); // Include forms. acf_include( 'includes/forms/form-attachment.php' ); acf_include( 'includes/forms/form-comment.php' ); acf_include( 'includes/forms/form-customizer.php' ); acf_include( 'includes/forms/form-front.php' ); acf_include( 'includes/forms/form-nav-menu.php' ); acf_include( 'includes/forms/form-post.php' ); acf_include( 'includes/forms/form-gutenberg.php' ); acf_include( 'includes/forms/form-taxonomy.php' ); acf_include( 'includes/forms/form-user.php' ); acf_include( 'includes/forms/form-widget.php' ); // Include admin. if ( is_admin() ) { acf_include( 'includes/admin/admin.php' ); acf_include( 'includes/admin/admin-internal-post-type-list.php' ); acf_include( 'includes/admin/admin-internal-post-type.php' ); acf_include( 'includes/admin/admin-notices.php' ); acf_include( 'includes/admin/admin-tools.php' ); acf_include( 'includes/admin/admin-upgrade.php' ); } // Include legacy. acf_include( 'includes/legacy/legacy-locations.php' ); // Include updater if included with this build. acf_include( 'includes/Updater/init.php' ); // Include PRO if included with this build. if ( ! defined( 'ACF_PREVENT_PRO_LOAD' ) || ( defined( 'ACF_PREVENT_PRO_LOAD' ) && ! ACF_PREVENT_PRO_LOAD ) ) { acf_include( 'pro/acf-pro.php' ); } if ( is_admin() && function_exists( 'acf_is_pro' ) && ! acf_is_pro() ) { acf_include( 'includes/admin/admin-options-pages-preview.php' ); } // Add actions. add_action( 'init', array( $this, 'register_post_status' ), 4 ); add_action( 'init', array( $this, 'init' ), 5 ); add_action( 'init', array( $this, 'register_post_types' ), 5 ); add_action( 'activated_plugin', array( $this, 'deactivate_other_instances' ) ); add_action( 'pre_current_active_plugins', array( $this, 'plugin_deactivated_notice' ) ); // Add filters. add_filter( 'posts_where', array( $this, 'posts_where' ), 10, 2 ); } /** * Completes the setup process on "init" of earlier. * * @date 28/09/13 * @since 5.0.0 */ public function init() { // Bail early if called directly from functions.php or plugin file. if ( ! did_action( 'plugins_loaded' ) ) { return; } // This function may be called directly from template functions. Bail early if already did this. if ( acf_did( 'init' ) ) { return; } // Update url setting. Allows other plugins to modify the URL (force SSL). acf_update_setting( 'url', plugin_dir_url( __FILE__ ) ); // Load textdomain file. acf_load_textdomain(); // Make plugin name translatable. acf_update_setting( 'name', __( 'Advanced Custom Fields', 'acf' ) ); // Include 3rd party compatiblity. acf_include( 'includes/third-party.php' ); // Include wpml support. if ( defined( 'ICL_SITEPRESS_VERSION' ) ) { acf_include( 'includes/wpml.php' ); } // Add post types and taxonomies. if ( acf_get_setting( 'enable_post_types' ) ) { acf_include( 'includes/post-types/class-acf-taxonomy.php' ); acf_include( 'includes/post-types/class-acf-post-type.php' ); } // Add other ACF internal post types. do_action( 'acf/init_internal_post_types' ); // Include fields. acf_include( 'includes/fields/class-acf-field-text.php' ); acf_include( 'includes/fields/class-acf-field-textarea.php' ); acf_include( 'includes/fields/class-acf-field-number.php' ); acf_include( 'includes/fields/class-acf-field-range.php' ); acf_include( 'includes/fields/class-acf-field-email.php' ); acf_include( 'includes/fields/class-acf-field-url.php' ); acf_include( 'includes/fields/class-acf-field-password.php' ); acf_include( 'includes/fields/class-acf-field-image.php' ); acf_include( 'includes/fields/class-acf-field-file.php' ); acf_include( 'includes/fields/class-acf-field-wysiwyg.php' ); acf_include( 'includes/fields/class-acf-field-oembed.php' ); acf_include( 'includes/fields/class-acf-field-select.php' ); acf_include( 'includes/fields/class-acf-field-checkbox.php' ); acf_include( 'includes/fields/class-acf-field-radio.php' ); acf_include( 'includes/fields/class-acf-field-button-group.php' ); acf_include( 'includes/fields/class-acf-field-true_false.php' ); acf_include( 'includes/fields/class-acf-field-link.php' ); acf_include( 'includes/fields/class-acf-field-post_object.php' ); acf_include( 'includes/fields/class-acf-field-page_link.php' ); acf_include( 'includes/fields/class-acf-field-relationship.php' ); acf_include( 'includes/fields/class-acf-field-taxonomy.php' ); acf_include( 'includes/fields/class-acf-field-user.php' ); acf_include( 'includes/fields/class-acf-field-google-map.php' ); acf_include( 'includes/fields/class-acf-field-date_picker.php' ); acf_include( 'includes/fields/class-acf-field-date_time_picker.php' ); acf_include( 'includes/fields/class-acf-field-time_picker.php' ); acf_include( 'includes/fields/class-acf-field-color_picker.php' ); acf_include( 'includes/fields/class-acf-field-icon_picker.php' ); acf_include( 'includes/fields/class-acf-field-message.php' ); acf_include( 'includes/fields/class-acf-field-accordion.php' ); acf_include( 'includes/fields/class-acf-field-tab.php' ); acf_include( 'includes/fields/class-acf-field-group.php' ); /** * Fires after field types have been included. * * @date 28/09/13 * @since 5.0.0 * * @param int ACF_FIELD_API_VERSION The field API version. */ do_action( 'acf/include_field_types', ACF_FIELD_API_VERSION ); // Include locations. acf_include( 'includes/locations/class-acf-location-post-type.php' ); acf_include( 'includes/locations/class-acf-location-post-template.php' ); acf_include( 'includes/locations/class-acf-location-post-status.php' ); acf_include( 'includes/locations/class-acf-location-post-format.php' ); acf_include( 'includes/locations/class-acf-location-post-category.php' ); acf_include( 'includes/locations/class-acf-location-post-taxonomy.php' ); acf_include( 'includes/locations/class-acf-location-post.php' ); acf_include( 'includes/locations/class-acf-location-page-template.php' ); acf_include( 'includes/locations/class-acf-location-page-type.php' ); acf_include( 'includes/locations/class-acf-location-page-parent.php' ); acf_include( 'includes/locations/class-acf-location-page.php' ); acf_include( 'includes/locations/class-acf-location-current-user.php' ); acf_include( 'includes/locations/class-acf-location-current-user-role.php' ); acf_include( 'includes/locations/class-acf-location-user-form.php' ); acf_include( 'includes/locations/class-acf-location-user-role.php' ); acf_include( 'includes/locations/class-acf-location-taxonomy.php' ); acf_include( 'includes/locations/class-acf-location-attachment.php' ); acf_include( 'includes/locations/class-acf-location-comment.php' ); acf_include( 'includes/locations/class-acf-location-widget.php' ); acf_include( 'includes/locations/class-acf-location-nav-menu.php' ); acf_include( 'includes/locations/class-acf-location-nav-menu-item.php' ); /** * Fires after location types have been included. * * @date 28/09/13 * @since 5.0.0 * * @param int ACF_FIELD_API_VERSION The field API version. */ do_action( 'acf/include_location_rules', ACF_FIELD_API_VERSION ); /** * Fires during initialization. Used to add local fields. * * @date 28/09/13 * @since 5.0.0 * * @param int ACF_FIELD_API_VERSION The field API version. */ do_action( 'acf/include_fields', ACF_FIELD_API_VERSION ); /** * Fires during initialization. Used to add local post types. * * @since 6.1 * * @param int ACF_MAJOR_VERSION The major version of ACF. */ do_action( 'acf/include_post_types', ACF_MAJOR_VERSION ); /** * Fires during initialization. Used to add local taxonomies. * * @since 6.1 * * @param int ACF_MAJOR_VERSION The major version of ACF. */ do_action( 'acf/include_taxonomies', ACF_MAJOR_VERSION ); // If we're on 6.5 or newer, load block bindings. if ( version_compare( get_bloginfo( 'version' ), '6.5', '>=' ) ) { new ACF\Blocks\Bindings(); } /** * Fires after ACF is completely "initialized". * * @date 28/09/13 * @since 5.0.0 * * @param int ACF_MAJOR_VERSION The major version of ACF. */ do_action( 'acf/init', ACF_MAJOR_VERSION ); } /** * Registers the ACF post types. * * @date 22/10/2015 * @since 5.3.2 */ public function register_post_types() { $cap = acf_get_setting( 'capability' ); // Register the Field Group post type. register_post_type( 'acf-field-group', array( 'labels' => array( 'name' => __( 'Field Groups', 'acf' ), 'singular_name' => __( 'Field Group', 'acf' ), 'add_new' => __( 'Add New', 'acf' ), 'add_new_item' => __( 'Add New Field Group', 'acf' ), 'edit_item' => __( 'Edit Field Group', 'acf' ), 'new_item' => __( 'New Field Group', 'acf' ), 'view_item' => __( 'View Field Group', 'acf' ), 'search_items' => __( 'Search Field Groups', 'acf' ), 'not_found' => __( 'No Field Groups found', 'acf' ), 'not_found_in_trash' => __( 'No Field Groups found in Trash', 'acf' ), ), 'public' => false, 'hierarchical' => true, 'show_ui' => true, 'show_in_menu' => false, '_builtin' => false, 'capability_type' => 'post', 'capabilities' => array( 'edit_post' => $cap, 'delete_post' => $cap, 'edit_posts' => $cap, 'delete_posts' => $cap, ), 'supports' => false, 'rewrite' => false, 'query_var' => false, ) ); // Register the Field post type. register_post_type( 'acf-field', array( 'labels' => array( 'name' => __( 'Fields', 'acf' ), 'singular_name' => __( 'Field', 'acf' ), 'add_new' => __( 'Add New', 'acf' ), 'add_new_item' => __( 'Add New Field', 'acf' ), 'edit_item' => __( 'Edit Field', 'acf' ), 'new_item' => __( 'New Field', 'acf' ), 'view_item' => __( 'View Field', 'acf' ), 'search_items' => __( 'Search Fields', 'acf' ), 'not_found' => __( 'No Fields found', 'acf' ), 'not_found_in_trash' => __( 'No Fields found in Trash', 'acf' ), ), 'public' => false, 'hierarchical' => true, 'show_ui' => false, 'show_in_menu' => false, '_builtin' => false, 'capability_type' => 'post', 'capabilities' => array( 'edit_post' => $cap, 'delete_post' => $cap, 'edit_posts' => $cap, 'delete_posts' => $cap, ), 'supports' => array( 'title' ), 'rewrite' => false, 'query_var' => false, ) ); } /** * Registers the ACF post statuses. * * @date 22/10/2015 * @since 5.3.2 */ public function register_post_status() { // Register the Inactive post status. register_post_status( 'acf-disabled', array( 'label' => _x( 'Inactive', 'post status', 'acf' ), 'public' => true, 'exclude_from_search' => false, 'show_in_admin_all_list' => true, 'show_in_admin_status_list' => true, /* translators: counts for inactive field groups */ 'label_count' => _n_noop( 'Inactive <span class="count">(%s)</span>', 'Inactive <span class="count">(%s)</span>', 'acf' ), ) ); } /** * Checks if another version of ACF/ACF PRO is active and deactivates it. * Hooked on `activated_plugin` so other plugin is deactivated when current plugin is activated. * * @param string $plugin The plugin being activated. */ public function deactivate_other_instances( $plugin ) { if ( ! in_array( $plugin, array( 'advanced-custom-fields/acf.php', 'advanced-custom-fields-pro/acf.php' ), true ) ) { return; } $plugin_to_deactivate = 'advanced-custom-fields/acf.php'; $deactivated_notice_id = '1'; // If we just activated the free version, deactivate the pro version. if ( $plugin === $plugin_to_deactivate ) { $plugin_to_deactivate = 'advanced-custom-fields-pro/acf.php'; $deactivated_notice_id = '2'; } if ( is_multisite() && is_network_admin() ) { $active_plugins = (array) get_site_option( 'active_sitewide_plugins', array() ); $active_plugins = array_keys( $active_plugins ); } else { $active_plugins = (array) get_option( 'active_plugins', array() ); } foreach ( $active_plugins as $plugin_basename ) { if ( $plugin_to_deactivate === $plugin_basename ) { set_transient( 'acf_deactivated_notice_id', $deactivated_notice_id, 1 * HOUR_IN_SECONDS ); deactivate_plugins( $plugin_basename ); return; } } } /** * Displays a notice when either ACF or ACF PRO is automatically deactivated. */ public function plugin_deactivated_notice() { $deactivated_notice_id = (int) get_transient( 'acf_deactivated_notice_id' ); if ( ! in_array( $deactivated_notice_id, array( 1, 2 ), true ) ) { return; } $message = __( "Advanced Custom Fields and Advanced Custom Fields PRO should not be active at the same time. We've automatically deactivated Advanced Custom Fields.", 'acf' ); if ( 2 === $deactivated_notice_id ) { $message = __( "Advanced Custom Fields and Advanced Custom Fields PRO should not be active at the same time. We've automatically deactivated Advanced Custom Fields PRO.", 'acf' ); } ?> <div class="updated" style="border-left: 4px solid #ffba00;"> <p><?php echo esc_html( $message ); ?></p> </div> <?php delete_transient( 'acf_deactivated_notice_id' ); } /** * Filters the $where clause allowing for custom WP_Query args. * * @date 31/8/19 * @since 5.8.1 * * @param string $where The WHERE clause. * @param WP_Query $wp_query The query object. * @return string */ public function posts_where( $where, $wp_query ) { global $wpdb; $field_key = $wp_query->get( 'acf_field_key' ); $field_name = $wp_query->get( 'acf_field_name' ); $group_key = $wp_query->get( 'acf_group_key' ); $post_type_key = $wp_query->get( 'acf_post_type_key' ); $taxonomy_key = $wp_query->get( 'acf_taxonomy_key' ); // Add custom "acf_field_key" arg. if ( $field_key ) { $where .= $wpdb->prepare( " AND {$wpdb->posts}.post_name = %s", $field_key ); } // Add custom "acf_field_name" arg. if ( $field_name ) { $where .= $wpdb->prepare( " AND {$wpdb->posts}.post_excerpt = %s", $field_name ); } // Add custom "acf_group_key" arg. if ( $group_key ) { $where .= $wpdb->prepare( " AND {$wpdb->posts}.post_name = %s", $group_key ); } // Add custom "acf_post_type_key" arg. if ( $post_type_key ) { $where .= $wpdb->prepare( " AND {$wpdb->posts}.post_name = %s", $post_type_key ); } // Add custom "acf_taxonomy_key" arg. if ( $taxonomy_key ) { $where .= $wpdb->prepare( " AND {$wpdb->posts}.post_name = %s", $taxonomy_key ); } return $where; } /** * Defines a constant if doesnt already exist. * * @date 3/5/17 * @since 5.5.13 * * @param string $name The constant name. * @param mixed $value The constant value. * @return void */ public function define( $name, $value = true ) { if ( ! defined( $name ) ) { define( $name, $value ); } } /** * Returns true if a setting exists for this name. * * @date 2/2/18 * @since 5.6.5 * * @param string $name The setting name. * @return boolean */ public function has_setting( $name ) { return isset( $this->settings[ $name ] ); } /** * Returns a setting or null if doesn't exist. * * @date 28/09/13 * @since 5.0.0 * * @param string $name The setting name. * @return mixed */ public function get_setting( $name ) { return isset( $this->settings[ $name ] ) ? $this->settings[ $name ] : null; } /** * Updates a setting for the given name and value. * * @date 28/09/13 * @since 5.0.0 * * @param string $name The setting name. * @param mixed $value The setting value. * @return true */ public function update_setting( $name, $value ) { $this->settings[ $name ] = $value; return true; } /** * Returns data or null if doesn't exist. * * @date 28/09/13 * @since 5.0.0 * * @param string $name The data name. * @return mixed */ public function get_data( $name ) { return isset( $this->data[ $name ] ) ? $this->data[ $name ] : null; } /** * Sets data for the given name and value. * * @date 28/09/13 * @since 5.0.0 * * @param string $name The data name. * @param mixed $value The data value. * @return void */ public function set_data( $name, $value ) { $this->data[ $name ] = $value; } /** * Returns an instance or null if doesn't exist. * * @date 13/2/18 * @since 5.6.9 * * @param string $class The instance class name. * @return object */ public function get_instance( $class ) { $name = strtolower( $class ); return isset( $this->instances[ $name ] ) ? $this->instances[ $name ] : null; } /** * Creates and stores an instance of the given class. * * @date 13/2/18 * @since 5.6.9 * * @param string $class The instance class name. * @return object */ public function new_instance( $class ) { $instance = new $class(); $name = strtolower( $class ); $this->instances[ $name ] = $instance; return $instance; } /** * Magic __isset method for backwards compatibility. * * @date 24/4/20 * @since 5.9.0 * * @param string $key Key name. * @return boolean */ public function __isset( $key ) { return in_array( $key, array( 'locations', 'json' ), true ); } /** * Magic __get method for backwards compatibility. * * @date 24/4/20 * @since 5.9.0 * * @param string $key Key name. * @return mixed */ public function __get( $key ) { switch ( $key ) { case 'locations': return acf_get_instance( 'ACF_Legacy_Locations' ); case 'json': return acf_get_instance( 'ACF_Local_JSON' ); } return null; } /** * Plugin Activation Hook * * @since 6.2.6 */ public function acf_plugin_activated() { // Set the first activated version of ACF. if ( null === get_option( 'acf_first_activated_version', null ) ) { // If acf_version is set, this isn't the first activated version, so leave it unset so it's legacy. if ( null === get_option( 'acf_version', null ) ) { update_option( 'acf_first_activated_version', ACF_VERSION, true ); do_action( 'acf/first_activated' ); } } if ( acf_is_pro() ) { do_action( 'acf/activated_pro' ); } } } /** * An ACF specific getter to replace `home_url` in our license checks to ensure we can avoid third party filters. * * @since 6.0.1 * @since 6.2.8 - Renamed to acf_pro_get_home_url to match pro exclusive function naming. * @since 6.3.10 - Renamed to acf_get_home_url now updater logic applies to free. * * @return string $home_url The output from home_url, sans known third party filters which cause license activation issues. */ function acf_get_home_url() { if ( acf_is_pro() ) { // Disable WPML and TranslatePress's home url overrides for our license check. add_filter( 'wpml_get_home_url', 'acf_pro_license_ml_intercept', 99, 2 ); add_filter( 'trp_home_url', 'acf_pro_license_ml_intercept', 99, 2 ); if ( acf_pro_is_legacy_multisite() && acf_is_multisite_sub_site() ) { $home_url = get_home_url( get_main_site_id() ); } else { $home_url = home_url(); } // Re-enable WPML and TranslatePress's home url overrides. remove_filter( 'wpml_get_home_url', 'acf_pro_license_ml_intercept', 99 ); remove_filter( 'trp_home_url', 'acf_pro_license_ml_intercept', 99 ); } else { $home_url = home_url(); } return $home_url; } /** * The main function responsible for returning the one true acf Instance to functions everywhere. * Use this function like you would a global variable, except without needing to declare the global. * * Example: <?php $acf = acf(); ?> * * @date 4/09/13 * @since 4.3.0 * * @return ACF */ function acf() { global $acf; // Instantiate only once. if ( ! isset( $acf ) ) { $acf = new ACF(); $acf->initialize(); } return $acf; } // Instantiate. acf(); } // class_exists check <?php /** * nlc-theme functions and definitions * * @link https://developer.wordpress.org/themes/basics/theme-functions/ * * @package nlc-theme */ if ( ! defined( '_S_VERSION' ) ) { // Replace the version number of the theme on each release. define( '_S_VERSION', '1.0.0' ); } if ( ! function_exists( 'nlc_theme_setup' ) ) : /** * Sets up theme defaults and registers support for various WordPress features. * * Note that this function is hooked into the after_setup_theme hook, which * runs before the init hook. The init hook is too late for some features, such * as indicating support for post thumbnails. */ function nlc_theme_setup() { /* * Make theme available for translation. * Translations can be filed in the /languages/ directory. * If you're building a theme based on nlc-theme, use a find and replace * to change 'nlc-theme' to the name of your theme in all the template files. */ load_theme_textdomain( 'nlc-theme', get_template_directory() . '/languages' ); // Add default posts and comments RSS feed links to head. // add_theme_support( 'automatic-feed-links' ); /* * Let WordPress manage the document title. * By adding theme support, we declare that this theme does not use a * hard-coded <title> tag in the document head, and expect WordPress to * provide it for us. */ add_theme_support( 'title-tag' ); /* * Enable support for Post Thumbnails on posts and pages. * * @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/ */ add_theme_support( 'post-thumbnails' ); // This theme uses wp_nav_menu() in one location. register_nav_menus( array( 'menu-1' => esc_html__( 'Primary Header', 'nlc-theme' ), 'menu-2' => esc_html__( 'Secondary Header', 'nlc-theme' ), 'menu-3' => esc_html__( 'Primary Footer', 'nlc-theme' ), 'menu-4' => esc_html__( 'Alumni Footer Menu', 'nlc-theme' ), 'menu-5' => esc_html__( 'Secondary Footer', 'nlc-theme' ), ) ); /* * Switch default core markup for search form, comment form, and comments * to output valid HTML5. */ // add_theme_support( // 'html5', // array( // 'search-form', // 'comment-form', // 'comment-list', // 'gallery', // 'caption', // 'style', // 'script', // ) // ); // Set up the WordPress core custom background feature. // add_theme_support( // 'custom-background', // apply_filters( // 'nlc_theme_custom_background_args', // array( // 'default-color' => 'ffffff', // 'default-image' => '', // ) // ) // ); // Add theme support for selective refresh for widgets. // add_theme_support( 'customize-selective-refresh-widgets' ); /** * Add support for core custom logo. * * @link https://codex.wordpress.org/Theme_Logo */ // add_theme_support( // 'custom-logo', // array( // 'height' => 250, // 'width' => 250, // 'flex-width' => true, // 'flex-height' => true, // ) // ); if( function_exists('acf_add_options_page') ) { acf_add_options_page(array( 'page_title' => 'Theme General Settings', 'menu_title' => 'Theme Settings', 'menu_slug' => 'theme-general-settings', 'capability' => 'edit_posts', 'redirect' => false )); } } endif; add_action( 'after_setup_theme', 'nlc_theme_setup' ); /** * Set the content width in pixels, based on the theme's design and stylesheet. * * Priority 0 to make it available to lower priority callbacks. * * @global int $content_width */ function nlc_theme_content_width() { $GLOBALS['content_width'] = apply_filters( 'nlc_theme_content_width', 640 ); } add_action( 'after_setup_theme', 'nlc_theme_content_width', 0 ); /** * Register widget area. * * @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar */ function nlc_theme_widgets_init() { /* Remove sidebar for theme. */ // register_sidebar( // array( // 'name' => esc_html__( 'Sidebar', 'nlc-theme' ), // 'id' => 'sidebar-1', // 'description' => esc_html__( 'Add widgets here.', 'nlc-theme' ), // 'before_widget' => '<section id="%1$s" class="widget %2$s">', // 'after_widget' => '</section>', // 'before_title' => '<h2 class="widget-title">', // 'after_title' => '</h2>', // ) // ); } add_action( 'widgets_init', 'nlc_theme_widgets_init' ); /** * Enqueue scripts and styles. */ function nlc_theme_scripts() { wp_enqueue_style( 'nlc-theme-style', get_stylesheet_uri(), array(), _S_VERSION ); wp_enqueue_style('nlc-theme-shared-style', get_template_directory_uri() . '/shared-style.min.css', array(), _S_VERSION); wp_style_add_data( 'nlc-theme-style', 'rtl', 'replace' ); wp_enqueue_script( 'nlc-theme-gsap', get_template_directory_uri() . '/js/gsap.min.js', array(), _S_VERSION, true ); wp_enqueue_script( 'nlc-theme-ScrollTrigger', get_template_directory_uri() . '/js/ScrollTrigger.min.js', array(), _S_VERSION, true ); wp_enqueue_script( 'nlc-theme-navigation', get_template_directory_uri() . '/js/navigation.js', array('jquery'), _S_VERSION, true ); wp_enqueue_script('jquery'); wp_enqueue_style('tinyslider', 'https://cdnjs.cloudflare.com/ajax/libs/tiny-slider/2.9.3/tiny-slider.css'); wp_enqueue_script( 'tinyslider', 'https://cdnjs.cloudflare.com/ajax/libs/tiny-slider/2.9.2/min/tiny-slider.js'); wp_enqueue_script( 'masonry', 'https://unpkg.com/masonry-layout@4.2.2/dist/masonry.pkgd.min.js'); if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply' ); } wp_enqueue_script( 'custom.js', get_template_directory_uri().'/js/custom.js', array( 'jquery' ), null, true ); // Localize the script with new data $script_data_array = array( 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'security' => wp_create_nonce( 'load_more_posts' ), ); wp_localize_script( 'custom.js', 'blog', $script_data_array ); } add_action( 'wp_enqueue_scripts', 'nlc_theme_scripts' ); function nlc_theme_admin_scripts( $hook ) { wp_enqueue_style('tinyslider', 'https://cdnjs.cloudflare.com/ajax/libs/tiny-slider/2.9.3/tiny-slider.css'); wp_enqueue_script( 'tinyslider', 'https://cdnjs.cloudflare.com/ajax/libs/tiny-slider/2.9.2/min/tiny-slider.js'); wp_enqueue_script( 'masonry', 'https://unpkg.com/masonry-layout@4.2.2/dist/masonry.pkgd.min.js'); } add_action( 'admin_enqueue_scripts', 'nlc_theme_admin_scripts' ); /** * Implement the Custom Header feature. */ require get_template_directory() . '/inc/custom-header.php'; /** * Custom template tags for this theme. */ require get_template_directory() . '/inc/template-tags.php'; /** * Functions which enhance the theme by hooking into WordPress. */ require get_template_directory() . '/inc/template-functions.php'; /** * Customizer additions. */ require get_template_directory() . '/inc/customizer.php'; /** * Load Jetpack compatibility file. */ if ( defined( 'JETPACK__VERSION' ) ) { require get_template_directory() . '/inc/jetpack.php'; } // // Adjust your form ID // add_filter( 'gform_form_post_get_meta_1', 'add_my_field' ); // function add_my_field( $form ) { // // Create a Single Line text field for the team member's name // $quoteText = GF_Fields::create( array( // 'type' => 'text', // 'id' => 1002, // The Field ID must be unique on the form // 'formId' => $form['id'], // 'label' => 'Name', // 'pageNumber' => 1, // Ensure this is correct // ) ); // // Create an email field for the team member's email address // $nameOfPersonQuoted = GF_Fields::create( array( // 'type' => 'email', // 'id' => 1001, // The Field ID must be unique on the form // 'formId' => $form['id'], // 'label' => 'Email', // 'pageNumber' => 1, // Ensure this is correct // ) ); // // Create an email field for the team member's email address // $titleOfPersonQuoted = GF_Fields::create( array( // 'type' => 'email', // 'id' => 1001, // The Field ID must be unique on the form // 'formId' => $form['id'], // 'label' => 'Email', // 'pageNumber' => 1, // Ensure this is correct // ) ); // // Create an email field for the team member's email address // $photoOfPersonQuoted = GF_Fields::create( array( // 'type' => 'fileupload', // 'id' => 1001, // The Field ID must be unique on the form // 'formId' => $form['id'], // 'label' => 'Email', // 'pageNumber' => 1, // Ensure this is correct // ) ); // // Create a repeater for the team members and add the name and email fields as the fields to display inside the repeater. // $quote = GF_Fields::create( array( // 'type' => 'repeater', // 'description' => 'Maximum of 5 quotes.', // 'id' => 1000, // The Field ID must be unique on the form // 'formId' => $form['id'], // 'label' => 'Quotes', // 'addButtonText' => 'Add Quote', // Optional // 'removeButtonText' => 'Remove Quote', // Optional // 'maxItems' => 5, // Optional // 'pageNumber' => 1, // Ensure this is correct // 'fields' => array( $quoteText, $nameOfPersonQuoted, $titleOfPersonQuoted ), // Add the fields here. // ) ); // $form['fields'][] = $team; // return $form; // } // // Remove the field before the form is saved. Adjust your form ID // add_filter( 'gform_form_update_meta_1', 'remove_my_field', 10, 3 ); // function remove_my_field( $form_meta, $form_id, $meta_name ) { // if ( $meta_name == 'display_meta' ) { // // Remove the Repeater field: ID 1000 // $form_meta['fields'] = wp_list_filter( $form_meta['fields'], array( 'id' => 1000 ), 'NOT' ); // } // return $form_meta; // } function gb_gutenberg_admin_styles() { echo ' <style> /* Main column width */ .wp-block { max-width: 100%; } /* Width of "wide" blocks */ // .wp-block[data-align="wide"] { // max-width: 1080px; // } /* Width of "full-wide" blocks */ // .wp-block[data-align="full"] { // max-width: none; // } </style> '; } add_action('admin_head', 'gb_gutenberg_admin_styles'); add_action('acf/init', 'my_acf_init_block_types'); function my_acf_init_block_types() { // Check function exists. if( function_exists('acf_register_block_type') ) { acf_register_block_type(array( 'name' => 'hero-intro-section', 'title' => __('NLC - Hero Intro Section'), 'description' => __('A hero intro block.'), 'render_template' => 'template-parts/blocks/hero-intro-section/hero-intro-section.php', 'category' => 'nlc-custom', 'icon' => 'cover-image', 'keywords' => array( 'marquee', 'hero' ), 'supports' => array( 'align' => false, 'anchor' => true, ), 'enqueue_style' => get_template_directory_uri() . '/template-parts/blocks/hero-intro-section/hero-intro-section.min.css', )); acf_register_block_type(array( 'name' => 'call-to-action', 'title' => __('NLC - Call to Action'), 'description' => __('A call to action block.'), 'render_template' => 'template-parts/blocks/call-to-action/call-to-action.php', 'category' => 'nlc-custom', 'icon' => 'cover-image', 'keywords' => array( 'cta', 'NLC', 'call to action' ), 'supports' => array( 'align' => false, 'anchor' => true, ), 'enqueue_style' => get_template_directory_uri() . '/template-parts/blocks/call-to-action/call-to-action.min.css', 'enqueue_script' => get_template_directory_uri() . '/template-parts/blocks/call-to-action/call-to-action.js', )); acf_register_block_type(array( 'name' => 'highlights-section', 'title' => __('NLC - Highlights Section'), 'description' => __('A highlights section block.'), 'render_template' => 'template-parts/blocks/highlights-section/highlights-section.php', 'category' => 'nlc-custom', 'icon' => 'cover-image', 'keywords' => array( 'highlights', 'NLC' ), 'supports' => array( 'align' => false, 'anchor' => true, ), 'enqueue_style' => get_template_directory_uri() . '/template-parts/blocks/highlights-section/highlights-section.min.css', 'enqueue_script' => get_template_directory_uri() . '/template-parts/blocks/highlights-section/highlights-section.js', )); acf_register_block_type(array( 'name' => 'quotes-section', 'title' => __('NLC - Quotes Section'), 'description' => __('A quotes section block.'), 'render_template' => 'template-parts/blocks/quotes-section/quotes-section.php', 'category' => 'nlc-custom', 'icon' => 'cover-image', 'keywords' => array( 'quotes', 'NLC' ), 'supports' => array( 'align' => false, 'anchor' => true, ), 'enqueue_style' => get_template_directory_uri() . '/template-parts/blocks/quotes-section/quotes-section.min.css', )); acf_register_block_type(array( 'name' => 'two-images-section', 'title' => __('NLC - Two Images Section'), 'description' => __('A quotes section block.'), 'render_template' => 'template-parts/blocks/two-images-section/two-images-section.php', 'category' => 'nlc-custom', 'icon' => 'cover-image', 'keywords' => array( 'images', 'NLC' ), 'supports' => array( 'align' => false, 'anchor' => true, ), 'enqueue_style' => get_template_directory_uri() . '/template-parts/blocks/two-images-section/two-images-section.min.css', )); acf_register_block_type(array( 'name' => 'custom-latest-posts', 'title' => __('NLC - Latest Posts'), 'description' => __('A latest post block.'), 'render_template' => 'template-parts/blocks/custom-latest-posts/custom-latest-posts.php', 'category' => 'nlc-custom', 'icon' => 'cover-image', 'keywords' => array( 'posts', 'NLC' ), 'supports' => array( 'align' => false, 'anchor' => true, ), 'enqueue_style' => get_template_directory_uri() . '/template-parts/blocks/custom-latest-posts/custom-latest-posts.min.css', )); acf_register_block_type(array( 'name' => 'custom-content-container', 'title' => __('NLC - Content Container'), 'description' => __('A content container block.'), 'render_template' => 'template-parts/blocks/custom-content-container/custom-content-container.php', 'category' => 'nlc-custom', 'icon' => 'cover-image', 'keywords' => array( 'container', 'NLC' ), 'supports' => array( 'align' => false, 'anchor' => true, 'customClassName' => true, 'jsx' => true, ), 'enqueue_style' => get_template_directory_uri() . '/template-parts/blocks/custom-content-container/custom-content-container.min.css', )); acf_register_block_type(array( 'name' => 'single-quote', 'title' => __('NLC - Single Quote Section'), 'description' => __('A single quote block.'), 'render_template' => 'template-parts/blocks/single-quote/single-quote.php', 'category' => 'nlc-custom', 'icon' => 'cover-image', 'keywords' => array( 'quote', 'NLC' ), 'supports' => array( 'align' => false, 'anchor' => true, ), 'enqueue_style' => get_template_directory_uri() . '/template-parts/blocks/single-quote/single-quote.min.css', )); acf_register_block_type(array( 'name' => 'accordion-section', 'title' => __('NLC - Accordion Section'), 'description' => __('A accordion section'), 'render_template' => 'template-parts/blocks/accordion-section/accordion-section.php', 'category' => 'nlc-custom', 'icon' => 'cover-image', 'keywords' => array( 'quote', 'NLC' ), 'supports' => array( 'align' => false, 'anchor' => true, ), 'enqueue_script' => get_template_directory_uri() . '/template-parts/blocks/accordion-section/accordion-section.js', 'enqueue_style' => get_template_directory_uri() . '/template-parts/blocks/accordion-section/accordion-section.min.css', )); acf_register_block_type(array( 'name' => 'image-animation-block', 'title' => __('NLC - Image Animation Block'), 'description' => __('A image animation block'), 'render_template' => 'template-parts/blocks/image-animation-block/image-animation-block.php', 'category' => 'nlc-custom', 'icon' => 'cover-image', 'keywords' => array( 'animation', 'NLC' ), 'supports' => array( 'align' => false, 'anchor' => true, ), // 'enqueue_script' => get_template_directory_uri() . '/template-parts/blocks/image-animation-block/image-animation-block.js', 'enqueue_style' => get_template_directory_uri() . '/template-parts/blocks/image-animation-block/image-animation-block.min.css', )); acf_register_block_type(array( 'name' => 'two-columns-section', 'title' => __('NLC - Two Column Section'), 'description' => __('A two-column section'), 'render_template' => 'template-parts/blocks/two-columns-section/two-columns-section.php', 'category' => 'nlc-custom', 'icon' => 'cover-image', 'keywords' => array( 'content', 'NLC' ), 'supports' => array( 'align' => false, 'anchor' => true, ), 'enqueue_style' => get_template_directory_uri() . '/template-parts/blocks/two-columns-section/two-columns-section.min.css', )); acf_register_block_type(array( 'name' => 'simple-cta', 'title' => __('NLC - Simple Call-to-action'), 'description' => __('A simple call to action'), 'render_template' => 'template-parts/blocks/simple-cta/simple-cta.php', 'category' => 'nlc-custom', 'icon' => 'cover-image', 'keywords' => array( 'cta', 'action', 'NLC' ), 'supports' => array( 'align' => false, 'anchor' => true, ), 'enqueue_style' => get_template_directory_uri() . '/template-parts/blocks/simple-cta/simple-cta.min.css', )); acf_register_block_type(array( 'name' => 'people-block', 'title' => __('NLC - People Block'), 'description' => __('A people block'), 'render_template' => 'template-parts/blocks/people-block/people-block.php', 'category' => 'nlc-custom', 'icon' => 'cover-image', 'keywords' => array( 'people', 'NLC' ), 'supports' => array( 'align' => false, 'anchor' => true, ), 'enqueue_style' => get_template_directory_uri() . '/template-parts/blocks/people-block/people-block.min.css', )); acf_register_block_type(array( 'name' => 'scrolling-people-block', 'title' => __('NLC - Scrolling People Block'), 'description' => __('A scrolling people block'), 'render_template' => 'template-parts/blocks/scrolling-people-block/scrolling-people-block.php', 'category' => 'nlc-custom', 'icon' => 'cover-image', 'keywords' => array( 'people', 'NLC' ), 'supports' => array( 'align' => false, 'anchor' => true, ), 'enqueue_style' => get_template_directory_uri() . '/template-parts/blocks/scrolling-people-block/scrolling-people-block.min.css', )); acf_register_block_type(array( 'name' => 'fellows-list', 'title' => __('NLC - Fellows List Block'), 'description' => __('A list of felows given chapter.'), 'render_template' => 'template-parts/blocks/fellows-list/fellows-list.php', 'category' => 'nlc-custom', 'icon' => 'cover-image', 'keywords' => array( 'fellows', 'NLC' ), 'supports' => array( 'align' => false, 'anchor' => true, ), 'enqueue_style' => get_template_directory_uri() . '/template-parts/blocks/fellows-list/fellows-list.min.css', )); acf_register_block_type(array( 'name' => 'chapter-header', 'title' => __('NLC - Chapter Header'), 'description' => __('Header for chapter page'), 'render_template' => 'template-parts/blocks/chapter-header/chapter-header.php', 'category' => 'nlc-custom', 'icon' => 'cover-image', 'keywords' => array( 'chapter', 'NLC' ), 'supports' => array( 'align' => false, 'anchor' => true, ), 'enqueue_style' => get_template_directory_uri() . '/template-parts/blocks/chapter-header/chapter-header.min.css', )); acf_register_block_type(array( 'name' => 'chapters-list', 'title' => __('NLC - Chapters List'), 'description' => __('A chapters list block.'), 'render_template' => 'template-parts/blocks/chapters-list/chapters-list.php', 'category' => 'nlc-custom', 'icon' => 'cover-image', 'keywords' => array( 'chapters', 'NLC' ), 'supports' => array( 'align' => false, 'anchor' => true, ), 'enqueue_style' => get_template_directory_uri() . '/template-parts/blocks/chapters-list/chapters-list.min.css', )); acf_register_block_type(array( 'name' => 'blog-header', 'title' => __('NLC - Blog Header'), 'description' => __('A blog header block.'), 'render_template' => 'template-parts/blocks/blog-header/blog-header.php', 'category' => 'nlc-custom', 'icon' => 'cover-image', 'keywords' => array( 'header', 'NLC' ), 'supports' => array( 'align' => false, 'anchor' => true, ), 'enqueue_style' => get_template_directory_uri() . '/template-parts/blocks/blog-header/blog-header.min.css', )); acf_register_block_type(array( 'name' => 'caucuse-list', 'title' => __('NLC - Caucus List'), 'description' => __('A caucuse list block.'), 'render_template' => 'template-parts/blocks/caucuse-list/caucuse-list.php', 'category' => 'nlc-custom', 'icon' => 'cover-image', 'keywords' => array( 'header', 'NLC' ), 'supports' => array( 'align' => false, 'anchor' => true, ), 'enqueue_style' => get_template_directory_uri() . '/template-parts/blocks/caucuse-list/caucuse-list.min.css', )); acf_register_block_type(array( 'name' => 'custom-content-section', 'title' => __('NLC - Custom Content Block'), 'description' => __('A caucuse list block.'), 'render_template' => 'template-parts/blocks/custom-content-section/custom-content-section.php', 'category' => 'nlc-custom', 'icon' => 'cover-image', 'keywords' => array( 'header', 'NLC' ), 'supports' => array( 'align' => false, 'anchor' => true, ), 'enqueue_style' => get_template_directory_uri() . '/template-parts/blocks/custom-content-section/custom-content-section.min.css', )); acf_register_block_type(array( 'name' => 'team-members-list', 'title' => __('NLC - Team Members List'), 'description' => __('A list of team members block.'), 'render_template' => 'template-parts/blocks/team-members-list/team-members-list.php', 'category' => 'nlc-custom', 'icon' => 'cover-image', 'keywords' => array( 'team members', 'NLC' ), 'supports' => array( 'align' => false, 'anchor' => true, ), 'enqueue_style' => get_template_directory_uri() . '/template-parts/blocks/team-members-list/team-members-list.min.css', )); acf_register_block_type(array( 'name' => 'show-more-content', 'title' => __('NLC - Show More Content'), 'description' => __('A show more content block.'), 'render_template' => 'template-parts/blocks/show-more-content/show-more-content.php', 'category' => 'nlc-custom', 'icon' => 'cover-image', 'keywords' => array( 'team members', 'NLC' ), 'supports' => array( 'align' => false, 'anchor' => true, ), 'enqueue_style' => get_template_directory_uri() . '/template-parts/blocks/team-members-list/team-members-list.min.css', )); acf_register_block_type(array( 'name' => 'custom-button', 'title' => __('NLC - Custom Button'), 'description' => __('A content container block.'), 'render_template' => 'template-parts/blocks/custom-button/custom-button.php', 'category' => 'nlc-custom', 'icon' => 'cover-image', 'keywords' => array( 'button', 'NLC' ), 'supports' => array( 'align' => true, 'anchor' => true, 'customClassName' => true, ), 'enqueue_style' => get_template_directory_uri() . '/template-parts/blocks/custom-button/custom-button.min.css', )); } } add_filter( 'gform_submit_button', 'form_submit_button', 10, 2 ); function form_submit_button( $button, $form ) { return "<button type='submit' class='button gform_button' id='gform_submit_button_{$form['id']}'><span>{$form['button']['text']} →</span></button>"; } add_action( 'admin_enqueue_scripts', 'my_admin_style'); function my_admin_style() { wp_enqueue_style('nlc-theme-shared-style', get_template_directory_uri() . '/shared-style.min.css', array(), _S_VERSION); } // add_filter( 'block_editor_settings' , 'remove_guten_wrapper_styles' ); function remove_guten_wrapper_styles( $settings ) { unset($settings['styles'][0]); return $settings; } add_filter( 'block_categories', function( $categories, $post ) { return array_merge( $categories, array( array( 'slug' => 'nlc-custom', 'title' => 'NLC Custom Block', ), ) ); }, 10, 2 ); function fellows_list() { // echo get_the_title(my_acf_post_id()); // echo my_acf_post_id(); $args = array( 'offset' => 0, 'orderby' => 'post_date', 'post_type' => 'fellow', /* your post type name */ 'post_status' => 'publish', 'meta_key' => 'name', 'orderby' => 'meta_value', 'order' => 'ASC', 'posts_per_page' => -1, 'meta_query' => array( array( 'key' => 'chapter_of_individual', 'value' => get_the_title(my_acf_post_id()), 'compare' => 'LIKE' ) ) ); $query = new WP_Query($args); if ($query->have_posts()) : while ($query->have_posts()) : $query->the_post(); $title = get_field('title', get_the_ID()); $name = get_field('name', get_the_ID()); $pronouns = get_field('pronouns', get_the_ID()); $image = get_the_post_thumbnail_url(get_the_ID(), 'full'); ?> <div class="w-full sm:w-1/2 md:w-1/4 p-2"> <div class="bg-black p-3 h-full"> <div class="w-full mb-2 fellow-image" role="img" aria-label="A photo of <?php echo $name; ?>" title="<?php echo $name; ?>" style="background-image:url(<?php echo $image; ?>)"></div> <a class="text-white block header3 no-underline" href="<?php the_permalink(); ?>"><?php echo $name; ?></a> <p class="text-white mt-2 mb-4"><?php echo $pronouns; ?></p> <a class="btn no-underline" href="<?php the_permalink(); ?>">Read More →</a> </div> </div> <?php endwhile; wp_reset_postdata(); endif; } add_shortcode('nlc-fellows-list', 'fellows_list'); function my_acf_post_id() { if ( is_admin() && function_exists( 'acf_maybe_get_POST' ) ) : return intval( acf_maybe_get_POST( 'post_id' ) ); else : global $post; return $post->ID; endif; } function load_posts_by_ajax_callback() { check_ajax_referer('load_more_posts', 'security'); $offset = $_POST['offset']; $maxPages = $_POST['maxPages']; $category = $_POST['category']; $tag = $_POST['tag']; $page = $_POST['page']; $args = array( 'posts_per_page' => 3, 'offset' => $offset, 'orderby' => 'post_date', 'order' => 'DESC', 'post_type' => 'post', 'post_status' => 'publish', 'paged' => $page ); if ($category) { $args = array( 'posts_per_page' => 3, 'offset' => $offset, 'orderby' => 'post_date', 'order' => 'DESC', 'post_type' => 'post', 'post_status' => 'publish', 'meta_key' => 'category', 'meta_value' => $category, 'paged' => $page ); } if ($tag) { $args = array( 'posts_per_page' => 3, 'offset' => $offset, 'orderby' => 'post_date', 'order' => 'DESC', 'post_type' => 'post', 'post_status' => 'publish', 'meta_key' => 'tag', 'meta_value' => $tag, 'paged' => $page ); } wp_die(); } add_action('wp_ajax_load_posts_by_ajax', 'load_posts_by_ajax_callback'); add_action('wp_ajax_nopriv_load_posts_by_ajax', 'load_posts_by_ajax_callback'); function my_excerpt_length($length){ return 25; } add_filter('excerpt_length', 'my_excerpt_length'); function body_class_user_role( $classes ) { if( is_user_logged_in() ) { $user = wp_get_current_user(); $roles = $user->roles; $classes = $classes.' user-role-' . $roles[0]; } return $classes; } add_filter( 'admin_body_class', 'body_class_user_role' ); add_action('rest_api_init', 'custom_api_get_projects'); function custom_api_get_projects(){ register_rest_route( 'projects', '/all-posts', array( 'methods' => 'GET', 'callback' => 'custom_api_get_projects_callback' )); } function custom_api_get_projects_callback($request){ $posts_data = array(); $paged = $request->get_param('page'); $paged = (isset($paged) || !(empty($paged))) ? $paged : 1; $how_many = $request->get_param('how_many'); $how_many = (isset($how_many) || !(empty($how_many))) ? $how_many : 1; $args = array( 'posts_per_page' => $how_many, 'orderby' => 'post_date', 'order' => 'DESC', 'post_type' => 'post', 'post_status' => 'publish', 'paged' => $paged ); if ($category) { $args = array( 'posts_per_page' => $how_many, 'orderby' => 'post_date', 'order' => 'DESC', 'post_type' => 'post', 'post_status' => 'publish', 'meta_key' => 'category', 'meta_value' => $category, 'paged' => $paged ); } if ($tag) { $args = array( 'posts_per_page' => $how_many, 'orderby' => 'post_date', 'order' => 'DESC', 'post_type' => 'post', 'post_status' => 'publish', 'meta_key' => 'tag', 'meta_value' => $tag, 'paged' => $paged ); } $posts = get_posts( $args ); foreach($posts as $post){ $result = get_the_excerpt($post->ID); $featured_img_url = get_template_directory_uri().'/assets/img/nlc-logo-alt.svg'; $hasImage = 'default'; if(get_the_post_thumbnail_url($post->ID, 'full')) { $featured_img_url = get_the_post_thumbnail_url($post->ID, 'full'); $hasImage = ''; $image_id = get_post_thumbnail_id($post->ID); $image_alt = get_post_meta($image_id, '_wp_attachment_image_alt', TRUE); $image_title = get_the_title($image_id); } $tag_string = ''; if ($tag) { $tag_name = get_tag($tag); $tag_string = '&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;&nbsp;&nbsp;&nbsp;'.$tag_name->name; } $posts_data[] = ' <div class="max-w-sm mx-auto sm:my-4 sm:mx-0 w-full sm:w-1/3 px-2 my-4 px-2"> <div class="bg-black h-full p-3"> <div role="img" aria-label="'.$image_alt.'" title="'.$image_title.'" class="post-image w-full mb-2 '.$hasImage.'" style="background-image: url('.$featured_img_url.');"></div> <span class="text-white my-2 meta">'.get_the_date('', $post->ID).htmlspecialchars_decode($tag_string).'</span> <a class="text-white block header3 my-2 no-underline" href="'.get_the_permalink($post->ID).'">'.get_the_title($post->ID).'</a> <p class="text-white m-0">'.$result.'</p> <a class="btn no-underline my-4" href="'.get_the_permalink($post->ID).'">Read More →</a> </div> </div>'; } return $posts_data; }