Settings';
array_unshift($links, $settings_link);
return $links;
}
}
add_filter("plugin_action_links_".plugin_basename(__FILE__), 'aklamatorinfeed_plugin_settings_link' );
/*
* Add rate and review link in plugin section
*/
if( !function_exists("aklamatorinfeed_plugin_meta_links")) {
function aklamatorINfeed_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', 'aklamatorinfeed_plugin_meta_links', 10, 2);
/*
* Activation Hook
*/
register_activation_hook( __FILE__, 'set_up_options_aklamator_infeed' );
function set_up_options_aklamatorinfeed(){
add_option('aklamatorinfeed_user_id', '');
add_option('aklamatorinfeed_access_token', '');
add_option('aklamatorinfeedApplicationID', '');
add_option('aklamatorinfeedPoweredBy', '');
add_option('aklamatorinfeedSingleWidgetID', '');
add_option('aklamatorinfeedPageWidgetID', '');
add_option('aklamatorinfeedSingleWidgetTitle', '');
}
/*
* Uninstall Hook
*/
register_uninstall_hook(__FILE__, 'aklamatorinfeed_uninstall');
function aklamatorinfeed_uninstall()
{
delete_option('aklamatorinfeed_user_id');
delete_option('aklamatorinfeed_access_token');
delete_option('aklamatorinfeedApplicationID');
delete_option('aklamatorinfeedPoweredBy');
delete_option('aklamatorinfeedSingleWidgetID');
delete_option('aklamatorinfeedPageWidgetID');
delete_option('aklamatorinfeedSingleWidgetTitle');
}
if( !function_exists("bottom_of_every_post_infeed")){
function bottom_of_every_post_infeed($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('aklamatorinfeedSingleWidgetID');
}elseif (is_page()) {
$widget_id = get_option('aklamatorinfeedPageWidgetID');
}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;
}
$return_content = $content;
if (strlen($widget_id) >= 7) {
$title = "";
// $aklamator_url = 'http://192.168.5.60/aklamator/www';
$aklamator_url = 'https://aklamator.com/';
if (get_option('aklamatorinfeedSingleWidgetTitle') !== '') {
$title .= "
" . get_option('aklamatorinfeedSingleWidgetTitle') . "
";
}
/* append the text file contents to the end of `the_content` */
$return_content .= "$title
" . "
";
}
return $return_content;
}
}
class AklamatorINfeedWidget
{
public $aklamator_url;
public $api_data;
public $popular_channels = array(
array(
'name' => 'YouTube Spotlight',
'url' => 'https://www.youtube.com/user/youtube'
),
array(
'name' => 'PewDiePie',
'url' => 'https://www.youtube.com/user/PewDiePie/'
),
array(
'name' => 'EmiMusic',
'url' => 'https://www.youtube.com/user/emimusic'
),
array(
'name' => 'FunToyzCollector',
'url' => 'https://www.youtube.com/user/disneycollectorbr'
)
);
public function __construct()
{
$this->aklamator_url = "https://aklamator.com/";
// $this->aklamator_url = "http://192.168.5.60/aklamator/www/";
if (is_admin()) {
add_action("admin_menu", array(
&$this,
"adminMenu"
));
add_action('admin_init', array(
&$this,
"setOptions"
));
if (get_option('aklamatorinfeedApplicationID') !== '') {
$this->api_data = $this->addNewWebsiteApi();
}
}
if (get_option('aklamatorinfeedSingleWidgetID') !== 'none') {
if (get_option('aklamatorinfeedSingleWidgetID') == '') {
if (isset($this->api_data->data) && $this->api_data->data) {
$selected = "";
foreach ($this->api_data->data as $item) {
if ($item->title == 'Initial infeed widget created') {
$selected = $item->uniq_name;
}
}
if ($selected != "")
{
update_option('aklamatorinfeedSingleWidgetID', $selected);
}
else
{
update_option('aklamatorinfeedSingleWidgetID', $this->api_data->data[0]->uniq_name);
}
}
}
add_filter('the_content', 'bottom_of_every_post_infeed');
}
if (get_option('aklamatorinfeedPageWidgetID') !== 'none') {
if (get_option('aklamatorinfeedPageWidgetID') == '') {
if (isset($this->api_data->data) && $this->api_data->data) {
$selected = "";
foreach ($this->api_data->data as $item) {
if ($item->title == 'Initial infeed widget created') {
$selected = $item->uniq_name;
}
}
if ($selected != "") {
update_option('aklamatorinfeedPageWidgetID', $selected);
} else {
update_option('aklamatorinfeedPageWidgetID', $this->api_data->data[0]->uniq_name);
}
}
}
add_filter('the_content', 'bottom_of_every_post_infeed');
}
}
function getinfeedfeedforAklamator() {
$empty = array(array(
'link' => '',
'created_time' => '',
'thumbnail_url' => '',
'caption' => '',
'username' => '',
'full_name' => '',
));
$media = file_get_contents("http://instagram.com/{$this->username}/media");
if(strlen($media) < 1) return $empty;
$json = json_decode($media);
if(!isset($json->items) || count($json->items) == 0) return $empty;
$results = array();
foreach( $json->items as $item ) {
$results[] = array(
'link' => $item->link,
'created_time' => $item->created_time,
'thumbnail_url' => $item->images->standard_resolution->url,
'caption' => isset( $item->caption->text ) ? $item->caption->text : '',
'username' => $item->user->username,
'full_name' => $item->user->full_name,
);
}
return $results;
}
function setOptions()
{
register_setting('aklamatorinfeed-options', 'aklamatorinfeed_user_id');
register_setting('aklamatorinfeed-options', 'aklamatorinfeed_access_token');
register_setting('aklamatorinfeed-options', 'aklamatorinfeedApplicationID');
register_setting('aklamatorinfeed-options', 'aklamatorinfeedPoweredBy');
register_setting('aklamatorinfeed-options', 'aklamatorinfeedSingleWidgetID');
register_setting('aklamatorinfeed-options', 'aklamatorinfeedPageWidgetID');
register_setting('aklamatorinfeed-options', 'aklamatorinfeedSingleWidgetTitle');
}
public function adminMenu()
{
add_menu_page('Aklamator - INfeed', 'Aklamator INfeed', 'manage_options', 'aklamator-infeed', array(
$this,
'createAdminPage'
), content_url() . '/plugins/aklamator-infeed/images/aklamator-icon.png');
}
public function getSignupUrl()
{
return $this->aklamator_url . 'registration/publisher?utm_source=wordpress&utm_medium=wpyoutube&e=' . urlencode(get_option('admin_email')) . '&pub=' . preg_replace('/^www\./','',$_SERVER['SERVER_NAME']).
'&un=' . urlencode(wp_get_current_user()->display_name).'&domain='.site_url().'&pl=infeed';
}
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('aklamatorinfeedApplicationID');
$p['aklamatorinstagram_user_id'] = get_option('aklamatorinfeed_user_id');
$p['aklamatorinstagram_access_token'] = get_option('aklamatorinfeed_access_token');
$data = wp_remote_post( $service, array(
'method' => 'POST',
'timeout' => 45,
'redirection' => 5,
'httpversion' => '1.0',
'blocking' => true,
'headers' => array(),
'body' => $p,
'cookies' => array()
)
);
$ret_info = new stdClass();
if(is_wp_error($data))
{
$this->curlfailovao=1;
}
else
{
$this->curlfailovao=0;
$ret_info = json_decode($data['body']);
}
return $ret_info;
}
public function createAdminPage()
{
$code = get_option('aklamatorinfeedApplicationID');
$user_id = get_option('aklamatorinfeed_user_id');
$access_token = get_option('aklamatorinfeed_access_token')
?>
curlfailovao) && $this->curlfailovao && get_option('aklamatorinfeedApplicationID') != ''): ?>
Error communicating with Aklamator server, please refresh plugin page or try again later.
api_data->flag) || !$this->api_data->flag): ?>
'',
'title' => '',
'content' => '',
);
public function __construct() {
// widget actual processes
parent::__construct(
'Aklamator_infeed_widget', // Base ID
'Aklamator INfeed', // 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_infeed'] ) ) {
$title = apply_filters( 'widget_title', $instance['title_infeed'], $instance, $this->id_base);
$title_html = $supertitle_html.$title;
}
echo $before_widget;
if ( $instance['title_infeed'] ) echo $before_title . $title_html . $after_title;
?>
show_widget(do_shortcode( $instance['widget_id_infeed'] )); ?>
default );
$title = strip_tags( $instance['title_infeed'] );
$widget_id = $instance['widget_id_infeed'];
if($widget_data->api_data->flag && !empty($widget_data->api_data->data)): ?>
Please make sure that you configured Aklamator plugin correctly
Click here to configure Aklamator plugin