Sharing_Service::set_blog_services PHP Method

set_blog_services() public method

public set_blog_services ( array $visible, array $hidden )
$visible array
$hidden array
    public function set_blog_services(array $visible, array $hidden)
    {
        $services = $this->get_all_services();
        // Validate the services
        $available = array_keys($services);
        // Only allow services that we have defined
        $hidden = array_intersect($hidden, $available);
        $visible = array_intersect($visible, $available);
        // Ensure we don't have the same ones in hidden and visible
        $hidden = array_diff($hidden, $visible);
        /**
         * Control the state of the list of sharing services.
         *
         * @module sharedaddy
         *
         * @since 1.1.0
         *
         * @param array $args {
         *	Array of options describing the state of the sharing services.
         *
         *	@type array $services List of all available service names and classes.
         *	@type array $available Validated list of all available service names and classes.
         *	@type array $hidden List of services hidden behind a "More" button.
         *	@type array $visible List of visible services.
         *	@type array $this->get_blog_services() Array of Sharing Services currently enabled.
         * }
         */
        do_action('sharing_get_services_state', array('services' => $services, 'available' => $available, 'hidden' => $hidden, 'visible' => $visible, 'currently_enabled' => $this->get_blog_services()));
        return update_option('sharing-services', array('visible' => $visible, 'hidden' => $hidden));
    }

Usage Example

Esempio n. 1
0
 public function ajax_save_services()
 {
     if (isset($_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'sharing-options') && isset($_POST['hidden']) && isset($_POST['visible'])) {
         $sharer = new Sharing_Service();
         $sharer->set_blog_services(explode(',', $_POST['visible']), explode(',', $_POST['hidden']));
         die;
     }
 }
All Usage Examples Of Sharing_Service::set_blog_services