cat_name.' ';
}
$attributes = 'title="'.$categories.get_the_title().'" keyword="'.get_the_title().'" category="'.$categories.'"';
//Check Style
if($options['style'] == 'button') {
$button = '';
} else {
$button = '';
}
//Display at top of content
if($options['position_top'] == 1) {
$content = $button."\n".$content;
}
//Display at bottom of content
if($options['position_bottom'] == 1) {
$content .= "\n".$button;
}
}
return $content;
}
function azullo_respond_javascript() {
$options = get_option('azullo_respond');
echo '';
echo '';
}
function azullo_respond_activate() {
//If the plugin hasn't been activated before set some defaults
if(!get_option('azullo_respond')) {
$options = array(
'user_id' => '',
'user_error' => '',
'style' => 'bar',
'position_top' => 1,
'position_bottom' => 1,
'display_home' => 1,
'display_archives' => 1,
'display_categories' => 1,
'display_page' => 1
);
add_option('azullo_respond', $options);
}
}
function azullo_respond_admin() {
add_options_page('Respond', 'Respond', 'manage_options', 'azullo-respond-settings', 'azullo_respond_admin_page');
}
function azullo_respond_admin_init(){
register_setting('azullo_respond_options', 'azullo_respond', 'azullo_respond_options_sanitize');
}
function azullo_respond_options_sanitize($options) {
//Get current options to re-include if nessecery
$current_options = get_option('azullo_respond');
//Set id as these won't be submitted most of the time
$options_new['user_id'] = $current_options['user_id'];
//If id is submitted check it is an interger
if(isset($options['user_submit'])) {
if(!empty($options['user_id'])) {
//Prep id
$options['user_id'] = trim($options['user_id']);
//if the id is an interger it will do!
if(absint($options['user_id'])) {
$options_new['user_id'] = $options['user_id'];
} else {
add_settings_error('azullo_respond', 'azullo_respond', 'The ID should be a number.');
}
} else {
add_settings_error('azullo_respond', 'azullo_respond', 'The ID is required.');
}
}
if(!empty($current_options['user_id'])) {
$options_new['style'] = $options['style'];
} else {
$options_new['style'] = $current_options['style'];//If current email is empty first time submission so maintain defaults
}
//If option submitted or first time submission set to true
if(isset($options['position_top']) || empty($current_options['user_id'])) {
$options_new['position_top'] = 1;
} else {
$options_new['position_top'] = '';
}
//If option submitted or first time submission set to true
if(isset($options['position_bottom']) || empty($current_options['user_id'])) {
$options_new['position_bottom'] = 1;
} else {
$options_new['position_bottom'] = '';
}
//If no position is selected throw error if not first time submission and keep current
if(!isset($options['position_top']) && !isset($options['position_bottom'])) {
if(!empty($current_options['user_id'])) {
add_settings_error('azullo_respond', 'azullo_respond', 'A least one position needs to be selected.');
}
$options_new['position_top'] = $current_options['position_top'];
$options_new['position_bottom'] = $current_options['position_bottom'];
}
//If option submitted or first time submission set to true
if(isset($options['display_home']) || empty($current_options['user_id'])) {
$options_new['display_home'] = 1;
} else {
$options_new['display_home'] = '';
}
//If option submitted or first time submission set to true
if(isset($options['display_archives']) || empty($current_options['user_id'])) {
$options_new['display_archives'] = 1;
} else {
$options_new['display_archives'] = '';
}
//If option submitted or first time submission set to true
if(isset($options['display_categories']) || empty($current_options['user_id'])) {
$options_new['display_categories'] = 1;
} else {
$options_new['display_categories'] = '';
}
//If option submitted or first time submission set to true
if(isset($options['display_page']) || empty($current_options['user_id'])) {
$options_new['display_page'] = 1;
} else {
$options_new['display_page'] = '';
}
return $options_new;
}
function azullo_respond_admin_page() { ?>
Respond (advertising and social sharing with Facebook, Twitter and LinkedIn).
Respond is a simple way to earn extra revenue through relevant 'call to action' buttons, which are contextually matched to your content. Respond also offers an easy way for your visitors to share your content through the most popular social networks.