php 额外的functions.php
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 额外的functions.php相关的知识,希望对你有一定的参考价值。
<?php
/* ---------------------------------------------
Force Login
--------------------------------------------- */
function aceify_force_login() {
global $post;
if ( ( is_single() || is_front_page() || is_page() ) && !is_page('login') && !is_user_logged_in()){
auth_redirect();
}
}
//add_action( 'wp_head', 'aceify_force_login' ); //uncomment to force users to login
/* ---------------------------------------------
shorter stylesheet directory function & get template directory function
--------------------------------------------- */
function gsdu() {
return get_stylesheet_directory_uri();
}
function gtdu() {
return get_template_directory_uri();
}
/* ---------------------------------------------
Enqueue Styles
--------------------------------------------- */
add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
function theme_enqueue_styles() {
wp_enqueue_style( 'parent-style', gsdu() . '/style.css', '', '2.1.0' );
}
/* ---------------------------------------------
Enqueue Scripts.
--------------------------------------------- */
function theme_scripts_enqueue() {
wp_enqueue_script('jquery');
wp_enqueue_script('fontawesome', '//use.fontawesome.com/29ee4ba4af.js', array(), '1', true);
wp_enqueue_script('slick', gtdu(). '/js/vendor/slick.min.js', 'jquery', '1', true);
wp_enqueue_script('jquery-validate', gtdu(). '/js/vendor/jquery.validate.min.js', 'jquery', '1.16.0', true);
wp_enqueue_script('jquery-validate-additional', gtdu(). '/js/vendor/additional-methods.min.js', 'jquery', '1.16.0', true);
wp_enqueue_script('jquery-form', gtdu(). '/js/vendor/jquery.form.min.js', 'jquery', '3.51.0', true);
$conde_newsletterID = get_field('conde_newsletter_id', 'option');
$conde_siteCode = get_field('conde_site_code', 'option');
$conde_staging_endpoint = get_field('conde_staging_endpoint', 'option');
$conde_production_endpoint = get_field('conde_production_endpoint', 'option');
$conde_staging_key = get_field('conde_staging_key', 'option');
$conde_production_key = get_field('conde_production_key', 'option');
if(get_site_env() == 'production'){
$conde_key = $conde_production_key;
$conde_endpoint = $conde_production_endpoint;
}else{
$conde_key =$conde_staging_key;
$conde_endpoint =$conde_staging_endpoint;
}
$options_array = array(
'baseURL' => home_url(),
'conde_newsletter_id' => $conde_newsletterID,
'conde_site_code' => $conde_siteCode,
'conde_key' => $conde_key,
'conde_endpoint' => $conde_endpoint
);
if(get_site_env() == 'staging' || get_site_env() == 'dev'){
if(!is_page_template('templates/template-homepage.php')){
wp_enqueue_script('waypoint', gtdu(). '/js/vendor/jquery.waypoints.min.js', array('jquery'), '1', true);
wp_enqueue_script('greensock', '//cdnjs.cloudflare.com/ajax/libs/gsap/1.19.1/TweenMax.min.js', array('jquery'), '1', true);
wp_register_script('theme-scripts', gtdu().'/js/site-scripts/event-scripts.js', array('jquery', 'jquery-validate', 'jquery-validate-additional'), '1.0.6', true);
wp_localize_script('theme-scripts', 'options', $options_array);
wp_enqueue_script('theme-scripts');
}else{
wp_enqueue_script('greensock', '//cdnjs.cloudflare.com/ajax/libs/gsap/1.19.1/TweenMax.min.js', array('jquery'), '1', true);
wp_enqueue_script('scroll-magic', '//cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.5/ScrollMagic.min.js', 'jquery', '2.0.5', true);
wp_enqueue_script('scroll-magic-gsap', '//cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.5/plugins/animation.gsap.min.js', 'jquery', '2.0.5', true);
wp_enqueue_script('scroll-magic-debug', '//cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.5/plugins/debug.addIndicators.min.js', 'jquery', '2.0.5', true);
wp_register_script('theme-scripts', gtdu().'/js/site-scripts/site-scripts.js', array('jquery', 'jquery-validate', 'jquery-validate-additional'), '1.1.4', true);
wp_localize_script('theme-scripts', 'options', $options_array);
wp_enqueue_script('theme-scripts');
}
}
else {
if(!is_page_template('templates/template-homepage.php')){
wp_enqueue_script('waypoint', gtdu(). '/js/vendor/jquery.waypoints.min.js', array('jquery'), '1', true);
wp_enqueue_script('greensock', '//cdnjs.cloudflare.com/ajax/libs/gsap/1.19.1/TweenMax.min.js', array('jquery'), '1', true);
wp_register_script('theme-scripts-min', gtdu().'/js/event-script-min.js', array('jquery', 'jquery-validate', 'jquery-validate-additional'), '1.1.0', true);
wp_localize_script('theme-scripts-min', 'options', $options_array);
wp_enqueue_script('theme-scripts-min');
}else{
wp_enqueue_script('greensock', '//cdnjs.cloudflare.com/ajax/libs/gsap/1.19.1/TweenMax.min.js', array('jquery'), '1', true);
wp_enqueue_script('scroll-magic', '//cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.5/ScrollMagic.min.js', 'jquery', '2.0.5', true);
wp_enqueue_script('scroll-magic-gsap', '//cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.5/plugins/animation.gsap.min.js', 'jquery', '2.0.5', true);
wp_enqueue_script('scroll-magic-debug', '//cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.5/plugins/debug.addIndicators.min.js', 'jquery', '2.0.5', true);
wp_register_script('theme-scripts-min', gtdu().'/js/script-min.js', array('jquery', 'jquery-validate', 'jquery-validate-additional'), '1.1.2', true);
wp_localize_script('theme-scripts-min', 'options', $options_array);
wp_enqueue_script('theme-scripts-min');
}
}
}
add_action( 'wp_enqueue_scripts', 'theme_scripts_enqueue' );
/* ---------------------------------------------
Google Analytics
--------------------------------------------- */
if(!empty($ga_account)){
function google_analytics(){
global $ga_account;
?>
<!-- Begin GA Tag -->
<script type="text/javascript">
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', '<?php echo $ga_account; ?>', 'auto'); // Replace with your property ID.
ga('send', 'pageview');
</script>
<!-- End GA Tag -->
<?php }
add_action( 'wp_head', 'google_analytics' );
}
/* ---------------------------------------------
Admin favicon
--------------------------------------------- */
function favicon(){
echo '<link rel="shortcut icon" href="'. gsdu() .'/img/favicon.png?v=1" />',"\n";
}
add_action('admin_head','favicon');
add_action('login_head','favicon');
/* ---------------------------------------------
Hide comment interfaces in admin
--------------------------------------------- */
function hide_admin_comments(){
echo '<style>#wp-admin-bar-comments {display: none !important;}#latest-comments.activity-block {display: none !important;}</style>',"\n";
}
add_action('admin_head','hide_admin_comments');
function hide_page_comments(){
echo '<script>jQuery("th.column-comments, td.column-comments").html("");</script>',"\n";
}
add_action('admin_footer','hide_page_comments');
/* ---------------------------------------------
Featured Image size note
--------------------------------------------- */
function featured_image_instructions(){
$output = '';
$output .= '<script type="text/javascript">';
//$output .= 'jQuery("#postimagediv .inside").append("<p>(1600x620 for Content Landing Pages. 640x320 for press releases and posts.)</p>");';
$output .= 'jQuery("#postimagediv .inside").append("<p>600x600(px) for speakers.<br>1600x900(px) for regular pages.</p>");';
$output .= '</script>';
echo $output;
}
add_action('admin_footer','featured_image_instructions');
/* ---------------------------------------------
Reformat default "read more" tag associated with the_excerpt()
--------------------------------------------- */
function replace_excerpt($content) {
return str_replace('[…]',' ',$content);
}
add_filter('the_excerpt', 'replace_excerpt');
/* ---------------------------------------------
Change length of excerpt returned with the_excerpt()
--------------------------------------------- */
function custom_excerpt_length( $length ) {
$length = 10;
return $length;
}
add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );
//excerpt length character limit
function get_the_trimmed_excerpt(){
$excerpt = get_the_content();
$excerpt = preg_replace(" (\[.*?\])",'',$excerpt);
$excerpt = strip_shortcodes($excerpt);
$excerpt = strip_tags($excerpt);
$excerpt = sanitize_text_field($excerpt);
if(strlen($excerpt)>=80){
$excerpt = substr($excerpt, 0, 80);
$excerpt = substr($excerpt, 0, strripos($excerpt, ' '));
$excerpt = trim(preg_replace( '/\s+/', ' ', $excerpt));
$excerpt = $excerpt.'… ';
}
return $excerpt;
}
/* ---------------------------------------------
Return truncated Title
--------------------------------------------- */
//excerpt length character limit
function get_the_trimmed_title(){
$title = get_the_title();
$title = clean_string($title);
if(strlen($title)<=40){
return $title;
} else {
$title = substr($title, 0, 40);
$title = substr($title, 0, strripos($title, ' '));
$title = trim(preg_replace( '/\s+/', ' ', $title));
$title = $title.'… ';
return $title;
}
}
function get_the_trimmed_sentence($sent){
$sentence = $sent;
$sentence = clean_string($sentence);
if(strlen($sentence)<=200){
return $sentence;
} else {
$sentence = substr($sentence, 0, 200);
$sentence = substr($sentence, 0, strripos($sentence, ' '));
$sentence = trim(preg_replace( '/\s+/', ' ', $sentence));
$sentence = $sentence.'… ';
return $sentence;
}
}
function clean_string($string){
// Strip HTML Tags
$string = strip_tags($string);
// Clean up things like &
$string = html_entity_decode($string, ENT_QUOTES, 'UTF-8');
// Strip out any url-encoded stuff
$string = urldecode($string);
// Replace non-AlNum characters with space
//$string = preg_replace('/[^A-Za-z0-9]/', ' ', $string);
// Replace Multiple spaces with single space
$string = preg_replace('/ +/', ' ', $string);
// Trim the string of leading/trailing space
$string = trim($string);
return $string;
}
/* ---------------------------------------------
Page Slug Body Class
--------------------------------------------- */
function add_slug_body_class( $classes ) {
global $post;
if ( isset( $post ) ) {
$classes[] = $post->post_type . '-' . $post->post_name;
}
return $classes;
}
add_filter( 'body_class', 'add_slug_body_class' );
/*
AJAX for Conde Newsletter Submit
*/
add_action( 'wp_ajax_submitCondeNewsletter', 'submitCondeNewsletter' );
add_action( 'wp_ajax_nopriv_submitCondeNewsletter', 'submitCondeNewsletter' );
function submitCondeNewsletter() {
if(isset($_POST['firstName'])){
$firstName = sanitize_text_field($_POST['firstName']);
}else{
wp_send_json(array('status'=>'false', 'message'=>'First name is required.'));
die();
}
if(isset($_POST['lastName'])){
$lastName = sanitize_text_field($_POST['lastName']);
}else{
wp_send_json(array('status'=>'false', 'message'=>'Last name is required.'));
die();
}
if(isset($_POST['email'])){
$email = sanitize_text_field($_POST['email']);
}else{
wp_send_json(array('status'=>'false', 'message'=>'Email is required.'));
die();
}
if(isset($_POST['birthday'])){
$birthday = sanitize_text_field($_POST['birthday']);
}else{
wp_send_json(array('status'=>'false', 'message'=>'Birthday is required.'));
die();
}
$conde_newsletterID = get_field('conde_newsletter_id', 'option');
$conde_siteCode = get_field('conde_site_code', 'option');
$conde_staging_endpoint = get_field('conde_staging_endpoint', 'option');
$conde_production_endpoint = get_field('conde_production_endpoint', 'option');
$conde_staging_key = get_field('conde_staging_key', 'option');
$conde_production_key = get_field('conde_production_key', 'option');
$conde_staging_secret = get_field('conde_staging_secret', 'option');
$conde_production_secret = get_field('conde_production_secret', 'option');
if(get_site_env() == 'production'){
$conde_key = $conde_production_key;
$conde_endpoint = $conde_production_endpoint;
$conde_secret = $conde_production_secret;
}else{
$conde_key =$conde_staging_key;
$conde_endpoint =$conde_staging_endpoint;
$conde_secret = $conde_staging_secret;
}
$dataPayload = new stdClass();
$dataPayload->newsletterSubscriptionsRequest = new stdClass();
$dataPayload->newsletterSubscriptionsRequest->{'longForm'} = 'true';
$dataPayload->newsletterSubscriptionsRequest->userEntry = new stdClass();
$dataPayload->newsletterSubscriptionsRequest->userEntry->{'@firstName'} = $firstName;
$dataPayload->newsletterSubscriptionsRequest->userEntry->{'@lastName'} = $lastName;
$dataPayload->newsletterSubscriptionsRequest->userEntry->{'@email'} = $email;
$dataPayload->newsletterSubscriptionsRequest->userEntry->{'@mobileNumber'} = '';
$dataPayload->newsletterSubscriptionsRequest->userEntry->{'@birthday'} = $birthday;
$dataPayload->newsletterSubscriptionsRequest->userEntry->{'@zipCode'} = '';
$dataPayload->newsletterSubscriptionsRequest->userEntry->{'@stateCode'} = '';
$dataPayload->newsletterSubscriptionsRequest->userEntry->{'@countryCode'} = '';
$dataPayload->newsletterSubscriptionsRequest->userEntry->{'@city'} = '';
$dataPayload->newsletterSubscriptionsRequest->userEntry->{'@address1'} = '';
$dataPayload->newsletterSubscriptionsRequest->userEntry->{'@address2'} = '';
$dataPayload->newsletterSubscriptionsRequest->userEntry->{'@partnerCode'} = '';
$dataPayload->newsletterSubscriptionsRequest->userEntry->entryContext = new stdClass();
$dataPayload->newsletterSubscriptionsRequest->userEntry->entryContext->{'@formName'} = 'teen_vogue_summit';
$dataPayload->newsletterSubscriptionsRequest->userEntry->entryContext->{'@siteCode'} = $conde_siteCode;
$dataPayload->newsletterSubscriptionsRequest->userEntry->customFieldValues = new stdClass();
$dataPayload->newsletterSubscriptionsRequest->newsletterSubscriptions = new stdClass();
$dataPayload->newsletterSubscriptionsRequest->newsletterSubscriptions->{'newsletterSubscription'} = array();
$newsletterFields = new stdClass();
$newsletterFields->{'@newsletterId'} = $conde_newsletterID;
$newsletterFields->{'@subscribe'} = "true";
$dataPayload->newsletterSubscriptionsRequest->newsletterSubscriptions->newsletterSubscription[] = $newsletterFields;
$jsonData = json_encode($dataPayload);
$headers = array(
"key:" . $conde_key,
"accept: application/json;ver=1.0",
"Content-Type: application/json;ver=1.0",
"Content-Length: ".strlen($jsonData)
);
// $oauth_consumer_key = $conde_key; // staging
// $oauth_secret = $conde_secret;
// $oauth_time = time();
// $oauth_nonce = md5(mt_rand()); // where I can get nonce?
// $oauth_base_string = 'test'; // ?
// $oauth_signature = base64_encode(hash_hmac('sha1', $oauth_base_string, $oauth_secret, true));
// $oauth = "Oauth realm='', oauth_signature_method='HMAC-SHA1', oauth_consumer_key='".$oauth_consumer_key."', oauth_version='1.0', oauth_timestamp='".$oauth_time."', oauth_nonce='".$oauth_nonce."'";
// $headers = array(
// "key:" . $conde_key,
// "accept: application/json;ver=1.0",
// "Content-Type: application/json;ver=1.0",
// "Content-Length: ".strlen($jsonData),
// "Authorization: ". $oauth
// );
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $conde_endpoint);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData);
$result = curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
$result = json_decode($result);
if($httpcode==200 || $httpcode==201) {
wp_send_json(array('status'=>'true', 'message'=>$result));
} else {
wp_send_json(array('status'=>'false', 'message'=>$result));
}
// die();
}
/* ---------------------------------------------
Gravity Form
--------------------------------------------- */
//Editor Access
function add_gforms_editor_access()
{
$role = get_role( 'editor' );
$role->add_cap( 'gform_full_access' );
}
add_action( 'admin_init', 'add_gforms_editor_access' );
function getSignature($m, $r){
$baseURL = home_url();
$api_key = get_field('gravity_public_key', 'option');
$private_key = get_field('gravity_private_key', 'option');
$method = $m; //"GET";
$route = $r; //"forms/1/entries";
$expires = strtotime("+60 mins");
$string_to_sign = sprintf("%s:%s:%s:%s", $api_key, $method, $route, $expires);
$sig = calculate_signature($string_to_sign, $private_key);
$signed_url = $baseURL.'/gravityformsapi/'.$route.'?api_key='.$api_key.'&signature='.$sig.'&expires='.$expires;
return $signed_url;
}
function calculate_signature($string, $private_key) {
$hash = hash_hmac("sha1", $string, $private_key, true);
$sig = rawurlencode(base64_encode($hash));
return $sig;
}
//
add_action( 'wp_ajax_addInterest', 'addInterest' );
add_action( 'wp_ajax_nopriv_addInterest', 'addInterest' );
function addInterest(){
$e = sanitize_text_field($_GET['entry']);
// $entry_decode = json_decode($e, true);
$values = explode(",", $e);
$interests = array("1.1"=>"Activism",
"1.2"=>"Social Justice",
"1.3"=>"Environment",
"1.4"=>"Fashion",
"1.5"=>"Beauty",
"1.6"=>"Retail",
"1.7"=>"Tech",
"1.8"=>"Innovation",
"1.9"=>"Science",
"1.11"=>"Entertainment",
"1.12"=>"Career/Work",
"1.13"=>"Art",
"1.14"=>"Politics"
);
$route = 'entries';
$formID = get_field('gravity_form_id', 'option');
$url = getSignature('POST', $route);
// $entries = array(
// array(
// 'form_id' => $formID,
// '1.1' => 'Activism'
// )
// );
// $entries = array();
// $entries[] = $entry_decode;
$entry = array('form_id'=>$formID);
foreach ($values as $value) {
$entry[$value] = $interests[$value];
}
$entries = array();
$entries[] = $entry;
$entry_json = json_encode( $entries );
$response = wp_remote_request( $url, array( 'method' => 'POST', 'body' => $entry_json ) );
if(wp_remote_retrieve_response_code($response)!= 200 || ( empty(wp_remote_retrieve_body($response))) ){
// http request fail
wp_send_json(array('status'=>'error', 'message'=>'There was an error attempting to access the API.'));
}
// result is in the response "body" and is json encoded.
$body = json_decode(wp_remote_retrieve_body($response), true);
if($body['status'] > 202){
$error = $body['response'];
if ( is_array( $error )){
$error_code = $error['code'];
$error_message = $error['message'];
$error_data = isset( $error['data'] ) ? $error['data'] : '';
$status = "Code: {$error_code}. Message: {$error_message}. Data: {$error_data}.";
}else{
$status = $error;
}
wp_mail( 'heayeon@sabornagency.com',
'teenvogue_summit',
$status.'<br>'.$e );
wp_send_json(array('status'=>'error', 'message'=>$status));
}
$entry_ids = $body['response'];
$entry_ids_created = 'The following entry ids were created: ';
foreach ( $entry_ids as $entry_id ){
$entry_ids_created .= $entry_id . ', ';
}
wp_send_json(array('status'=>'success', 'message'=>''));
}
/* ------------------------------------------------------
IF USING THE ACIFY PLUGIN, REMOVE THE FOLLOWING FUNCTIONS
------------------------------------------------------ */
//remove admin areas
function remove_menus(){
// remove_menu_page( 'index.php' ); //Hide Dashboard
remove_menu_page( 'edit.php' ); //Hide Posts
remove_menu_page( 'link-manager.php' ); //Hide Link Manager
// remove_menu_page( 'upload.php' ); //Hide Media
// remove_menu_page( 'edit.php?post_type=page' ); //Hide Pages
remove_menu_page( 'edit-comments.php' ); //Hide Comments
// remove_menu_page( 'themes.php' ); //Hide Appearance
// remove_menu_page( 'plugins.php' ); //Hide Plugins
// remove_menu_page( 'users.php' ); //Hide Users
remove_menu_page( 'tools.php' ); //Hide Tools
// remove_menu_page( 'options-general.php' ); //Hide Settings
global $submenu;
unset($submenu['themes.php'][6]); // Customize
}
add_action( 'admin_menu', 'remove_menus' );
//remove unwanted wordpress <head> tags
remove_action('wp_head', 'wlwmanifest_link');
remove_action('wp_head', 'wp_shortlink_wp_head');
remove_action('wp_head', 'wp_generator');
remove_action('wp_head','feed_links_extra', 3);
remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);
add_filter('xmlrpc_enabled', '__return_false');
remove_action('wp_head', 'rsd_link'); //Edit URI Link (xmlrpc)
remove_action( 'wp_head', 'rest_output_link_wp_head', 10 );
remove_action( 'wp_head', 'wp_oembed_add_discovery_links', 10 );
//remove widget css ouput from header
add_action( 'widgets_init', 'my_remove_recent_comments_style' );
function my_remove_recent_comments_style() {
global $wp_widget_factory;
remove_action( 'wp_head', array( $wp_widget_factory->widgets['WP_Widget_Recent_Comments'], 'recent_comments_style' ) );
}
//remove emoji support
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
remove_action( 'wp_print_styles', 'print_emoji_styles' );
remove_action( 'admin_print_styles', 'print_emoji_styles' );
//disable admin bar on front end
//add_filter('show_admin_bar', '__return_false');
//custom login page styles
function aceify_login_style() { ?>
<style type="text/css">
body.login {
background: #ffffff;
}
body.login div#login {
padding-top: 2%;
}
body.login div#login h1 a {
display: none;
}
body.login div#login h1{
background: url("<?php echo gsdu(); ?>/img/wired-logo_03.png") center no-repeat;
background-size: 60% auto;
background-position: center;
width: 100%;
height: 150px;
}
.login form {
}
</style>
<?php
}
add_action( 'login_enqueue_scripts', 'aceify_login_style' );
//remove admin menu toolbars
function aceify_remove_toolbar_items( $bar ){
$bar->remove_node( 'new-media' ); // +New
//$bar->remove_node( 'wp-logo' ); // wp Logo
$bar->remove_node( 'new-content' );
$bar->remove_node( 'about' );
$bar->remove_node( 'wporg' );
$bar->remove_node( 'wp-logo-external' );
}
add_action( 'admin_bar_menu', 'aceify_remove_toolbar_items', PHP_INT_MAX -1 );
//change admin logo (top left)
function aceify_add_admin_logo_node( $wp_admin_bar ){
//print_r($wp_admin_bar);
$node_args = array(
'id' => 'wp-logo',
'title' => '<img src="'.gsdu().'/img/icon-white.png" alt="" style="width: 25px; height: auto; margin-top: 5px;" />',
'href' => ''
);
$wp_admin_bar->add_node( $node_args );
}
add_action( 'admin_bar_menu', 'aceify_add_admin_logo_node', 9999 );
//hide admin footer
function aceify_remove_footer_admin () {
echo '';
}
add_filter('admin_footer_text', 'aceify_remove_footer_admin');
//deactivate dashboard widgets
function aceify_remove_dashboard_widgets() {
global $wp_meta_boxes;
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']);
//unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_activity']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_welcome']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_drafts']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments']);
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']);
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']);
remove_action( 'welcome_panel', 'wp_welcome_panel' );
}
add_action('wp_dashboard_setup', 'aceify_remove_dashboard_widgets' );
?>
以上是关于php 额外的functions.php的主要内容,如果未能解决你的问题,请参考以下文章