[3woords_block question-code="QUE1" question-title="Put you question title here" language="en" width="300" show-credit-link=0] question-code is mandatory. width is in pixel. show-credit-link is option whether you want to show credit link or not.
Version: 1.0.0
Author: Sverker
*/
class Twoords
{
/**
* Holds the values to be used in the fields callbacks
*/
private $options;
/**
* Start up
*/
public function __construct()
{
add_action( 'admin_menu', array( $this, 'twoods_add_plugin_page' ) );
add_action( 'admin_init', array( $this, 'twoods_page_init' ) );
}
/**
* Add options page
*/
public function twoods_add_plugin_page()
{
// This page will be under "Settings"
add_options_page(
'Settings Admin',
'3woords',
'manage_options',
'3woords-setting-admin',
array( $this, 'twoods_create_admin_page' )
);
}
/**
* Options page callback
*/
public function twoods_create_admin_page()
{
// Set class property
$this->options = get_option( 'woords_option_name' );
?>
3woords - Settings
Enter your credentials from 3woords : (for more 3woords )";
}
/**
* Get the settings option array and print one of its values
*/
public function twoords_access_token_callback()
{
printf(
'',
isset( $this->options['access_token'] ) ? esc_attr( $this->options['access_token']) : ''
);
}
/**
* Get the settings option array and print one of its values
*/
public function twoords_access_key_callback()
{
printf(
'',
isset( $this->options['access_key'] ) ? esc_attr( $this->options['access_key']) : ''
);
}
}
if( is_admin() )
$my_settings_page = new Twoords();
// shortcode function
function twoords_woordsPlot_func( $atts ) {
$lang = $atts['language'] ? $atts['language'] : 'en';
$width = $atts['width'] ? $atts['width'].'px' : 'auto';
$qcode = $atts['question-code'] ? $atts['question-code'] : null;
// credit link will not show as per plugin guidelines
$showCreditLink = $atts['show-credit-link'] ? $atts['show-credit-link'] : 0;
$option = get_option('woords_option_name',true);
// get credentials for api from settings
$accessToken = $option['access_token'];
$accessKey = $option['access_key'];
// random string on single page for make unique
$rand_s = rand(100000,999999);
// background color of cloud and color map
$twoods_background = $atts['background'] ? $atts['background'] : '255,255,255';
$twoods_colormap = $atts['colormap'] ? $atts['colormap'] : '';
if (!$accessToken || !$accessKey) {
echo 'Please set credentials before using 3woords API.';
return;
}
if (is_null($qcode)) {
echo '"question-code" option is required.';
return;
}
?>