add_submenu_separator( $parent_slug, 5, 'members-eparator'); // 예시: 5번째 위치에 섹션 구분선 삽입 } /** * Ensure the ACF parent menu is selected for add-new.php * * @since 6.1 * @param string $parent_file The parent file checked against menu activation. * @return string The modified parent file */ public function ensure_menu_selection( $parent_file ) { if ( ! is_string( $parent_file ) ) { return $parent_file; } if ( strpos( $parent_file, 'edit.php?post_type=amem-' ) === 0 ) { return 'edit.php?post_type=acf-field-group'; } return $parent_file; } function add_submenu_separator($parent_slug, $position, $menu_title) { global $submenu; // 배열의 특정 위치에 섹션 구분선을 삽입 $new_submenu_item = array('', 'read', '#'.sanitize_title($menu_title), '', 'wp-menu-separator amem-submenu-separator-wrap'); // 해당 위치에 삽입 if(isset($submenu[$parent_slug])){ array_splice($submenu[$parent_slug], $position, 0, array($new_submenu_item)); } } /** * Load the body class and scripts. * * @since 1.0.0 */ public function admin_load() { add_action( 'admin_body_class', array( $this, 'admin_body_class' ) ); add_action( 'admin_print_scripts', array( $this, 'admin_head' ) ); // acf_enqueue_scripts(); } public function update_dashboard() { if( !isset($_POST['dashboard_update_nonce']) || !wp_verify_nonce( sanitize_key($_POST['dashboard_update_nonce']), 'amem_dashboard_update' ) ){ // phpcs:disable WordPress.Security.NonceVerification -- already verified by ACF return false; } if( isset($_POST['amem_modules'])){ // phpcs:disable WordPress.Security.NonceVerification -- already verified by ACF update_option( 'amem_modules', amem_sanitize_vars($_POST['amem_modules']) ); // phpcs:disable WordPress.Security.NonceVerification -- already verified by ACF amem()->options->modules = amem_sanitize_vars($_POST['amem_modules']); // phpcs:disable WordPress.Security.NonceVerification -- already verified by ACF acf_add_admin_notice( __('Dashboard Update Success', 'advanced-members'), 'success' ); } } public function update_option() { if( !isset($_POST['option_update_nonce']) || !wp_verify_nonce( sanitize_key($_POST['option_update_nonce']), 'amem_options_update' ) ) { return false; } if( isset($_POST['amem_options'])){ $rules = array('accform', 'regform'); foreach ($rules as $rule) { if( isset($_POST['amem_options'][$rule]['rules']) ){ $i = 0; foreach ($_POST['amem_options'][$rule]['rules'] as $key => $value) { $_POST['amem_options'][$rule]['rules'][$i] = amem_sanitize_vars($value); unset($_POST['amem_options'][$rule]['rules'][$key]); $i = $i + 1; } } } if( isset($_POST['amem_options']['email'])){ foreach ($_POST['amem_options']['email'] as $key => $mail_option) { if( isset($_POST['amem_options']['email'][$key]['body'])){ $mail_option = amem_sanitize_vars( $mail_option ); $_POST['amem_options']['email'][$key]['body'] = wpautop(stripslashes($mail_option['body'])); } } } update_option('amem_options', amem_sanitize_vars($_POST['amem_options'])); do_action( 'amem/admin/update_options' ); acf_add_admin_notice( __('Options Update Success', 'advanced-members'), 'success' ); } } /** * Modifies the admin body class. * * @since 1.0.0 * * @param string $classes Space-separated list of CSS classes. * @return string */ public function admin_body_class( $classes ) { $classes .= ' amem-admin-page amem-option-page'; return $classes; } /** * postbox_submitdiv * * This function will render the submitdiv metabox * * @type function * @since 1.0.0 * * @param n/a * @return n/a **/ function postbox_submitdiv( $post, $args ) { /** * Fires before the major-publishing-actions div. * * @since 1.0 * * @param array $page The current options page. */ do_action( 'acf/options_page/submitbox_before_major_actions' ); ?>

Need Help? We have a knowledge base full of articles to get you started.

Browse Documentation
page['updated_message'], 'success' ); // } // add submit div add_meta_box( 'submitdiv', __( 'Update Settings', 'advanced-members' ), array( $this, 'postbox_submitdiv' ), 'amem_options_page', 'side', 'high' ); add_meta_box( 'submitdiv', __( 'Save', 'advanced-members' ), array( $this, 'postbox_submit_dashboard' ), 'amem_dashboard_page', 'side', 'high' ); add_meta_box( 'dashdocu', __( 'Documentation', 'advanced-members' ), array( $this, 'postbox_dashboard_document' ), 'amem_dashboard_page', 'side', 'low' ); } function amem_dashboard() { /* $page = ! empty( $_REQUEST['page'] ) ? sanitize_key( $_REQUEST['page'] ) : ''; if ( $page == 'amem_dashboard' ) { ?>

$screen->id ); $default_settings_tabs = apply_filters( 'amem/member_dashboard/dashboard_tabs', array( 'modules' => array( 'label' => __( 'Modules', 'advanced-members' ), 'link' => '#' ), 'settings' => array( 'label' => __( 'Settings', 'advanced-members' ), 'link' => admin_url( 'edit.php?post_type=acf-field-group&page=amem_settings' ) ), 'forms' => array( 'label' => __( 'Forms', 'advanced-members' ), 'link' => admin_url( 'edit.php?post_type=amem-form' ) ), )); // _acf_apply_get_local_field_groups() $settings_data = array( 'page_title' => __( 'Advanced Members for ACF Dashboard' , 'advanced-members' ), 'tabs' => $default_settings_tabs, ); amem_get_view( __DIR__ . '/views/html-dashboard-page.php', $settings_data ); } /** * The render for the options page preview view. * * @since 1.0.0 */ public function render() { $screen = get_current_screen(); $view = array( 'screen_id' => $screen->id ); $option_tabs = array( 'general' => __( 'General', 'advanced-members' ), 'account' => __( 'Account', 'advanced-members' ), ); if ( amem()->options->getmodule('_use_redirects') ) { $option_tabs['redirects'] = __( 'Redirects', 'advanced-members' ); } if ( amem()->options->getmodule('_use_adminbar') ) { $option_tabs['adminbar'] = __( 'Admin Bar', 'advanced-members' ); } $option_tabs['email'] = __( 'Emails', 'advanced-members' ); $default_settings_tabs = apply_filters( 'amem/member_settings/settings_tabs', $option_tabs); // _acf_apply_get_local_field_groups() $settings_data = array( 'page_title' => __( 'Members Settings' , 'advanced-members' ), 'tabs' => $default_settings_tabs, // 'fields' => $fields, ); amem_get_view( __DIR__ . '/views/html-options-page.php', $settings_data ); } function add_option_default_rule() { global $wp_roles; $all_roles = $wp_roles->roles; $roles = array(); foreach ($all_roles as $key => $role) { if( sanitize_key($_POST['ruletab']) == 'regform' && $key == 'administrator') continue; $roles[$key] = translate_user_role($role['name']); } $account_forms = array( 0 => __('Not Selected', 'advanced-members') ); foreach ( get_posts(array( 'post_type' => 'amem-form', 'numberposts' => -1, 'sort_column' => 'post_title', 'sort_order' => 'ASC', 'meta_query' => array( array( 'key' => 'amem_form_select_type', 'value' => 'account', 'compare' => '=', ), ), )) as $form ){ $account_forms[$form->ID] = $form->post_title; }; $rule = array('id'=> 'rule_0', 'role' => '','value' => ''); $ruletab = amem_sanitize_vars($_POST['ruletab']); ob_start(); amem_get_view( __DIR__ . '/views/location-rule.php', array( 'ruletab' => $ruletab, 'roles' => $roles, 'forms' => $account_forms, 'rule' => $rule, ) ); $content = ob_get_clean(); wp_send_json_success( array( 'content' => $content ) ); } function enqueue_admin_scripts() { $min = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; wp_enqueue_style( 'amem-admin', amem_get_url("assets/build/css/admin{$min}.css"), [], AMEM_VERSION ); if ( !amem_is_screen( ['amem-form', 'edit-amem-form', 'acf-field-group', 'acf_page_amem_settings', 'acf_page_amem_dashboard']) ) return; amem()->fields->enqueue_scripts(); wp_register_script( 'amem-admin', amem_get_url("assets/build/js/amem-admin{$min}.js"), ['jquery', 'acf-input', 'amem-input'], AMEM_VERSION, true ); $account_forms = array( 0 => __('Not Selected', 'advanced-members') ); foreach ( get_posts(array( 'post_type' => 'amem-form', 'numberposts' => -1, 'sort_column' => 'post_title', 'sort_order' => 'ASC', 'meta_query' => array( array( 'key' => 'amem_form_select_type', 'value' => 'account', 'compare' => '=', ), ), )) as $form ){ $account_forms[$form->ID] = $form->post_title; }; wp_localize_script( 'amem-admin', 'amem_options', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'account_forms' => $account_forms, ) ); wp_enqueue_script( 'amem-admin' ); } function remove_separator_menu($more_items) { foreach ($more_items as $key => $item) { if( strpos($item['text'], 'submenu-separator') !== false ){ unset($more_items[$key]); } } return $more_items; } function register_core_page_option_button() { foreach( array_keys(amem()->config->core_pages) as $page_key ) { $name = amem()->options->get_core_page_id($page_key); // $name = "amem_options[{$name}]"; add_action( 'acf/render_field/name=' . $name, [$this, 'core_page_option_button'] ); } } function core_page_option_button($field) { if ( $field['prefix'] == 'amem_options' && $field['value'] ) { $page_id = (int) $field['value']; echo edit_post_link( __('Edit Page', 'advanced-members'), '', '', $page_id, 'page-edit-link button' ); // if ( $form_ids = $this->get_content_forms($page_id, $field['key']) ) { // $form_edit_link = edit_post_link( __('Edit Form', 'advanced-members'), '', '', $form_ids[0], 'form-edit-link button' ); // echo $form_edit_link; // } } } protected function get_content_forms($page_id, $type='login') { $type = str_replace( 'core_', '', $type ); switch( $type ) { case 'registration': case 'register': case 'login': $find = 'advanced-members'; break; case 'account': if ( amem()->options->get('accform/default') ) return amem()->options->get('accform/default'); return false; break; default: return false; break; } $page = get_post( $page_id ); if ( !$page ) return false; $content = $page->post_content; $pattern = get_shortcode_regex([$find]); preg_match_all( "/$pattern/", $content, $matches ); $found = []; foreach ( $matches[0] as $k => $tag ) { if ( !empty($matches[3][$k]) ) { $atts = shortcode_parse_atts($matches[3][$k]); if ( isset($atts['form']) ) $found[] = (int) $atts['form']; } } return array_filter( array_unique($found) ); } } amem()->register_module('admin_options', ADMIN_OPTIONS::getInstance()); endif; // class_exists check