php add_to_functions.php

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php add_to_functions.php相关的知识,希望对你有一定的参考价值。

/* Add these lines to /sage/respirces/functions.php */

/* Generate custom menu array */
function b_get_menu_id( $location )
{
  $a = get_nav_menu_locations();
  if (isset($a[$location])) return $a[$location];
  return false;
}
function b_get_menu_items( $location )
{
  $navItems = [];
  foreach (wp_get_nav_menu_items( b_get_menu_id($location) ) as $obj) {
    $item = new stdClass();
    $item->url = $obj->url;
    $item->label = $obj->title;
    $item->icon = $obj->classes[0];
    $item->id = $obj->object_id;
    array_push($navItems, $item);
  }
  return $navItems;
}
/* Dropdown menu */
function b_get_nav_items($location) {
  $id = b_get_menu_id($location);
  $nav = [];
  $children = [];
  if(!$id) {
    return $nav;
  }
  foreach(wp_get_nav_menu_items($id) as $object) {
    $item = new stdClass();
    $item->url = $object->url;
    $item->target = $object->target;
    $item->label = $object->title;
    $item->id = $object->object_id;
    $item->icon = $object->classes[0];
    $item->parent = intval($object->menu_item_parent);
    $item->children = [];
    if($item->parent){
      $children[] = $item;
    } else {
      $nav[$object->ID] = $item;
    }
  }
  foreach($children as $item) {
    $nav[$item->parent]->children[] = $item;
  }
  return $nav;
}

/**
 * Register new version of jquery with CDN
 */
function replace_core_jquery_version() {
  wp_deregister_script( 'jquery' );
  wp_register_script( 'jquery', "https://code.jquery.com/jquery-3.1.1.min.js", array(), '3.1.1' );
}
add_action( 'wp_enqueue_scripts', 'replace_core_jquery_version' );

/*
 * Remove P and </br> for Contact Form 7
 */
add_filter( 'wpcf7_autop_or_not', '__return_false' );

// Disable guttenberg for entire wordpress website
add_filter('use_block_editor_for_post', '__return_false', 10);
add_filter('use_block_editor_for_post_type', '__return_false', 10);

/**
 * Add page options with ACF
 */
if( function_exists('acf_add_options_page') ) {
  
  acf_add_options_page([
    'page_title' 	=> 'Données du site',
    'menu_title'	=> 'Données du site',
    'menu_slug' 	=> 'theme-option-settings',
    'capability'	=> 'edit_posts',
    'redirect'		=> false
  ]);
}

以上是关于php add_to_functions.php的主要内容,如果未能解决你的问题,请参考以下文章

php [guzzle php] guzzle php #php

php send.php php邮件模板#php

IntelliJ IDEA 11编辑php是,支持php文件名为.php5和.php4,如何设置能让其也支持.php呢?

如何从php5升级到php7

请问php中如何调用php文件中的内容?

php [php:PHPMailer示例] php库“PHPMailer”示例。 #PHP