首页 » 网站推广 » absintphp技巧_Nana主题若何添加WordPress 3D扭转彩色标签云

absintphp技巧_Nana主题若何添加WordPress 3D扭转彩色标签云

访客 2024-11-19 0

扫一扫用手机浏览

文章目录 [+]

PS:由于Nana主题集成的彩色云会跟这个3D旋转彩色标签云有所冲突,会导致这个3D旋转彩色标签云色彩非常丢脸,以是必须二选一,想要3D旋转彩色标签云就必须删除这个主题默认的彩色标签云。

Nana主题添加WordPress 3D旋转彩色标签云方法:

absintphp技巧_Nana主题若何添加WordPress 3D扭转彩色标签云

方法一:文件更换法,适宜Nana主题文件未修正过

absintphp技巧_Nana主题若何添加WordPress 3D扭转彩色标签云
(图片来自网络侵删)

1、下载Nana主题添加WordPress 3D旋转彩色标签云所需文件压缩包,并解压得到4个文件,分别是functions.php、style.css、widgets.php和3dtag.js文件。

文件下载

2、分别将解压所得的functions.php和style.css文件更换Nana主题文件中的functions.php和style.css文件;widgets.php文件更换Nana\inc\functions\目录下的widgets.php文件;3dtag.js文件拷贝到Nana\js\目录下。

至此,Nana主题已经成功添加了WordPress 3D旋转彩色标签云到小工具中。
我们想要利用这个3D旋转彩色标签云时,只须要登录后台 > 外不雅观 > 小工具,找到“主题 3D标签云”,然后添加到相应侧边栏即可(可以同时添加到首页和文章页侧边栏)。

方法二:自行折腾法,适宜Nana主题文件已被修正过

1、Nana主题中的functions.php文件,找到以下彩色标签云代码并删除,大概在471至483行。

// 彩色标签云

function colorCloud($text) {

$text = preg_replace_callback('|<a (.+?)>|i', 'colorCloudCallback', $text);

return $text;

}

function colorCloudCallback($matches) {

$text = $matches[1];

$color = dechex(rand(0,16777215));

$pattern = '/style=(\'|\\"大众)(.)(\'|\\"大众)/i';

$text = preg_replace($pattern, \公众style=\\"大众color:#{$color};$2;\\"大众\"大众, $text);

return \"大众<a $text>\公众;

}

add_filter('wp_tag_cloud', 'colorCloud', 1);

2、下载3dtag.js文件到Nana主题JS文件目录下(Nana\js\)。

3、打开Nana\inc\functions\widgets.php文件,在第一个<?php下方添加以下代码:

// 3D标签云

class cx_tag_cloud extends WP_Widget {

function cx_tag_cloud() {

$widget_ops = array('description' => '可实现3D殊效');

$this->WP_Widget('cx_tag_cloud', '主题&nbsp;&nbsp;3D标签云', $widget_ops);

}

function widget($args, $instance) {

extract($args);

$title = apply_filters( 'widget_title', $instance['title'] );

echo $before_widget;

if ( ! emptyempty( $title ) )

echo $before_title . $title . $after_title;

$number = strip_tags($instance['number']) ? absint( $instance['number'] ) : 20;

?>

<div id=\公众tag_cloud_widget\"大众>

<?php wp_tag_cloud( array ( 'smallest' => '14', 'largest' => 14, 'unit' => 'px', 'order' => 'RAND', 'number' => $number ) ); ?>

<div class=\公众clear\"大众></div>

<?php wp_enqueue_script( '3dtag.min', get_template_directory_uri() . '/js/3dtag.js', array(), '', false ); ?>

</div>

<?php

echo $after_widget;

}

function update( $new_instance, $old_instance ) {

if (!isset($new_instance['submit'])) {

return false;

}

$instance = $old_instance;

$instance = array();

$instance['title'] = strip_tags( $new_instance['title'] );

$instance['number'] = strip_tags($new_instance['number']);

return $instance;

}

function form($instance) {

if ( isset( $instance[ 'title' ] ) ) {

$title = $instance[ 'title' ];

}

else {

$title = '3D标签云';

}

global $wpdb;

$instance = wp_parse_args((array) $instance, array('number' => '20'));

$number = strip_tags($instance['number']);

?>

<p><label for=\公众<?php echo $this->get_field_id( 'title' ); ?>\"大众>标题:</label>

<input class=\"大众widefat\"大众 id=\"大众<?php echo $this->get_field_id( 'title' ); ?>\"大众 name=\公众<?php echo $this->get_field_name( 'title' ); ?>\"大众 type=\公众text\"大众 value=\"大众<?php echo $title; ?>\"大众 /></p>

<p><label for=\公众<?php echo $this->get_field_id('number'); ?>\公众>显示数量:</label>

<input id=\"大众<?php echo $this->get_field_id( 'number' ); ?>\"大众 name=\公众<?php echo $this->get_field_name( 'number' ); ?>\公众 type=\"大众text\公众 value=\"大众<?php echo $number; ?>\"大众 size=\"大众3\公众 /></p>

<input type=\"大众hidden\"大众 id=\公众<?php echo $this->get_field_id('submit'); ?>\"大众 name=\"大众<?php echo $this->get_field_name('submit'); ?>\"大众 value=\"大众1\公众 />

<?php }

}

add_action( 'widgets_init', create_function( '', 'register_widget( \"大众cx_tag_cloud\"大众 );' ) );

4、打开Nana主题的style.css文件,在末了面添加以下代码:

/ 3D标签 /

#tag_cloud_widget{position:relative;width:240px;height:240px;margin:10px auto 10px}

#tag_cloud_widget a{position:absolute;color:#fff;text-align:center;text-overflow:ellipsis;whitewhite-space:nowrap;top:0;left:0;padding:3px 5px;box-shadow:0 1px 1px rgba(0,0,0,0.08)}

#tag_cloud_widget a:hover{background:#d02f53;display:block}

#tag_cloud_widget a:nth-child(n){background:#666;border-radius:3px;display:inline-block;line-height:18px;margin:0 10px 15px 0}

#tag_cloud_widget a:nth-child(2n){background:#d1a601}

#tag_cloud_widget a:nth-child(3n){background:#286c4a}

#tag_cloud_widget a:nth-child(5n){background:#518ab2}

#tag_cloud_widget a:nth-child(4n){background:#c91d13}

#tag_cloud_widget a{line-height:15px;background:#999}

至此,Nana主题已经成功添加了WordPress 3D旋转彩色标签云到小工具中。
我们想要利用这个3D旋转彩色标签云时,只须要登录后台 > 外不雅观 > 小工具,找到“主题 3D标签云”,然后添加到相应侧边栏即可(可以同时添加到首页和文章页侧边栏)。

主要声明:本文所涉及到的代码均来源于网络上分享的知更鸟begin主题破解版,原则上版权属于知更鸟大神,希望大家喝水之余不要忘了挖井人哦。

原文地址:http://yigujin.wang/958.html

相关文章