관리-도구
편집 파일: core.php
<?php defined( 'ABSPATH' ) || die( "Can't access directly" ); // adminize ////////////////////////////////////////////////////// if ( ! function_exists('adminize') ): function adminize() { require_once( ABSPATH . 'wp-includes/pluggable.php' ); if ( current_user_can( 'manage_options' ) ): return true; else: return false; endif; } endif;// end // admin debug ////////////////////////////////////////////////////// if ( ! function_exists('debug') ): function debug($data, $color = false) { if ( ! defined( 'DISABLE_DEBUG' ) ) define( 'DISABLE_DEBUG', false ); if ( ! defined( 'DEBUG_FORCE' ) ) define( 'DEBUG_FORCE', false ); if ( DISABLE_DEBUG || !adminize() ) { return; } // Work only this username: ArcadeDemo //$current_user = wp_get_current_user(); //if ($current_user->user_login != 'ArcadeDemo') return; // require_once( ABSPATH . 'wp-includes/pluggable.php' ); if ( adminize() || DEBUG_FORCE ): if ( $color ) { $tag = ($color == "h1") ? "h1" : "div" ; echo "<$tag style='color:$color;background:white;'>"; print_r($data); echo "</$tag>"; return true; } if (is_string($data)): echo "<pre style='background:white;'>".$data."</pre>"; elseif (is_object($data)): var_dump($data); else: print_r($data); endif; //echo "<hr>"; else: return false; endif; }endif;// end /* ----- UPDATE OPTION */ function arcade_site_option ($option=false,$value=false) { if ( $option ) { if (get_option( $option ) !== false) { if ($value) { update_option( $option, $value ); } else { return get_option( $option ); } } else { add_option( $option, $value, null, 'no' ); } } return $value; } /** * */ function arcade_is_premium() { return false; } /** * Menu Custon Fields */ add_action('wp_nav_menu_item_custom_fields', function($item_id, $item) { $am = get_post_meta($item_id, 'am', true); $am1 = $am2 = $am3 = $am4 = $am5 = false; switch ($am) { case 'categories': $am2 = true; break; case 'favorite': $am3 = true; break; case 'history': $am4 = true; break; case 'search': $am5 = true; break; default: $am1 = true; break; } ?> <p class="arcade-am description description-wide"> <label for="arcade-am--<?php echo $item_id; ?>">Choose a action:</label> <select name="arcade-am-[<?php echo $item_id; ?>]" id="arcade-am-[<?php echo $item_id; ?>]"> <option <?php selected($am1);?> value="none">No Action</option> <option <?php selected($am2);?> value="categories">Categories</option> <option <?php selected($am3);?> value="favorite">Favorites</option> <option <?php selected($am4);?> value="history">History</option> <option <?php selected($am5);?> value="search">Search</option> </select> </p> <?php }, 10, 2); add_action('wp_update_nav_menu_item', function($menu_id, $menu_item_db_id) { $val = (isset($_POST['arcade-am-'][$menu_item_db_id]) && !empty($_POST['arcade-am-'][$menu_item_db_id])) ? $_POST['arcade-am-'][$menu_item_db_id] : false; update_post_meta($menu_item_db_id, 'am', $val); }, 10, 2); add_filter('nav_menu_css_class', function($classes, $menu_item) { $am = get_post_meta($menu_item->ID, 'am', true); if ($am) { $classes[] = $am; } return $classes; }, 10, 2); /** * How to add Class in <li> using wp_nav_menu() in Wordpress? */ function arcade_add_additional_class_on_li($classes, $item, $args) { if(isset($args->add_li_class)) { $classes[] = $args->add_li_class; } return $classes; } add_filter('nav_menu_css_class', 'arcade_add_additional_class_on_li', 1, 3); /** * Remove Unused Attr's from menu items */ function arcade_remove_css_id_filter($var) { return is_array($var) ? array_intersect($var, array('current-menu-item')) : ''; } //add_filter( 'page_css_class', 'arcade_remove_css_id_filter', 100, 1); add_filter( 'nav_menu_item_id', 'arcade_remove_css_id_filter', 100, 1); //add_filter( 'nav_menu_css_class', 'arcade_remove_css_id_filter', 100, 1); /** * Shortcode : all_categories */ function all_categories_f( $atts ){ $tags = get_tags( ['orderby' => 'count', 'order' => 'DESC'] ); if (!$tags) return; $li = array(); foreach ($tags as $tag) { $li [] = sprintf('<li><a href="%s">%s</a></li>', get_term_link($tag->term_id), esc_attr($tag->name)); if ( count($li) >= 250 ) break; } return sprintf('<ul id="tc" class="w gtc">%s</ul>', implode('', $li)); } add_shortcode( 'all_categories', 'all_categories_f' ); /** * Is Json */ if ( !function_exists("isJson") ) { function isJson($string) { json_decode($string); return json_last_error() === JSON_ERROR_NONE; } }