Settings';
array_unshift($links, $settings_link);
return $links;
}
}
add_filter("plugin_action_links_".plugin_basename(__FILE__), 'aklamator_plugin_settings_link' );
/*
* Add rate and review link in plugin section
*/
if( !function_exists("aklamator_plugin_meta_links")) {
function aklamator_plugin_meta_links($links, $file)
{
$plugin = plugin_basename(__FILE__);
// create link
if ($file == $plugin) {
return array_merge(
$links,
array('Please rate and review')
);
}
return $links;
}
}
add_filter( 'plugin_row_meta', 'aklamator_plugin_meta_links', 10, 2);
/*
* Adds featured images from posts to your site's RSS feed output,
*/
if(!function_exists('akla_featured_images_in_rss')) {
function akla_featured_images_in_rss($content){
global $post;
if (has_post_thumbnail($post->ID)) {
$featured_images_in_rss_size = 'thumbnail';
$featured_images_in_rss_css_code = 'display: block; margin-bottom: 5px; clear:both;';
$content = get_the_post_thumbnail($post->ID, $featured_images_in_rss_size, array('style' => $featured_images_in_rss_css_code)) . $content;
}
return $content;
}
}
if(get_option('aklamatorFeatured2Feed')){
add_filter('the_excerpt_rss', 'akla_featured_images_in_rss', 1000, 1);
add_filter('the_content_feed', 'akla_featured_images_in_rss', 1000, 1);
}
/*
* Activation Hook
*/
register_activation_hook( __FILE__, 'set_up_options' );
function set_up_options(){
add_option('aklamatorApplicationID', '');
add_option('aklamatorPoweredBy', '');
add_option('aklamatorSingleWidgetID', '');
add_option('aklamatorPageWidgetID', '');
add_option('aklamatorSingleWidgetTitle', '');
add_option('aklamatorFeatured2Feed', 'on');
}
/*
* Uninstall Hook
*/
register_uninstall_hook(__FILE__, 'aklamator_uninstall');
function aklamator_uninstall()
{
delete_option('aklamatorApplicationID');
delete_option('aklamatorPoweredBy');
delete_option('aklamatorSingleWidgetID');
delete_option('aklamatorPageWidgetID');
delete_option('aklamatorSingleWidgetTitle');
delete_option('aklamatorFeatured2Feed');
}
if( !function_exists("bottom_of_every_post")){
function bottom_of_every_post($content){
/* we want to change `the_content` of posts, not pages
and the text file must exist for this to work */
if (is_single()){
$widget_id = get_option('aklamatorSingleWidgetID');
}elseif (is_page()) {
$widget_id = get_option('aklamatorPageWidgetID');
}else{
/* if `the_content` belongs to a page or our file is missing
the result of this filter is no change to `the_content` */
return $content;
}
$title = "";
if(get_option('aklamatorSingleWidgetTitle') !== ''){
$title .= "
". get_option('aklamatorSingleWidgetTitle'). "
";
}
/* append the text file contents to the end of `the_content` */
return $content . $title ."
" . "
";
}
}
class AklamatorWidget
{
public $aklamator_url;
public $api_data;
public function __construct()
{
$this->aklamator_url = "https://aklamator.com/";
if (is_admin()) {
add_action("admin_menu", array(
&$this,
"adminMenu"
));
add_action('admin_init', array(
&$this,
"setOptions"
));
if (get_option('aklamatorApplicationID') !== '') {
$this->api_data = $this->addNewWebsiteApi();
}
}
if (get_option('aklamatorSingleWidgetID') !== 'none') {
if (get_option('aklamatorSingleWidgetID') == '') {
if ($this->api_data->data[0]) {
update_option('aklamatorSingleWidgetID', $this->api_data->data[0]->uniq_name);
}
}
add_filter('the_content', 'bottom_of_every_post');
}
if (get_option('aklamatorPageWidgetID') !== 'none') {
if (get_option('aklamatorPageWidgetID') == '') {
if ($this->api_data->data[0]) {
update_option('aklamatorPageWidgetID', $this->api_data->data[0]->uniq_name);
}
}
add_filter('the_content', 'bottom_of_every_post');
}
if(get_option('aklamatorFeatured2Feed')){
update_option('aklamatorFeatured2Feed', 'on');
}
}
function setOptions()
{
register_setting('aklamator-options', 'aklamatorApplicationID');
register_setting('aklamator-options', 'aklamatorPoweredBy');
register_setting('aklamator-options', 'aklamatorSingleWidgetID');
register_setting('aklamator-options', 'aklamatorPageWidgetID');
register_setting('aklamator-options', 'aklamatorSingleWidgetTitle');
register_setting('aklamator-options', 'aklamatorFeatured2Feed');
}
public function adminMenu()
{
add_menu_page('Aklamator Digital PR', 'Aklamator PR', 'manage_options', 'aklamator-digital-pr', array(
$this,
'createAdminPage'
), content_url() . '/plugins/aklamator-digital-pr/images/aklamator-icon.png');
}
public function getSignupUrl()
{
return $this->aklamator_url . 'registration/publisher?utm_source=wordpress&utm_medium=admin&e=' . urlencode(get_option('admin_email')) . '&pub=' . preg_replace('/^www\./','',$_SERVER['SERVER_NAME']).
'&un=' . urlencode(wp_get_current_user()->display_name).'&domain='.site_url();
}
private function addNewWebsiteApi()
{
if (!is_callable('curl_init')) {
return;
}
$service = $this->aklamator_url . "wp-authenticate/user";
$p['ip'] = $_SERVER['REMOTE_ADDR'];
$p['domain'] = site_url();
$p['source'] = "wordpress";
$p['AklamatorApplicationID'] = get_option('aklamatorApplicationID');
$client = curl_init();
curl_setopt($client, CURLOPT_AUTOREFERER, TRUE);
curl_setopt($client, CURLOPT_HEADER, 0);
curl_setopt($client, CURLOPT_RETURNTRANSFER, true);
curl_setopt($client, CURLOPT_URL, $service);
if (!empty($p)) {
curl_setopt($client, CURLOPT_POST, count($p));
curl_setopt($client, CURLOPT_POSTFIELDS, http_build_query($p));
}
$data = curl_exec($client);
if (curl_error($client)!= "") {
$this->curlfailovao=1;
} else {
$this->curlfailovao=0;
}
curl_close($client);
$data = json_decode($data);
return $data;
}
public function createAdminPage()
{
$code = get_option('aklamatorApplicationID');
?>
curlfailovao && get_option('aklamatorApplicationID') != ''): ?>
Error communicating with Aklamator server, please refresh plugin page or try again later.
api_data->flag): ?>
'',
'title' => '',
'content' => '',
);
public $aklamator_url = 'https://aklamator.com/';
public $widget_data;
public function __construct() {
// widget actual processes
parent::__construct(
'wp_widget_aklamator', // Base ID
'Aklamator Digital PR', // Name
array( 'description' => __( 'Display Aklamator Widgets in Sidebar')) // Widget Description
);
}
function widget( $args, $instance ) {
extract($args);
//var_dump($instance); die();
$supertitle_html = '';
if ( ! empty( $instance['supertitle'] ) ) {
$supertitle_html = sprintf( __( '%s', 'envirra' ), $instance['supertitle'] );
}
$title_html = '';
if ( ! empty( $instance['title'] ) ) {
$title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base);
$title_html = $supertitle_html.$title;
}
echo $before_widget;
if ( $instance['title'] ) echo $before_title . $title_html . $after_title;
?>
show_widget(do_shortcode( $instance['widget_id'] )); ?>
aklamator_url = $widget->aklamator_url;
$this->widget_data = $widget->api_data;
$instance = wp_parse_args( (array) $instance, $this->default );
$supertitle = strip_tags( $instance['supertitle'] );
$title = strip_tags( $instance['title'] );
$content = $instance['content'];
$widget_id = $instance['widget_id'];
if($this->widget_data->flag && !empty($this->widget_data->data)): ?>
Please make sure that you configured Aklamator plugin correctly
Click here to configure Aklamator plugin