'.$params['send_time']. ' '.$params['title'].' '.$text; $sitesCache = json_decode(json_encode (get_transient('xpush_sites')), true); $sitesArr = explode(',', $post['xpush_sites']); $sites = ''; foreach ($sitesArr as $key => $val) { $sites .= $sitesCache[$val]. ','; } if ($sites{strlen($sites)-1} == ',') { $sites = substr($sites,0,-1); } if ($post['xpush_regions'] != '') { if ($post['xpush_regions']{strlen($post['xpush_regions'])-1} == ',') { $post['xpush_regions'] = substr($post['xpush_regions'],0,-1); } $post['xpush_regions'] = str_replace(',',', ',$post['xpush_regions']); } if ($post['xpush_langs'] != '') { if ($post['xpush_langs']{strlen($post['xpush_langs'])-1} == ',') { $post['xpush_langs'] = substr($post['xpush_langs'],0,-1); } $post['xpush_langs'] = str_replace(',',', ',$post['xpush_langs']); } if ($post['xpush_tags'] != '') { if ($post['xpush_tags']{strlen($post['xpush_tags'])-1} == ',') { $post['xpush_tags'] = substr($post['xpush_tags'],0,-1); } $post['xpush_tags'] = str_replace(',',', ',$post['xpush_tags']); } $sites = str_replace(',',', ',$sites); if (is_numeric($send)) { $content .= ' '.__( 'RecipientsF', '3xpush' ).': '.$send; } else { $content .= ' '.$send; } $content .= ''.'
'; $content .= ''. __( 'RecipientsN', '3xpush' ) .'
'; $content .= ''. __( 'Sites', '3xpush' ).': '.$sites. ''. __('Regions', '3xpush' ).': '.$post['xpush_regions']. ''. __('Langs', '3xpush').': '.$post['xpush_langs']. ''. __( 'Tags', '3xpush' ).': '.$post['xpush_tags']. '
'; $data = array( 'id' => NULL, 'p_date' => $params['send_time'].':00', 'p_status' => $status, 'p_recipients' => $recipients, 'p_content' => $content ); $wpdb->insert($wpdb->get_blog_prefix().'xpush_dispatch', $data); } protected function xpush_get_api_log(){ global $wpdb; $query = $wpdb->get_results("SELECT * FROM ".$wpdb->get_blog_prefix()."xpush_dispatch ORDER BY p_date DESC", OBJECT); return $query; } protected function xpush_trim_text($text, $count){ $text = strip_tags(trim($text)); $exp = mb_strlen($text, 'UTF-8'); if ($exp > $count) { $text = mb_substr($text, 0, $count, 'UTF-8'); } return $text; } public function xpush_get_site_lang(){ $langArr = explode('_', get_locale()); return $langArr; } public function xpush_get_site_domen(){ $domenArr = explode('//', get_option('siteurl')); return $domenArr[1]; } protected function xpush_post_processing($post){ $data = array(); $result = array(); unset($post['file']); foreach($post as $key => $val){ $val = (!is_numeric($val)) ? htmlspecialchars(trim($val)) : intval($val); $data[$key] = $val; } if ($data['form-action'] == 'check-key' && strlen($data['api-key']) > 1){ $check = $this->api->xpush_check_api_status($data['api-key']); if ($check == 'valid'){ $result['message'] = __( 'Api-key valid', '3xpush' ); $result['class'] = 'notice-success'; delete_option('xpush_api_key'); update_option('xpush_api_key', $data['api-key']); } else { $result['message'] = $check; $result['class'] = 'notice-error'; } } else { unset($data['form-action']); delete_option('xpush_settings'); delete_option('xpush_tuned'); $sUpdate = update_option('xpush_settings', maybe_serialize($data)); $tUpdate = update_option('xpush_tuned', '1'); if ($sUpdate && $tUpdate){ $result['message'] = __( 'Settings saved successfully', '3xpush' ); $result['class'] = 'notice-success'; } else { $result['message'] = __( 'Error saving settings', '3xpush' ); $result['class'] = 'notice-error'; } } return $result; } public function xpush_set_api_cash(){ $key = get_option('xpush_api_key'); if (strlen($key) > 20) { foreach ($this->options as $item){ $cache = get_transient($item); if( false === $cache){ $option = $this->api->xpush_get_api_options($item); if ($option) { set_transient($item, $option, 1 * HOUR_IN_SECONDS ); } } } } } private function xpush_is_gutenberg_active() { $gutenberg = false; $block_editor = false; if ( has_filter( 'replace_editor', 'gutenberg_init' ) ) { $gutenberg = true; } if ( version_compare( $GLOBALS['wp_version'], '5.0-beta', '>' ) ) { $block_editor = true; } if ( ! $gutenberg && ! $block_editor ) { return false; } include_once ABSPATH . 'wp-admin/includes/plugin.php'; if ( ! is_plugin_active( 'classic-editor/classic-editor.php' ) ) { return true; } $use_block_editor = ( get_option( 'classic-editor-replace' ) === 'no-replace' ); return $use_block_editor; } public function xpush_image_upload(){ if (isset($_GET['id']) ){ $id = filter_input( INPUT_GET, 'id', FILTER_VALIDATE_INT ); $image_url = wp_get_attachment_image_url($id, 'full', false); $image_info = pathinfo($image_url); $image_sizes = getimagesize($image_url); $data = array( 'url' => $image_url, 'ext' => $image_info['extension'], 'width' => $image_sizes[0], 'height' => $image_sizes[1] ); wp_send_json_success( $data ); } else { wp_send_json_error(); } } }