Added settings for priority on the_excerpt and the_content
-
Hello,
I just wanted to mention that I added some code to allow myself to set the priority on the hooks WPSocialite uses for the_content and the_excerpt. I’m helping tweak a site for some friends, and needed the buttons to appear below some other plugin’s functionality that also gets added to those hooks.
Code I added for using the_content option:
if( get_option( 'wpsocialite_content_priority' ) ){ add_filter( 'the_content', array( $this, 'wpsocialite_filter_content' ), get_option( 'wpsocialite_content_priority' ) ); } else { add_filter( 'the_content', array( $this, 'wpsocialite_filter_content' ) ); }
Code I added for using the_excerpt option:
if( get_option( 'wpsocialite_excerpt' ) == 1 ){ if( get_option( 'wpsocialite_excerpt_priority' ) ){ add_filter( 'the_excerpt', array( $this, 'wpsocialite_filter_content' ), get_option( 'wpsocialite_excerpt_priority' ) ); } else { add_filter( 'the_excerpt', array( $this, 'wpsocialite_filter_content' ) ); } }
Code I added for creating the options in the admin:
add_settings_field( $id = 'wpsocialite_excerpt_priority', $title = __('Excerpt Priority','wpsocialite'), $callback = array( $this, 'wpsocialite_text_input' ), $page = 'discussion', $section = 'wpsocialite', $args = array( 'name' => 'wpsocialite_excerpt_priority', 'description' => 'Assign priority to <code>the_excerpt</code> filter for WPSocialite. Default (10) is used if blank.', 'options' => array( 'excerpt_priority' => _(''), ), ) ); register_setting( $option_group = 'discussion', $option_name = 'wpsocialite_excerpt_priority' ); add_settings_field( $id = 'wpsocialite_content_priority', $title = __('Content Priority','wpsocialite'), $callback = array( $this, 'wpsocialite_text_input' ), $page = 'discussion', $section = 'wpsocialite', $args = array( 'name' => 'wpsocialite_content_priority', 'description' => 'Assign priority to <code>the_content</code> filter for WPSocialite. Default (10) is used if blank.', 'options' => array( 'content_priority' => _(''), ), ) ); register_setting( $option_group = 'discussion', $option_name = 'wpsocialite_content_priority' );
Hope this formats well in the comment box here. I’d love to see this get a review to see if it works for everyone, and potentially added to the plugin. Let me know if I can do anything else!
Thanks,
Jonathan Stegall
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Added settings for priority on the_excerpt and the_content’ is closed to new replies.