Sharing_Service::set_service PHP Method

set_service() public method

public set_service ( $id, Sharing_Source $service )
$service Sharing_Source
    public function set_service($id, Sharing_Source $service)
    {
        // Update the options for this service
        $options = get_option('sharing-options');
        // No options yet
        if (!is_array($options)) {
            $options = array();
        }
        /**
         * Get the state of a sharing button.
         *
         * @module sharedaddy
         *
         * @since 1.1.0
         *
         * @param array $args {
         *	State of a sharing button.
         *
         *	@type string $id Service ID.
         *	@type array $options Array of all sharing options.
         *	@type array $service Details about a service.
         * }
         */
        do_action('sharing_get_button_state', array('id' => $id, 'options' => $options, 'service' => $service));
        $options[$id] = $service->get_options();
        update_option('sharing-options', array_filter($options));
    }

Usage Example

Esempio n. 1
0
 public function ajax_save_options()
 {
     if (isset($_POST['_wpnonce']) && isset($_POST['service']) && wp_verify_nonce($_POST['_wpnonce'], 'sharing-options_' . $_POST['service'])) {
         $sharer = new Sharing_Service();
         $service = $sharer->get_service($_POST['service']);
         if ($service && $service instanceof Sharing_Advanced_Source) {
             $service->update_options($_POST);
             $sharer->set_service($_POST['service'], $service);
         }
         $this->output_service($service->get_id(), $service, true);
         echo '<!--->';
         $service->button_style = 'icon-text';
         $this->output_preview($service);
         die;
     }
 }
All Usage Examples Of Sharing_Service::set_service