forked from themejunkie/recent-posts-widget-extended
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rpwe.php
136 lines (112 loc) · 3.77 KB
/
rpwe.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
<?php
/**
* Plugin Name: Recent Posts Widget Extended
* Plugin URI: http://satrya.me/projects/recent-posts-widget-extended/
* Description: Enables advanced widget that gives you total control over the output of your site’s most recent Posts.
* Version: 0.9.9.1
* Author: Satrya
* Author URI: http://satrya.me/
* Author Email: [email protected]
*
* This program is free software; you can redistribute it and/or modify it under the terms of the GNU
* General Public License as published by the Free Software Foundation; either version 2 of the License,
* or (at your option) any later version.
*
* 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.
*
* 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
*
* @package Recent_Posts_Widget_Extended
* @since 0.1
* @author Satrya
* @copyright Copyright (c) 2014, Satrya
* @license http://www.gnu.org/licenses/gpl-2.0.html
*/
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
class RPW_Extended {
/**
* PHP5 constructor method.
*
* @since 0.1
*/
public function __construct() {
// Set the constants needed by the plugin.
add_action( 'plugins_loaded', array( &$this, 'constants' ), 1 );
// Internationalize the text strings used.
add_action( 'plugins_loaded', array( &$this, 'i18n' ), 2 );
// Load the functions files.
add_action( 'plugins_loaded', array( &$this, 'includes' ), 3 );
// Load the admin style.
add_action( 'admin_enqueue_scripts', array( &$this, 'admin_style' ) );
// Register widget.
add_action( 'widgets_init', array( &$this, 'register_widget' ) );
// Register new image size.
add_action( 'init', array( &$this, 'register_image_size' ) );
}
/**
* Defines constants used by the plugin.
*
* @since 0.1
*/
public function constants() {
// Set constant path to the plugin directory.
define( 'RPWE_DIR', trailingslashit( plugin_dir_path( __FILE__ ) ) );
// Set the constant path to the plugin directory URI.
define( 'RPWE_URI', trailingslashit( plugin_dir_url( __FILE__ ) ) );
// Set the constant path to the includes directory.
define( 'RPWE_INCLUDES', RPWE_DIR . trailingslashit( 'includes' ) );
// Set the constant path to the includes directory.
define( 'RPWE_CLASS', RPWE_DIR . trailingslashit( 'classes' ) );
// Set the constant path to the assets directory.
define( 'RPWE_ASSETS', RPWE_URI . trailingslashit( 'assets' ) );
}
/**
* Loads the translation files.
*
* @since 0.1
*/
public function i18n() {
load_plugin_textdomain( 'rpwe', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
}
/**
* Loads the initial files needed by the plugin.
*
* @since 0.1
*/
public function includes() {
require_once( RPWE_INCLUDES . 'resizer.php' );
require_once( RPWE_INCLUDES . 'functions.php' );
require_once( RPWE_INCLUDES . 'shortcode.php' );
require_once( RPWE_INCLUDES . 'helpers.php' );
}
/**
* Register custom style for the widget settings.
*
* @since 0.8
*/
public function admin_style() {
// Loads the widget style.
wp_enqueue_style( 'rpwe-admin-style', trailingslashit( RPWE_ASSETS ) . 'css/rpwe-admin.css', null, null );
}
/**
* Register the widget.
*
* @since 0.9.1
*/
public function register_widget() {
require_once( RPWE_CLASS . 'widget.php' );
register_widget( 'Recent_Posts_Widget_Extended' );
}
/**
* Register new image size.
*
* @since 0.9.4
*/
function register_image_size() {
add_image_size( 'rpwe-thumbnail', 45, 45, true );
}
}
new RPW_Extended;