function mysiteapp_send_push($post_id, $post_details = NULL) { if (!uppsite_api_values_set() || uppsite_push_control_enabled() && !isset($_POST['send_push'])) { return; } if (is_null($post_details)) { $post_details = get_post($post_id, ARRAY_A); } $dataOpts = get_option(MYSITEAPP_OPTIONS_DATA); $json_str = json_encode(array('title' => $post_details['post_title'], 'post_id' => $post_details['ID'], 'utime' => mysiteapp_convert_datetime($post_details['post_date']), 'api_key' => $dataOpts['uppsite_key'])); $hash = mysiteapp_sign_message($json_str); wp_remote_post(MYSITEAPP_PUSHSERVICE, array('body' => 'data=' . $json_str . '&hash=' . $hash, 'timeout' => 5)); }
function uppsite_add_pushcontrol_button() { global $post; if (uppsite_push_control_enabled() && get_post_type($post) == 'post' && get_post_status($post) != 'publish') { ?> <div class="misc-pub-section"> <label for="send_push" style="background-repeat: no-repeat; background-position: left center; background-image: url(<?php echo plugins_url('images/push-icon.png', __FILE__); ?> ); padding: 2px 0 1px 20px; font-weight: bold"> Send Push? <input name="send_push" type="checkbox" id="send_push" value="1" checked="checked"/> </label> </div> <?php } }