Changeset 1311664
- Timestamp:
- 12/18/2015 02:16:15 PM (10 years ago)
- Location:
- octavius-rocks/trunk
- Files:
-
- 1 added
- 7 edited
-
admin/class-octavius-ajax.php (modified) (5 diffs)
-
admin/class-octavius-client-settings.php (modified) (3 diffs)
-
admin/js/octavius-dashboard.js (modified) (4 diffs)
-
admin/partials/octavius-dashboard-ab.php (modified) (1 diff)
-
admin/partials/octavius-settings-ab.php (modified) (5 diffs)
-
notifier.php (added)
-
octavius-client.php (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
octavius-rocks/trunk/admin/class-octavius-ajax.php
r1246523 r1311664 72 72 wp_send_json(array('success' => true, "result" => $result)); 73 73 } 74 74 75 75 public function get_ab_posts_not_chosen(){ 76 76 $post_ids = array(); 77 77 78 78 //get all posts that have no chosen variant 79 79 $args = array( 80 'meta_query' => array( 81 array( 82 'key' => '_octavius_rocks_variant', 83 'compare' => 'NOT EXISTS' 84 ), 85 ) 86 ); 80 'posts_per_page' => -1, 81 'date_query' => array( //this is the date when rendering was tracked 82 array( 83 'after' => array( 84 'year' => 2015, 85 'month' => 10, 86 'day' => 9 87 ), 88 'inclusive' => true, 89 ), 90 ), 91 'meta_query' => array( 92 array( 93 'key' => '_octavius_rocks_variant', 94 'compare' => 'NOT EXISTS' 95 ), 96 'post_type' => 'post', 97 'post_status' => 'publish', 98 ) 99 ); 87 100 // The Query 88 101 $the_query = new WP_Query( $args ); … … 96 109 /* Restore original Post Data */ 97 110 wp_reset_postdata(); 98 111 99 112 wp_send_json($post_ids); 100 113 } … … 148 161 } 149 162 } 150 163 151 164 } 152 165 wp_send_json(array('success' => true, "result" => $result)); … … 163 176 } 164 177 /** 165 * save or delete post meta 178 * save or delete post meta 166 179 */ 167 180 $pid = intval($_POST["pid"]); … … 169 182 $success = $this->variants->set_variant($pid, $slug); 170 183 /** 171 * 184 * 172 185 */ 173 186 wp_send_json(array('success' => $success, "result" => array($pid,$slug))); -
octavius-rocks/trunk/admin/class-octavius-client-settings.php
r1281156 r1311664 59 59 */ 60 60 private function render_server_settings(){ 61 // TODOtab for server settings61 //tab for server settings 62 62 $api_key_id = "ph_octavius_api_key"; 63 63 $server_id = "ph_octavius_server"; … … 122 122 $this->variants->save($values); 123 123 } 124 $sample_size_key = 'octavius_rocks_sample_size'; 125 if(isset($_POST[$sample_size_key])){ 126 update_option($sample_size_key, intval($_POST[$sample_size_key]) ); 127 } 128 $ab_email_key = 'octavius_rocks_ab_email'; 129 if(isset($_POST[$ab_email_key])){ 130 update_option($ab_email_key, trim($_POST[$ab_email_key]) ); 131 } 124 132 /** 125 133 * render settings page … … 127 135 $ab_enabled = $this->variants->enabled(); 128 136 $all = $this->variants->get(); 137 $ab_email = get_option($ab_email_key, ''); 138 $sample_size = get_option($sample_size_key, ''); 129 139 require dirname(__FILE__)."/partials/octavius-settings-ab.php"; 130 140 } -
octavius-rocks/trunk/admin/js/octavius-dashboard.js
r1281237 r1311664 18 18 var oc = null; 19 19 20 var theDate = new Date('09-10-2015');//daten when rendered was tracked on zett TODO21 22 20 this.init = function(octavius){ 23 21 oc = octavius; … … 34 32 */ 35 33 socket.on('update_ab_top_reports', function(data){ 34 console.log(data); 36 35 if(data.error){ //if no results found 37 36 $results_ab.empty(); … … 50 49 ids_map[content_id] = result; 51 50 51 } 52 if(content_ids.length < 1){ 53 $results_ab.empty(); 54 $loading_ab.css("visibility", "hidden"); 55 $results_ab.append("<tr><td colspan='3'>Derzeit sind keine Testergebnisse verfügbar.</td></tr>"); 56 return; 52 57 } 53 58 // get infos from wordpress instance … … 61 66 $loading_ab.css("visibility", "hidden"); 62 67 var countListItems = 0; 68 if(!_data.success){ 69 $results_ab.append("<tr><td colspan='3'>Fehler: Die Beitrags-IDs konnten nicht zugeordnet werden.</td></tr>"); 70 return; 71 }; 63 72 for( var i = 0; i < _data.result.length; i++){ 64 73 var result = _data.result[i]; 65 var releaseDate = new Date(result.date);66 if(theDate > releaseDate) continue; //cannot calculate signigicance for old posts67 74 var ob = ids_map[result.content_id]; 68 75 if(ob.significance.error) continue; //hide results with not calculatable significance -
octavius-rocks/trunk/admin/partials/octavius-dashboard-ab.php
r1281223 r1311664 1 <input type="hidden" id="octavius-rocks-ab-limit" value="<?php echo $limit; ?>" />1 <input type="hidden" id="octavius-rocks-ab-limit" value="<?php echo get_option('octavius_rocks_sample_size', 500); ?>" /> 2 2 <div id="octavius-rocks-ab-button-template" style="visibility: hidden"><?php echo submit_button(__("Use variant"), "small"); ?></div> 3 3 <table class="wp-list-table widefat fixed striped"> -
octavius-rocks/trunk/admin/partials/octavius-settings-ab.php
r1236313 r1311664 1 1 <form method="post" action="<?php echo $_SERVER["PHP_SELF"]; ?>?page=octavius-rocks&tab=ab"> 2 2 3 3 <h2>Settings</h2> 4 4 <table class="form-table"> … … 9 9 <td><input type="checkbox" id="octavius_rocks_ab_enabled" value="1" 10 10 <?php if($ab_enabled) echo "checked='checked'"; ?> 11 name="octavius_rocks_ab_enabled"> <?php 11 name="octavius_rocks_ab_enabled"> <?php 12 12 if($ab_enabled) { 13 echo __("Enabled"); 13 echo __("Enabled"); 14 14 } else { 15 15 echo __("Disabled"); … … 20 20 </tbody> 21 21 </table> 22 22 23 23 <h2>Variants</h2> 24 24 <?php … … 54 54 </tbody> 55 55 </table> 56 57 <h2>Testgröße</h2> 58 <table class="form-table"> 59 <tbody> 60 <tr> 61 <td scope="row"><input class="form-text" name="octavius_rocks_sample_size" type="text" value="<?php echo $sample_size; ?>"><br> 62 <small><?php echo __("Mindestanzahl Klicks insgesamt (Default 500)."); ?></small> 63 </td> 64 </tr> 65 </tbody> 66 </table> 67 68 <h2>Notifications</h2> 69 <table class="form-table"> 70 <tbody> 71 <tr> 72 <td scope="row"><?php echo __("Send Notifications to:"); ?> <input class="form-text" name="octavius_rocks_ab_email" type="text" value="<?php echo $ab_email; ?>"><br/> 73 <small><?php echo __("Leave empty for no notification. (Please notify your admin to enable the cronjob for notifications.) "); ?></small> 74 </td> 75 </tr> 76 </tbody> 77 </table> 78 56 79 <?php 57 80 else: … … 59 82 <p><?php echo __("Enable A/B Tests to see more options"); ?></p> 60 83 <?php 61 endif; 84 endif; 62 85 ?> 63 86 87 88 64 89 65 90 <?php submit_button("Save"); ?> -
octavius-rocks/trunk/octavius-client.php
r1281237 r1311664 23 23 24 24 /** 25 * The code that runs during plugin activation.26 * This action is documented in includes/class-octavius-client-activator.php25 * Dirty hack 26 * by jk because zett #152 27 27 */ 28 function activate_octavius_client() { 29 require_once plugin_dir_path( __FILE__ ) . 'includes/class-octavius-client-activator.php'; 30 Octavius_Client_Activator::activate(); 28 function analyze_ab_results(){ 29 //check if email can be sent 30 $email = get_option('octavius_rocks_ab_email', ''); 31 if(!isset($email) || $email == null || $email == "" || !filter_var($email, FILTER_VALIDATE_EMAIL)){ 32 return; 33 } 34 35 $content_ids = join(',', get_posts_with_not_chosen_variant()); 36 $limit = get_option('octavius_rocks_sample_size', 500); 37 $api_key = get_option('ph_octavius_api_key'); 38 //send request to server 39 $resp = json_decode(file_get_contents(get_option('ph_octavius_server', '')."/json/".$api_key."/ab_top_reports/".$limit."/".$content_ids)); 40 $results = $resp->result; 41 42 //write mail 43 $text = "<html><head><title>Neue Octavius Ergebnisse</title></head><body>Hallo,<br><br>"."es gibt signifikante Testergebnisse für folgende Artikel: <br>"; 44 45 $num_results = 0; 46 foreach($results as $result){ 47 if(!isset($result->significance->error)) { 48 $text .= "<a href='".get_the_permalink($result->content_id)."'>".get_the_title($result->content_id)."</a><br>"; 49 $num_results++; 50 } 51 } 52 53 //check if there are results to be sent 54 if($num_results < 1){ 55 return; 56 } 57 58 $text .= "<br>Besuche das <a href='ze.tt/wp-admin/'>ze.tt-Dashboard</a> um die Variante festzulegen. <br><br>"."Viele Grüße,<br>"."<em>Octavius</em></body></html>"; 59 60 $headers = 'From: Octavius <no-response@octavius.rocks>' . PHP_EOL . 61 'X-Mailer: PHP/' . phpversion() . 62 'MIME-Version: 1.0' . "\r\n" . 63 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; 64 65 mail($email, 'Neue Octavius Ergebnisse', $text, $headers); 31 66 } 67 /** 68 * duplicate from admin_ajax class 69 * by jk because zett #152 70 */ 71 function get_posts_with_not_chosen_variant(){ 72 $post_ids = array(); 32 73 33 /** 34 * The code that runs during plugin deactivation. 35 * This action is documented in includes/class-octavius-client-deactivator.php 36 */ 37 function deactivate_octavius_client() { 38 require_once plugin_dir_path( __FILE__ ) . 'includes/class-octavius-client-deactivator.php'; 39 Octavius_Client_Deactivator::deactivate(); 74 //get all posts that have no chosen variant 75 $args = array( 76 'posts_per_page' => -1, 77 'date_query' => array( 78 array( 79 'after' => array( 80 'year' => 2015, 81 'month' => 10, 82 'day' => 9 83 ), 84 'inclusive' => true, 85 ), 86 ), 87 'meta_query' => array( 88 array( 89 'key' => '_octavius_rocks_variant', 90 'compare' => 'NOT EXISTS' 91 ), 92 'post_type' => 'post', 93 'post_status' => 'publish', 94 ) 95 ); 96 // The Query 97 $the_query = new WP_Query( $args ); 98 // The Loop 99 if ( $the_query->have_posts() ) { 100 while ( $the_query->have_posts() ) { 101 $the_query->the_post(); 102 array_push($post_ids, get_the_ID()); 103 } 40 104 } 105 /* Restore original Post Data */ 106 wp_reset_postdata(); 41 107 42 register_activation_hook( __FILE__, 'activate_octavius_client' ); 43 register_deactivation_hook( __FILE__, 'deactivate_octavius_client' ); 108 return $post_ids; 109 110 } 44 111 45 112 /** -
octavius-rocks/trunk/readme.txt
r1281237 r1311664 5 5 Requires at least: 4.0 6 6 Tested up to: 4.3 7 Stable tag: 1.3. 97 Stable tag: 1.3.10 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 33 33 34 34 == Changelog == 35 36 = 1.3.10 = 37 * Added functionality for notification service and global sample size setting. 35 38 36 39 = 1.3.9 =
Note: See TracChangeset
for help on using the changeset viewer.