我创建了一个插件,在我的WordPress站点中添加了一些短代码。但我是一个PHP新手,所以我相信它可能有一些错误或优化它的方法。
它工作正常,显然没有问题。内存使用率为00.04MB。你能看看吗?非常感谢!
add_action( \'wp_enqueue_scripts\', \'prefix_add_my_stylesheet\' );
function prefix_add_my_stylesheet() {
// Respects SSL, Style.css is relative to the current file
wp_register_style( \'prefix-style\', plugins_url(\'style.css\', __FILE__) );
wp_enqueue_style( \'prefix-style\' );
}
/* Adsesnse Shortcode */
function get_adsense($atts) {
return \'THE_ADSENSE_SCRIPT_GOES_HERE
\';
}
add_shortcode(\'adsense\', \'get_adsense\');
/*Padding Shortcodes*/
function get_pad5($atts) {
return \'<div class="pad5"></div>\';
}
add_shortcode(\'pad5\', \'get_pad5\');
function get_pad10($atts) {
return \'<div class="pad10"></div>\';
}
add_shortcode(\'pad10\', \'get_pad10\');
function get_pad20($atts) {
return \'<div class="pad20"></div>\';
}
add_shortcode(\'pad20\', \'get_pad20\');
function get_pad25($atts) {
return \'<div class="pad25"></div>\';
}
add_shortcode(\'pad25\', \'get_pad25\');
function get_pad50($atts) {
return \'<div class="pad50"></div>\';
}
add_shortcode(\'pad50\', \'get_pad50\');
function get_pad75($atts) {
return \'<div class="pad75"></div>\';
}
add_shortcode(\'pad75\', \'get_pad75\');
function get_pad100($atts) {
return \'<div class="pad100"></div>\';
}
add_shortcode(\'pad100\', \'get_pad100\');
function get_clr($atts, $content=null) {
return \'<div class="clr">\' . $content . \'</div>\';
}
add_shortcode( \'clr\', \'get_clr\' );
/* Alert Boxes */
function get_alertblue($atts, $content=null) {
return \'<div class="ultra_alert_box ultra_box-blue">\' . $content . \'</div>\';
}
add_shortcode( \'alertblue\', \'get_alertblue\' );
function get_alertgreen($atts, $content=null) {
return \'<div class="ultra_alert_box ultra_box-green">\' . $content . \'</div>\';
}
add_shortcode( \'alertgreen\', \'get_alertgreen\' );
function get_alertyellow($atts, $content=null) {
return \'<div class="ultra_alert_box ultra_box-yellow">\' . $content . \'</div>\';
}
add_shortcode( \'alertyellow\', \'get_alertyellow\' );
function get_alertred($atts, $content=null) {
return \'<div class="ultra_alert_box ultra_box-red">\' . $content . \'</div>\';
}
add_shortcode( \'alertred\', \'get_alertred\' );
function get_alertgray($atts, $content=null) {
return \'<div class="ultra_alert_box ultra_box-gray">\' . $content . \'</div>\';
}
add_shortcode( \'alertgray\', \'get_alertgray\' );
/* Style Boxes */
function get_stylegreen($atts, $content=null) {
return \'<div class="ultra_style_box ultra_style-green">\' . $content . \'</div>\';
}
add_shortcode( \'stylegreen\', \'get_stylegreen\' );
function get_styleblue($atts, $content=null) {
return \'<div class="ultra_style_box ultra_style-blue">\' . $content . \'</div>\';
}
add_shortcode( \'styleblue\', \'get_styleblue\' );
function get_styleyellow($atts, $content=null) {
return \'<div class="ultra_style_box ultra_style-yellow">\' . $content . \'</div>\';
}
add_shortcode( \'styleyellow\', \'get_styleyellow\' );
function get_stylered($atts, $content=null) {
return \'<div class="ultra_style_box ultra_style-red">\' . $content . \'</div>\';
}
add_shortcode( \'stylered\', \'get_stylered\' );
function get_stylegray($atts, $content=null) {
return \'<div class="ultra_style_box ultra_style-gray">\' . $content . \'</div>\';
}
add_shortcode( \'stylegray\', \'get_stylegray\' );
function get_stylewhite($atts, $content=null) {
return \'<div class="ultra_style_box ultra_style-white">\' . $content . \'</div>\';
}
add_shortcode( \'stylewhite\', \'get_stylewhite\' );