• Jonathan Stegall

    (@jonathanstegall)


    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

    http://wordpress.org/extend/plugins/wpsocialite/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Tom Morton

    (@tm3909)

    Jonathan,

    Appreciate your contributions! We host the WPSocialite codebase on Github as well in case you want to submit a pull request: https://github.com/tmort/wpsocialite

    I’ll review your changes and see if it fits well within the user options. I always try to keep user options to a minimum, and when adjusting filter priority I feel that may be more of a developer level adjustment than a day to day user. I may create a definition you can set via wp-config or in your theme, but I’d be interested in your thoughts. Any particular reason you would rather see it in the admin?

    Again, thanks for your feedback!

    -Tom

    Thread Starter Jonathan Stegall

    (@jonathanstegall)

    Hey Tom,

    That’s great – I went ahead and submitted a pull request, and why I was thinking it fit in the admin. But I’m certainly not stuck on that.

    I look forward to hearing your thoughts!

    Thanks,
    Jonathan

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.