forked from niemanlab/openfuego
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathopenfuego.php
167 lines (130 loc) · 4.37 KB
/
openfuego.php
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<?php
/*
Plugin Name: OpenFuego for WordPress
Plugin URI: http://github.com/AramZS/openfuego
Description: A WordPress adaptation of the OpenFuego system from Nieman Journalism Lab (as created by Andrew Phelps).
Version: 0.0.1
Author: Aram Zucker-Scharff, Andrew Phelps
Author URI: http://github.com/AramZS
License: GPL2
*/
/* Developed for the CFO Publishing
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
I should also note that I borrowed heavily from coding patterns in the PressForward
project that were created by Boone Gorges.
*/
//Set up some constants
define( 'OF_SLUG', 'of' );
define( 'OF_TITLE', 'OpenFuego' );
define( 'OF_MENU_SLUG', PF_SLUG . '-menu' );
define( 'OF_ROOT', dirname(__FILE__) );
define( 'OF_FILE_PATH', PF_ROOT . '/' . basename(__FILE__) );
define( 'OF_URL', plugins_url('/', __FILE__) );
define( 'OF_VERSION', '0.0.1' );
class OpenFuegoWP {
var $openfuego_installer;
var $openfuego_wp_adminspace;
var $openfuego_bootstrapper;
var $openfuego_runtime;
var $openfuego_pressedforward;
var $openfuego_frontend;
public static function init(){
static $instance;
if (! is_a($instance, 'OpenFuegoWP' )){
$instance = new self();
}
return $instance;
}
private function __construct(){
$this->includes();
$this->openfuego_install();
$this->openfuego_wp_admin();
$this->openfuego_bootstrap();
$this->openfuego_run();
$this->openfuego_unto_pf();
$this->openfuego_display();
add_action( 'wp', array( $this, 'check_installed' ), 0 );
load_plugin_textdomain( 'of', false, OF_ROOT . '/languages' );
}
function includes() {
// Pull and parse Open Graph data from a page.
require_once( OF_ROOT . "/includes/openfuego_install.php" );
}
function openfuego_install(){
if ( empty( $this->openfuego_installer ) ) {
$this->openfuego_installer = new OpenFuego_Installer;
}
}
function openfuego_wp_admin(){
if ( empty( $this->openfuego_wp_adminspace ) ) {
$this->openfuego_wp_adminspace = new OpenFuegoWPAdmin;
}
}
function openfuego_bootstrap(){
if ( empty( $this->openfuego_bootstrapper ) ) {
$this->openfuego_bootstrapper = new OpenFuegoBootstrap;
}
}
function openfuego_run(){
if ( empty( $this->openfuego_runtime ) ) {
$this->openfuego_runtime = new OpenFuegoRunner;
}
}
function openfuego_unto_pf(){
if ( empty( $this->openfuego_pressedforward ) ) {
$this->openfuego_pressedforward = new OpenFuegoPF;
}
}
function openfuego_display(){
if ( empty( $this->openfuego_frontend ) ) {
$this->openfuego_frontend = new OpenFuegoDisplay;
}
}
/**
* Set up first feed and other install/upgrade tasks
* Code via Boone
*
* @since 0.0.1
*
*
*/
public function check_installed() {
$current_version = OF_VERSION; // define this constant in the loader file
$saved_version = get_option( 'of_version' );
// This is a new installation
if ( ! $saved_version ) {
// Do whatever you need to do during first installation
// This is an upgrade
} else if ( version_compare( $saved_version, $current_version, '<' ) ) {
// Do whatever you need to do on an upgrade
// Version is up to date - do nothing
} else {
return;
}
// Update the version number stored in the db (so this does not run again)
update_option( 'of_version', OF_VERSION );
}
}
/**
* Bootstrap
*
* You can also use this to get a value out of the global, eg
*
* $foo = openfuego_for_wp()->bar;
*
* @since 0.0.1
*/
function openfuego_for_wp() {
return OpenFuegoWP::init();
}
// Start me up!
openfuego_for_wp();