You are here

easy_social.api.php in Easy Social 7.2

Same filename and directory in other branches
  1. 8.4 easy_social.api.php
  2. 8.3 easy_social.api.php

Easy Social API documentation.

The following is an overview of using the Easy Social API.

For a better reading experience, try the handbook on Drupal.org: http://drupal.org/node/1347326

File

easy_social.api.php
View source
<?php

/**
 * @file
 * Easy Social API documentation.
 *
 * The following is an overview of using the Easy Social API.
 *
 * For a better reading experience, try the handbook on Drupal.org:
 * http://drupal.org/node/1347326
 */

/**
 * Implements hook_easy_social_widget().
 *
 * This is how you define additional share widgets.
 */
function hook_easy_social_widget() {
  return array(
    'my_custom_share_button' => array(
      'name' => 'My Custom Share Button',
      // This appears on admin pages only.
      'markup' => '_mymodule_custom_share_button_markup',
      // Callback function that returns widget markup.
      'scripts' => array(
        array(
          'path' => 'http://mycustomshare.com/widget.js',
          // JavaScript include, if any.
          'type' => 'external',
        ),
      ),
      'styles' => array(
        array(
          'path' => drupal_get_path('module', 'easy_social') . '/css/easy_social_twitter.css',
          // CSS include, if any.
          'type' => 'external',
        ),
      ),
    ),
  );
}

/**
 * Widget markup callback.
 * This is where you return your widget's markup.
 *
 * @param string
 *   The URL to share.
 * @param int
 *   The widget type (horizontal or vertical). This maps to one of the defined
 *   constants: EASY_SOCIAL_WIDGET_HORIZONTAL or EASY_SOCIAL_WIDGET_VERTICAL.
 * @param string
 *   The title to share.
 * @param string
 *   The widget's language code. Not all widgets implement i18n so this can
 *   be ignored and fallback to a default language.
 * @return string
 *   A rendered html string.
 *
 * @see hook_easy_social_widget()
 */
function _mymodule_custom_share_button_markup($url, $type, $title = NULL, $lang = 'en') {
  return <<<HTML
This is my widget' markup, I can replace parameters with variables such as {<span class="php-variable">$url</span>} and {<span class="php-variable">$title</span>}.
HTML;
}

Functions

Namesort descending Description
hook_easy_social_widget Implements hook_easy_social_widget().
_mymodule_custom_share_button_markup Widget markup callback. This is where you return your widget's markup.