-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
43 lines (28 loc) · 905 Bytes
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
/*
Plugin Name: Follow Script
*/
add_action( 'wp_enqueue_scripts', 'my_enqueue' );
function my_enqueue() {
wp_enqueue_script( 'ajax-script', plugins_url( 'follow.js', __FILE__ ), array('jquery'));
wp_localize_script( 'ajax-script', 'ajax_object',
array( 'ajax_url' => admin_url( 'admin-ajax.php' )) );
}
add_action('wp_ajax_my_action', 'my_action_callback');
add_action('wp_ajax_nopriv_my_action', 'my_action_callback');
function my_action_callback() {
global $wpdb;
error_log(print_r($post, 1));
$data = intval( $_POST['data'] );
echo 'success';
die(); // this is required to return a proper result
}
add_filter('the_content', 'add_post_content');
function add_post_content($content) {
if(!is_feed() && !is_home()) {
global $post;
$content .= '<p><input type="button" class="follow" value="Follow" data="' . $post->ID . '" /></p>';
}
return $content;
}
?>