This repository was archived by the owner on Sep 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patharpw.php
More file actions
executable file
·144 lines (117 loc) · 4.02 KB
/
arpw.php
File metadata and controls
executable file
·144 lines (117 loc) · 4.02 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
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
<?php
/**
* Plugin Name: Advanced Random Posts Widget
* Plugin URI: https://github.com/idenovasi/advanced-random-posts-widget
* Description: Easily to display advanced random posts via shortcode or widget.
* Version: 2.2.0
* Author: Idenovasi
* Author URI: https://idenovasi.com/
* Author Email: satrya@idenovasi.com
*
* 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
*/
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'ARP_Widget' ) ) :
class ARP_Widget {
/**
* PHP5 constructor method.
*
* @since 0.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 );
// Register widget.
add_action( 'widgets_init', array( &$this, 'register_widget' ) );
// Register new image size.
add_action( 'init', array( &$this, 'register_image_size' ) );
// Enqueue the front-end style.
add_action( 'wp_enqueue_scripts', array( &$this, 'plugin_style' ) );
// Load the admin style.
add_action( 'admin_enqueue_scripts', array( &$this, 'admin_scripts' ) );
add_action( 'customize_controls_enqueue_scripts', array( &$this, 'admin_scripts' ) );
}
/**
* Defines constants used by the plugin.
*
* @since 0.0.1
*/
public function constants() {
// Set constant path to the plugin directory.
define( 'ARPW_DIR', trailingslashit( plugin_dir_path( __FILE__ ) ) );
// Set the constant path to the plugin directory URI.
define( 'ARPW_URI', trailingslashit( plugin_dir_url( __FILE__ ) ) );
// Set the constant path to the includes directory.
define( 'ARPW_INC', ARPW_DIR . trailingslashit( 'includes' ) );
// Set the constant path to the assets directory.
define( 'ARPW_ASSETS', ARPW_URI . trailingslashit( 'assets' ) );
}
/**
* Loads the translation files.
*
* @since 0.0.1
*/
public function i18n() {
load_plugin_textdomain( 'advanced-random-posts-widget', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
}
/**
* Loads the initial files needed by the plugin.
*
* @since 0.0.1
*/
public function includes() {
require_once( ARPW_INC . 'functions.php' );
require_once( ARPW_INC . 'resizer.php' );
require_once( ARPW_INC . 'posts.php' );
require_once( ARPW_INC . 'shortcode.php' );
require_once( ARPW_INC . 'widget.php' );
}
/**
* Register custom style for the widget settings.
*
* @since 0.0.1
*/
function admin_scripts() {
wp_enqueue_style( 'arpw-admin-style', trailingslashit( ARPW_ASSETS ) . 'css/arpw-admin.css' );
wp_enqueue_script( 'arpw-admin-script', trailingslashit( ARPW_ASSETS ) . 'js/jquery-cookie.js', array( 'jquery-ui-tabs' ) );
}
/**
* Register the widget.
*
* @since 0.0.1
*/
function register_widget() {
register_widget( 'Advanced_Random_Posts_Widget' );
}
/**
* Register new image size.
*
* @since 0.0.1
*/
function register_image_size() {
add_image_size( 'arpw-thumbnail', 50, 50, true );
}
/**
* Enqueue front-end style.
*
* @since 0.0.1
*/
function plugin_style() {
wp_register_style( 'arpw-style', trailingslashit( ARPW_ASSETS ) . 'css/arpw-frontend.css' );
}
}
endif;
new ARP_Widget;