options = get_option("pw-mobile-app");
$this->accountOptions = get_option("androapp_account_settings");
$this->scriptsOptions = get_option("androapp_scripts_detected");
}
// Add checkboxes
function androapp_notification_settings() {
global $post;
$dont_send_push_notification = (get_post_meta($post->ID, "androapp_post_notify", true) ? ' checked' : '');
?>
/>
ID, "androapp_post_notify", $_POST["androapp_post_notify"]);
if (($old_status != 'publish') && ($new_status == 'publish')) {
$dont_send_push_notification = get_post_meta($post->ID, "androapp_post_notify", true);
if(empty($dont_send_push_notification))
{
$this->schedule_push_notification($post);
}
}
}
function schedule_push_notification_save(){
global $post;
$this->schedule_push_notification($post);
}
function schedule_push_notification($post){
wp_schedule_single_event( time()+ 10*60 , 'send_push_notification_after_publish', array ($post->ID, $post->post_title, $this->accountOptions[GCM_API_KEY] , $this->accountOptions[NOTIFICATION_TYPE_KEY] ));
}
function send_push_notification_after_publish($post_id, $post_title, $google_api_key, $notification_type)
{
require_once PW_MOBILE_PATH.'gcm/send_message.php';
sendPushNotification(array("post_id" => $post_id, "title" => $post_title, "notification_type" => $notification_type), $google_api_key);
}
function removeShortcodes($shortcodes){
global $shortcode_tags;
$shortCodesFunctionArray = array();
foreach($shortcodes as $shortcode){
if(!empty($shortcode_tags[$shortcode])){
$shortCodesFunctionArray[$shortcode] = $shortcode_tags[$shortcode];
unset($shortcode_tags[$shortcode]);
}
}
return $shortCodesFunctionArray;
}
function addShortcodesBack($shortCodesFunctionArray){
global $shortcode_tags;
foreach($shortCodesFunctionArray as $key => $shortcode){
$shortcode_tags[$key] = $shortcode;
}
}
function getScripts(){
if(!empty($this->scriptsOptions) && !empty($this->options[pw_mobile_app_settings::$selectedScripts])){
$scripts = $this->scriptsOptions['scripts'];
$selectedScripts = explode("\n", $this->options[pw_mobile_app_settings::$selectedScripts]);
foreach($selectedScripts as $handle){
$handle = trim($handle);
if($scripts[$handle]){
$out .= "";
}
}
}
if(!empty($this->options[pw_mobile_app_settings::$postProcessedCss])){
$out .= "";
}
return $out;
}
function pw_mobile_prepare_post($data, $post, $context) {
$data['pwapp_feed_image_dimension_type'] = $this->options['image_dimension'];
$share_text_fn = $this->options['share_function_name'];
if($this->options['image_dimension'] != 'noimage'){
$data['pwapp_post_image'] = get_first_image($post['post_content']);
}
$preview = "";
if($this->options['excerpt_preference'] == 'seo_meta_desc'){
$wpseo_metadesc = get_post_meta($post['ID'], '_yoast_wpseo_metadesc', true);
if(!empty($wpseo_metadesc)){
$preview = $wpseo_metadesc;
}
}else if($this->options['excerpt_preference'] == 'none'){
$preview = "";
}else{
$this->options['excerpt_preference'] = "excerpt";
$preview = $data['excerpt'];
}
$data['pwapp_excerpt'] = $preview;
$postcontent = "";
if($this->options['post_content'] == 'preprocessed'){
$shortcodesToRemove = array('caption', 'wp_caption', 'gallery', 'playlist', 'audio','video');
$shortcodesArray = $this->removeShortcodes($shortcodesToRemove);
$stripped_content = strip_shortcodes(wpautop($post['post_content']));
$this->addShortcodesBack($shortcodesArray);
$postcontent = do_shortcode($stripped_content);
}else if($this->options['post_content'] == 'postprocessed'){
$postcontent = $this->getScripts()."".$data['content']."
";
}
$data['pwapp_post_content'] = $postcontent;
$data['pwapp_post_content_type'] = $this->options['post_content'];
$data['pwapp_preview_type'] = $this->options['excerpt_preference'];
$data['share_text'] = "";
if(!empty($share_text_fn) && function_exists($share_text_fn) ){
$data['share_text'] = $share_text_fn($post, $data['link']);
}
if(empty($data['share_text'])){
if($this->options[pw_mobile_app_settings::$sharePreference] == "TITLE"){
$data['share_text'] = $data['title'];;
}
else if($this->options[pw_mobile_app_settings::$sharePreference] == "EXCERPT"){
$data['share_text'] = $data['excerpt'];;
}
else if($this->options[pw_mobile_app_settings::$sharePreference] == "SEO"){
$wpseo_metadesc = get_post_meta($post['ID'], '_yoast_wpseo_metadesc', true);
if(!empty($wpseo_metadesc)){
$data['share_text'] = $wpseo_metadesc;
}
}else if($this->options[pw_mobile_app_settings::$sharePreference] == "FULL"){
$data['share_text'] = wpautop($post['post_content']);
}
if(!empty($this->options[pw_mobile_app_settings::$shareSuffixText])){
$data['share_text'] .= " ".$this->options[pw_mobile_app_settings::$shareSuffixText];
}
if($this->options[pw_mobile_app_settings::$shareSuffixLink] == "HOME"){
$data['share_text'] .= " ".get_bloginfo('url');
}
else if($this->options[pw_mobile_app_settings::$shareSuffixLink] == "POST"){
$data['share_text'] .= " ". $data['link'];
}
}
$data['supercache'] = "androappsupercache";
return $data;
}
function myplugin_api_init( $server ) {
global $myplugin_api_mytype;
require_once dirname( __FILE__ ) . '/class-pw-wp-menu.php';
$myplugin_api_mytype = new Pw_Wp_Menu( $server );
add_filter( 'json_endpoints', array( $myplugin_api_mytype, 'register_routes'), 0);
require_once dirname( __FILE__ ) . '/class-pw-wp-posts.php';
$pwapp_posts = new Pw_Wp_Posts( $server );
add_filter( 'json_endpoints', array( $pwapp_posts, 'register_routes'), 0);
require_once dirname( __FILE__ ) . '/class-pw-wp-gcm-register.php';
$pwapp_gcm = new Pw_Wp_Gcm_Register( $server );
add_filter( 'json_endpoints', array( $pwapp_gcm, 'register_routes'), 0);
}
function add_css_bottom() {
if(isAndroAppRequest())
{
echo '';
}
}
}