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 $new_modules = amem_sanitize_vars( $_POST['amem_modules'] ); update_option( 'amem_modules', $new_modules ); // phpcs:disable WordPress.Security.NonceVerification -- already verified by ACF amem()->options->modules = $new_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( !empty($_POST['amem_options']) || !is_array($_POST['amem_options']) ) { $new_options = $this->sanitize_options( $_POST['amem_options'] ); update_option( 'amem_options', $new_options ); do_action( 'amem/admin/update_options' ); acf_add_admin_notice( __('Options Update Success', 'advanced-members'), 'success' ); } } function sanitize_email_body($body) { $wp_default_protocols = wp_allowed_protocols(); $protocols = array_merge( $wp_default_protocols, array( 'data' ) ); return wp_kses( stripslashes( $body ), 'post', $protocols ); } function sanitize_options( $data, $sanitizers = null ) { foreach( $data as $name => $option ) { switch ($name) { case 'accform': case 'regform': if( isset($option['rules']) ){ $i = 0; foreach ($option['rules'] as $key => $value) { $data[$name]['rules'][$i] = amem_sanitize_vars($value); unset($data[$name]['rules'][$key]); $i = $i + 1; } } break; case 'email': foreach ($option as $key => $mail_option) { if( isset($option[$key]['body'])) { $data[$name][$key]['body'] = $this->sanitize_email_body($mail_option['body']); } } break; case 'avatar': $sizes = trim( sanitize_text_field($data[$name]['avatar_sizes']) ); if ( $sizes ) { $sizes = explode(',', $sizes ); $sizes = array_filter( array_map('intval', $sizes), function($v) { return $v >= 80 && $v <= 512; } ); sort($sizes); $sizes = implode(',', $sizes ); } if ( !$sizes ) { $sizes = '96,150,300'; } $data[$name]['avatar_sizes'] = $sizes; break; default: $sanitizers = $sanitizers ? $sanitizers : amem()->options->sanitizers(); if ( isset($sanitizers[$name]) ) { switch ( $sanitizers[$name] ) { case 'int': if ( is_array( $option ) ) { $data[$name] = map_deep( $option, 'intval' ); } else { $data[$name] = (int) $option; } break; case 'absint': if ( is_array( $option ) ) { $data[$name] = map_deep( $option, 'absint' ); } else { $data[$name] = absint( $option ); } break; case 'empty_absint': if ( is_array( $option ) ) { $data[$name] = map_deep( $option, 'absint' ); } else { $data[$name] = ( '' !== $option ) ? absint( $option ) : ''; } break; case 'key': if ( is_array( $option ) ) { $data[$name] = map_deep( $option, 'sanitize_key' ); } else { $data[$name] = sanitize_key( $option ); } break; case 'bool': if ( is_array($option) ) { $data[$name] = map_deep( $option, 'boolval' ); } else { $data[$name] = (bool) $option; } break; case 'url': if ( is_array( $option ) ) { $data[$name] = map_deep( $option, 'esc_url_raw' ); } else { $data[$name] = esc_url_raw( $option ); } break; case 'wp_kses': if ( is_array( $option ) ) { $data[$name] = map_deep( $option, 'wp_kses_post' ); } else { $data[$name] = wp_kses_post( $option ); } break; case 'textarea': if ( is_array( $option ) ) { $data[$name] = map_deep( $option, 'sanitize_textarea_field' ); } else { $data[$name] = sanitize_textarea_field( $option ); } break; case 'text': if ( is_array( $option ) ) { $data[$name] = map_deep( $option, 'sanitize_text_field' ); } else { $data[$name] = sanitize_text_field( $option ); } break; case 'array_text': if ( $option ) $data[$name] = map_deep( $option, 'sanitize_text_field' ); else $data[$name] = []; break; case 'email_body': if ( is_array( $option ) ) { $data[$name] = map_deep( $option, [$this, 'sanitize_email_body'] ); } else { $data[$name] = $this->sanitize_email_body( $option ); } break; case is_array($sanitizers[$name]): $data[$name] = $this->sanitize_options( $option, $sanitizers[$name] ); // foreach( $sanitizers[$name] as $skey => $sname ) { // if ( isset($sanitizers[$skey]) && !is_array($sanitizers[$skey]) ) { // $data[$name] // } // } break; default: $data[$name] = apply_filters( 'amem/option/sanitize/method=' . $sanitizers[$name] , $option ); break; } } else { $data[$name] = apply_filters( 'amem/option/sanitize/name=' . $name, $option ); } break; } } return $data; } /** * 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 acf-admin-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' => '#' ), )); // _acf_apply_get_local_field_groups() $settings_data = array( 'page_title' => __( 'Advanced Members 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' ); } if ( amem()->is_dev() && amem()->options->getmodule('_use_avatar') ) { $option_tabs['avatar'] = __( 'Avatar', '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' => '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("admin{$min}.css", 'assets/css'), ['acf-global', 'acf-input'], AMEM_VERSION ); $amem_screens = apply_filters( 'amem/admin/screens', ['acf_page_amem_settings', 'acf_page_amem_dashboard'] ); $amem_edit_screens = apply_filters( 'amem/admin/edit_screens', ['amem-form', 'edit-amem-form'] ); $check_screens = array_merge( amem()->admin->screens(), amem()->admin->edit_screens(), ['acf-field-group'] ); if ( !amem_is_screen( $check_screens ) ) return; amem()->fields->enqueue_scripts(); amem_register_script( 'amem-admin', amem_get_url("amem-admin{$min}.js", 'assets/js'), ['jquery', 'acf-input', 'amem-input'], AMEM_VERSION, ['in_footer' => true, 'asset_path' => amem_get_path('', 'assets/js')] ); $account_forms = array( 0 => __('Not Selected', 'advanced-members') ); foreach ( get_posts(array( 'post_type' => 'amem-form', 'numberposts' => 999, 'sort_column' => 'post_title', 'sort_order' => 'ASC', 'meta_query' => array( array( 'key' => '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