-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclasses.php
More file actions
60 lines (54 loc) · 1.67 KB
/
classes.php
File metadata and controls
60 lines (54 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
class RedAlert
{
const OREF_URL='http://www.oref.org.il/WarningMessages/alerts.json';
public function registerScripts()
{
$scriptFile=RED_ALERT_URL.'/script.js';
$styleFile=RED_ALERT_URL.'/style.css';
wp_register_script(__FILE__.'reer',$scriptFile,array('jquery'),false,false);
wp_enqueue_script(__FILE__.'reer');
wp_register_style(__FILE__.'style', $styleFile);
wp_enqueue_style(__FILE__.'style');
}
public function echoScript()
{
$scriptString='<script>'
. 'redAlertPikudOref("'. plugin_dir_url(__FILE__).'/cities.json","'. admin_url('admin-ajax.php').'");'
. '</script>';
echo $scriptString;
}
public function parseCities()
{
$json= file_get_contents(plugin_dir_path(__FILE__).'/cities.json');
$arr= json_decode($json);
$data=array(
);
}
public function getAlerts()
{
$msg= wp_remote_get(self::OREF_URL);
header('content-type:json');
echo( $msg['body']);
die;
}
public function init()
{
add_action('wp_enqueue_scripts', array(&$this,'registerScripts'));
add_action('wp_footer', array(&$this,'echoScript'));
add_action('wp_ajax_nopriv_red_alert_msg',array(&$this,'getAlerts'));
}
public function __construct()
{
$this->init();
}
public static function run()
{
return new self();
}
}