Socialize API
Available Actions/Filters
Actions
socialize_settings_tabs - Called after admin tabs are generated
Filters
socialize_settings_tabs_array - Add new tabs to the Socialize settings page
Example:
function new_tab($tabs) {
$tabs['my-new-tab'] = array(
'title' => 'My New tab',
'function' => 'my_new_tab_callback'
);
return $tabs;
}
socialize-sort_buttons_array – Modify services array before sorting
socialize-footerjs – Modify services javascript array before passing to wp_print_scripts()
socialize-short_url – Modify short_url returned by get_short_url()
socialize-get_bitly_short_url – Modify bitly url returned by get_bitly_short_url()
socialize-get_services – Modify services array used throughout Socialize
socialize-get_button_array – Modify services array returned by get_button_array()
socialize-{service_name} – Modify output of specific service
Adding New Buttons
add_filter('socialize-get_services', 'my_socialize_button');
function my_socialize_button($socialize_array){
$new_button = array(
'My Button' => array(
'inline' => 100,
'action' => 101,
'callback' => 'createMyButton'
)
);
$socialize_array = array_merge($socialize_array, $new_button);
return $socialize_array;
}
function createMyButton(){
return 'This is my custom button code';
}
Note: The inline and action numbers are arbitrary however cannot clash with built in number. It’s safest to use number greater than 100.
Modifying Existing Buttons
The following code replaces the default Socialize buttons with their asynchronous alternatives
// Add custom javascript
add_action('wp', 'socialize_custom');
function socialize_custom(){
add_action('wp_footer', 'socialize_custom_js');
}
// Add asynchronous loading code
function socialize_custom_js() {
?>
}
// Replace Twitter button
add_filter('socialize-twitter', 'filter_socialize_twitter');
function filter_socialize_twitter($content) {
$socialize_settings = array();
$socialize_settings = get_option('socialize_settings10');
$buttonContent = '
