php 使用Genesis钩子显示基于SW设置的Social Warfare图标。
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 使用Genesis钩子显示基于SW设置的Social Warfare图标。相关的知识,希望对你有一定的参考价值。
<?php
/**
* Use Genesis hooks to display Social Warfare icons based on SW settings.
*
* @version 1.1.0
*
* @author Mike Hemberger @JiveDig
*
* @return void
*/
add_action( 'genesis_before', 'prefix_social_warfare_genesis_hooks' );
function prefix_social_warfare_genesis_hooks() {
// Bail if not a single post, archive, blog, or front page.
if ( ! ( is_singular() || is_archive() || is_home() || is_front_page() ) ) {
return;
}
// Bail if Social Warfare is not active.
if ( ! function_exists( 'social_warfare' ) ) {
return;
}
// Remove default display of SW icons.
remove_filter( 'the_content','social_warfare_wrapper', 10 );
remove_filter( 'the_excerpt','social_warfare_wrapper' );
// Get global SW options.
global $swp_user_options;
// Build the single post type key in SW options.
$singular_key = sprintf( 'location_%s', get_post_type() );
// If a valid singular location in SW options.
if ( is_singular() && isset( $swp_user_options[ $singular_key ] ) ) {
// Check the display location settings and set the hook locations.
$before = in_array( $swp_user_options[ $singular_key ], array( 'above', 'both' ) );
$after = in_array( $swp_user_options[ $singular_key ], array( 'below', 'both' ) );
$before_hook = 'genesis_before_entry_content';
$after_hook = 'genesis_after_entry_content';
}
// Or if archive/blog/front page.
elseif ( is_archive() || is_home() ) {
// Check the display location settings and set the hook locations.
$before = in_array( $swp_user_options[ 'locationSite' ], array( 'above', 'both' ) );
$after = in_array( $swp_user_options[ 'locationSite' ], array( 'below', 'both' ) );
$before_hook = 'genesis_before_loop';
$after_hook = 'genesis_after_loop';
}
// If front page.
elseif ( is_front_page() ) {
// Check the display location settings and set the hook locations.
$before = in_array( $swp_user_options[ 'locationHome' ], array( 'above', 'both' ) );
$after = in_array( $swp_user_options[ 'locationHome' ], array( 'below', 'both' ) );
$before_hook = 'genesis_before_loop';
$after_hook = 'genesis_after_loop';
}
// If showing icons before content.
if ( $before ) {
// Display the SW icons.
add_action( $before_hook, function() {
social_warfare();
});
}
// If showing icons before content.
if ( $after ) {
// Display the SW icons.
add_action( $after_hook, function() {
social_warfare();
});
}
}
以上是关于php 使用Genesis钩子显示基于SW设置的Social Warfare图标。的主要内容,如果未能解决你的问题,请参考以下文章
PHP 基于 SW-X 框架,搭建高性能API架构
PHP 基于 SW-X 框架,搭建高性能API架构
PHP 基于 SW-X 框架,搭建高性能API架构
PHP 基于 SW-X 框架,搭建RPC微服务支持
php 调整FacetWP的寻呼机html以匹配Genesis标记。这允许它继承Genesis主题样式。与[facetwp pager =“true”]一起使用
php 使用Genesis Framework自定义网站页脚。