Changeset 1245862
- Timestamp:
- 09/15/2015 12:43:36 PM (11 years ago)
- Location:
- trendmd/trunk
- Files:
-
- 4 edited
-
readme.txt (modified) (1 diff)
-
settings.php (modified) (7 diffs)
-
templates/settings.php (modified) (2 diffs)
-
trendmd.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trendmd/trunk/readme.txt
r1209902 r1245862 124 124 125 125 5. The recommendations widget 126 127 == Changelog == 128 129 = 1.1 = 130 * Option for excluding post categories from indexing 131 * Option for manually embedding the widget -
trendmd/trunk/settings.php
r1185392 r1245862 20 20 // register your plugin's settings 21 21 register_setting('trendmd-group', 'trendmd_journal_id'); 22 register_setting('trendmd-group', 'trendmd_custom_widget_location'); 23 register_setting('trendmd-group', 'trendmd_categories_ignored'); 24 register_setting('trendmd-group', 'trendmd_settings_saved'); 22 25 23 26 // add your settings section … … 31 34 // add your setting's fields 32 35 add_settings_field( 36 'trendmd-custom_widget_location', 37 'Do not auto-embed widget code, I want to place the widget in a custom location', 38 array(&$this, 'settings_field_input_checkbox'), 39 'trendmd', 40 'trendmd-section', 41 array( 42 'field' => 'trendmd_custom_widget_location' 43 ) 44 ); 45 add_settings_field( 46 'trendmd-categories_ignored', 47 'Do not index posts from the following categories:', 48 array(&$this, 'settings_categories'), 49 'trendmd', 50 'trendmd-section', 51 array( 52 'field' => 'trendmd_categories_ignored' 53 ) 54 ); 55 add_settings_field( 33 56 'trendmd-journal_id', 34 57 '', … … 38 61 array( 39 62 'field' => 'trendmd_journal_id' 63 ) 64 ); 65 add_settings_field( 66 'trendmd-settings_saved', 67 '', 68 array(&$this, 'settings_field_input_text2'), 69 'trendmd', 70 'trendmd-section', 71 array( 72 'field' => 'trendmd_settings_saved', 73 'value' => '1' 40 74 ) 41 75 ); … … 49 83 update_option('trendmd_journal_id', TrendMD::trendmd_get_journal_id()); 50 84 // Think of this as help text for the section. 51 if (TrendMD::is_set_journal_id() ) {85 if (TrendMD::is_set_journal_id() ) { 52 86 $count_posts = wp_count_posts(); 53 87 $published_posts = $count_posts->publish; 54 88 $chunk = round(400 / $published_posts); 55 89 56 echo '<div style="color: #333; background-color: #f2f7ec;border-color: #d6e9c6; padding: 30px; margin-bottom: 20px; border: 1px solid transparent; border-radius: 6px; font-family: \'Helvetica Neue\', Helvetica, Arial, sans-serif; font-size: 14px; max-width: 750px;"><div style="display: inline;" class="trendmd-message"><h3>TrendMD is indexing <span class="articles-indexed">1</span> of ' . number_format($published_posts) . ' articles from ' . parse_url(get_bloginfo("url"), PHP_URL_HOST) . '</h3></div><br /><br /><div class="trendmd-progress-container" style="border-radius: 4px; background: #fff; border: 1px solid #ccc; width: 400px; height: 30px; box-shadow: inset 0 1px 1px 0 rgba(0,0,0,0.2); position: relative;"><div class="trendmd-progress" style="position: absolute; top: -1px; left: 0; height: 30px; border-radius: 4px; border: 1px solid #2b6ede; background-color: #3e81ef; border-top-right-radius: 0; border-bottom-right-radius: 0; width: 0px;"></div></div></div>';90 if(get_option('trendmd_settings_saved')) echo '<div style="color: #333; background-color: #f2f7ec;border-color: #d6e9c6; padding: 30px; margin-bottom: 20px; border: 1px solid transparent; border-radius: 6px; font-family: \'Helvetica Neue\', Helvetica, Arial, sans-serif; font-size: 14px; max-width: 750px;"><div style="display: inline;" class="trendmd-message"><h3>TrendMD is indexing <span class="articles-indexed">1</span> of ' . number_format($published_posts) . ' articles from ' . parse_url(get_bloginfo("url"), PHP_URL_HOST) . '</h3></div><br /><br /><div class="trendmd-progress-container" style="border-radius: 4px; background: #fff; border: 1px solid #ccc; width: 400px; height: 30px; box-shadow: inset 0 1px 1px 0 rgba(0,0,0,0.2); position: relative;"><div class="trendmd-progress" style="position: absolute; top: -1px; left: 0; height: 30px; border-radius: 4px; border: 1px solid #2b6ede; background-color: #3e81ef; border-top-right-radius: 0; border-bottom-right-radius: 0; width: 0px;"></div></div></div>'; 57 91 58 92 } else { … … 65 99 66 100 /** 67 * This function provides text inputs for settings fields101 * This function provides text inputs for settings fields 68 102 */ 69 103 public function settings_field_input_text($args) … … 76 110 // echo a proper input type="text" 77 111 echo sprintf('<input type="hidden" name="%s" id="%s" value="%s" />', $field, $field, $value); 78 //echo TrendMD::trendmd_get_journal_id();79 112 } // END public function settings_field_input_text($args) 113 114 /** 115 * This function provides text inputs for settings fields 116 */ 117 public function settings_field_input_text2($args) 118 { 119 // Get the field name from the $args array 120 $field = $args['field']; 121 $value = $args['value']; 122 // Get the value of this setting 123 // $value = get_option($field); 124 125 // echo a proper input type="text" 126 echo sprintf('<input type="hidden" name="%s" id="%s" value="%s" />', $field, $field, $value); 127 } // END public function settings_field_input_text($args) 128 129 /** 130 * This function provides text inputs for settings fields 131 */ 132 public function settings_field_input_checkbox($args) 133 { 134 $html = '<input type="checkbox" id="trendmd_custom_widget_location" name="trendmd_custom_widget_location" value="1"' . checked(1, get_option('trendmd_custom_widget_location'), false) . '/>'; 135 echo $html; 136 } // END public function settings_field_input_text($args) 137 138 public function settings_categories($args) 139 { 140 ob_start(); 141 wp_category_checklist( 0, 0, get_option('trendmd_categories_ignored'), 0, 0, 0); 142 $select_cats = ob_get_contents(); 143 ob_end_clean(); 144 145 $select_cats = str_replace("post_category[]", "trendmd_categories_ignored[]", $select_cats); 146 echo $select_cats; 147 148 } 80 149 81 150 /** … … 111 180 add_action('wp_ajax_my_action', array('TrendMD', 'index_posts')); 112 181 113 114 115 182 ?> -
trendmd/trunk/templates/settings.php
r1185392 r1245862 1 1 <div class="wrap"> 2 <form method="POST" action="options.php"> 2 3 <?php @settings_fields('trendmd-group'); ?> 3 4 <?php do_settings_sections('trendmd'); ?> 5 6 <?php submit_button(); ?> 7 </form> 4 8 </div> 9 <?php 10 if(get_option('trendmd_settings_saved')) { 11 ?> 5 12 <script type="text/javascript"> 6 13 <?php global $wpdb; $offset = TrendMD::offset() ?> … … 37 44 ?> 38 45 </script> 46 <?php 47 } 48 ?> 49 <style type="text/css"> 50 .form-table th { 51 width:328px; 52 } 53 .form-table li 54 { 55 list-style-type: none; 56 } 57 </style> 58 -
trendmd/trunk/trendmd.php
r1185392 r1245862 4 4 Plugin URI: http://www.trendmd.com 5 5 Description: This plugin will add the TrendMD recommendations widget to your WordPress website. The TrendMD recommendations widget is used by scholarly publishers to increase their readership and revenue. 6 Version: 1. 06 Version: 1.1 7 7 */ 8 8 … … 79 79 public static function trendmd_add_html($content) 80 80 { 81 if (self::show_widget() ) {81 if (self::show_widget() && !self::custom_widget_location()) { 82 82 $content .= "<div id='trendmd-suggestions'></div>"; 83 83 } … … 97 97 public static function show_widget() 98 98 { 99 return (self::is_set_journal_id() && is_singular() && !is_preview() );99 return (self::is_set_journal_id() && is_singular() && !is_preview() && self::category_is_indexed()); 100 100 } 101 101 … … 111 111 } 112 112 113 public static function custom_widget_location() 114 { 115 return get_option('trendmd_custom_widget_location', array()); 116 } 117 118 public static function category_is_indexed() 119 { 120 121 if (in_category( get_option('trendmd_categories_ignored') )) return false; 122 return true; 123 } 124 113 125 static function prepare_string($string) 114 126 { … … 118 130 static function submit_post($post) 119 131 { 132 if(!is_object($post)) return; 120 133 global $wpdb; 121 134 $wpdb->query('REPLACE INTO ' . $wpdb->prefix . 'trendmd_indexed_articles values(' . $post->ID . ');'); … … 151 164 'post_type' => 'post', 152 165 'post_status' => 'publish', 153 'suppress_filters' => true 166 'suppress_filters' => true, 167 'category__not_in' => get_option('trendmd_categories_ignored') 154 168 ); 169 //$posts_array = get_posts($args); 155 170 $posts_array = get_posts($args); 171 156 172 157 173 foreach ($posts_array as $post) {
Note: See TracChangeset
for help on using the changeset viewer.