Changeset 1900694
- Timestamp:
- 06/28/2018 04:31:44 PM (8 years ago)
- Location:
- bitwords-io/trunk
- Files:
-
- 4 added
- 1 deleted
- 2 edited
-
assets/script.v2.js (deleted)
-
assets/script.v3.js (added)
-
assets/script.v3.min.js (added)
-
assets/style.v3.css (added)
-
assets/style.v3.min.css (added)
-
bitwords_admin_settings.php (modified) (3 diffs)
-
lib/BitwordsAPI.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
bitwords-io/trunk/bitwords_admin_settings.php
r1898118 r1900694 6 6 * Plugin Name: Bitwords.io 7 7 * Description: Show ads from the Bitwords.io site 8 * Version: 1. 2.28 * Version: 1.3.0 9 9 */ 10 10 if (!defined('WPINC')) die; … … 84 84 */ 85 85 function bitwordsScripts() { 86 wp_enqueue_style('bitwords_style', plugin_dir_url(__FILE__) . 'assets/style. css', array(), '1.1.2');87 wp_enqueue_script('bitwords_script', plugin_dir_url(__FILE__) . 'assets/script.v 2.js', array(), '1.1.2', true);86 wp_enqueue_style('bitwords_style', plugin_dir_url(__FILE__) . 'assets/style.v3.min.css', array(), '1.3.0'); 87 wp_enqueue_script('bitwords_script', plugin_dir_url(__FILE__) . 'assets/script.v3.min.js', array(), '1.3.0', true); 88 88 } 89 89 add_action('wp_enqueue_scripts', 'bitwordsScripts'); … … 120 120 $api = new BitwordsAPI(); 121 121 122 // post is published 123 if ( $new == 'publish' ) { 124 // get the content of post without tags 125 $content = wp_strip_all_tags($post->post_content); 126 // get the url of post thumbnail 127 $thumbnailUrl = get_the_post_thumbnail_url($post); 122 // Only process published posts 123 if ($new != 'publish') return 128 124 129 // post is updated130 if ( $old == 'publish') $post->type = 'update';131 // post is pulished132 else $post->type = 'publish';125 // get the content of post without tags 126 $content = wp_strip_all_tags($post->post_content); 127 // get the url of post thumbnail 128 $thumbnailUrl = get_the_post_thumbnail_url($post); 133 129 134 // fields for advertisment 135 $post->title = $post->post_title; 136 $post->description = $content; 137 $post->url = $post->guid; 138 $post->thumbnailUrl = $post->$thumbnailUrl; 130 // fields for advertisment 131 $data = array( 132 'authorId' => intval($post->post_author), 133 'comments' => intval($post->comment_count), 134 'content' => $content, 135 'guid' => $post->guid, 136 'imageUrl' => get_the_post_thumbnail_url($post), 137 'postId' => intval($post->ID), 138 'publishedAt' => $post->post_date, 139 'title' => $post->post_title, 140 'url' => get_post_permalink($post), 141 ); 139 142 140 // send this data to bitwords 141 $api->sendArticle($post); 142 } else { 143 return; 144 } 143 // send this data to bitwords 144 $api->sendPost($data); 145 145 } 146 add_action( 'transition_post_status', 'bitwordsOnArticlePublishOrUpdate', 10, 3 ); 146 147 add_action('transition_post_status', 'bitwordsOnArticlePublishOrUpdate', 10, 3); -
bitwords-io/trunk/lib/BitwordsAPI.php
r1897786 r1900694 23 23 $options = array( 24 24 'method' => 'POST', 25 'timeout' => 15,25 'timeout' => 5, 26 26 'redirection' => 2, 27 27 'blocking' => true, … … 35 35 $response = wp_remote_post($HOST . $url, $options); 36 36 37 if (is_wp_error($response)) return NULL; 38 37 39 if ($response["response"]["code"] == 200) { 38 40 $responseBody = json_decode($response["body"]); 39 41 return $responseBody; 40 42 } 41 42 die('bad response from the server');43 43 } 44 44 … … 79 79 * send published or updated articles to bitwords 80 80 */ 81 public function send Article($post) {82 $this-> _api('/publishers/wordpress/ article', $post);81 public function sendPost ($post) { 82 $this-> _api('/publishers/wordpress/post', $post); 83 83 } 84 84 }
Note: See TracChangeset
for help on using the changeset viewer.