Version Description
- 12/03/2014 =
-
Fix: Compatibility issue with
Get The Image
plugin/extension. -
Fix: Issue with
html or text before and after recent posts
, now it allow all HTML tags.
Download this release
Release Info
Developer | satrya |
Plugin | Advanced Random Posts Widget |
Version | 2.0.2 |
Comparing to | |
See all releases |
Code changes from version 2.0.1 to 2.0.2
- arpw.php +153 -153
- assets/css/arpw-admin.css +52 -52
- assets/css/arpw-frontend.css +25 -25
- classes/widget.php +126 -126
- includes/form.php +223 -223
- includes/functions.php +240 -238
- includes/resizer.php +209 -209
- includes/shortcode.php +20 -20
- license.txt +338 -338
- readme.txt +177 -173
arpw.php
CHANGED
@@ -1,154 +1,154 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Plugin Name: Advanced Random Posts Widget
|
4 |
-
* Plugin URI: http://wordpress.org/plugins/advanced-random-posts-widget/
|
5 |
-
* Description: Easy to display random posts via shortcode or widget.
|
6 |
-
* Version: 2.0.
|
7 |
-
* Author: Satrya
|
8 |
-
* Author URI: http://satrya.me/
|
9 |
-
* Author Email: satrya@satrya.me
|
10 |
-
*
|
11 |
-
* This program is free software; you can redistribute it and/or modify it under the terms of the GNU
|
12 |
-
* General Public License as published by the Free Software Foundation; either version 2 of the License,
|
13 |
-
* or (at your option) any later version.
|
14 |
-
*
|
15 |
-
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
|
16 |
-
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
17 |
-
*
|
18 |
-
* You should have received a copy of the GNU General Public License along with this program; if not, write
|
19 |
-
* to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
20 |
-
*
|
21 |
-
* @package Advanced_Random_Posts_Widget
|
22 |
-
* @since 0.0.1
|
23 |
-
* @author Satrya
|
24 |
-
* @copyright Copyright (c) 2014, Satrya
|
25 |
-
* @license http://www.gnu.org/licenses/gpl-2.0.html
|
26 |
-
*/
|
27 |
-
|
28 |
-
// Exit if accessed directly
|
29 |
-
if ( ! defined( 'ABSPATH' ) ) exit;
|
30 |
-
|
31 |
-
class ARP_Widget {
|
32 |
-
|
33 |
-
/**
|
34 |
-
* PHP5 constructor method.
|
35 |
-
*
|
36 |
-
* @since 0.0.1
|
37 |
-
*/
|
38 |
-
public function __construct() {
|
39 |
-
|
40 |
-
// Set the constants needed by the plugin.
|
41 |
-
add_action( 'plugins_loaded', array( &$this, 'constants' ), 1 );
|
42 |
-
|
43 |
-
// Internationalize the text strings used.
|
44 |
-
add_action( 'plugins_loaded', array( &$this, 'i18n' ), 2 );
|
45 |
-
|
46 |
-
// Load the functions files.
|
47 |
-
add_action( 'plugins_loaded', array( &$this, 'includes' ), 3 );
|
48 |
-
|
49 |
-
// Load the admin style.
|
50 |
-
add_action( 'admin_enqueue_scripts', array( &$this, 'admin_style' ) );
|
51 |
-
|
52 |
-
// Register widget.
|
53 |
-
add_action( 'widgets_init', array( &$this, 'register_widget' ) );
|
54 |
-
|
55 |
-
// Register new image size.
|
56 |
-
add_action( 'init', array( &$this, 'register_image_size' ) );
|
57 |
-
|
58 |
-
// Enqueue the front-end style.
|
59 |
-
add_action( 'wp_enqueue_scripts', array( &$this, 'plugin_style' ) );
|
60 |
-
|
61 |
-
}
|
62 |
-
|
63 |
-
/**
|
64 |
-
* Defines constants used by the plugin.
|
65 |
-
*
|
66 |
-
* @since 0.0.1
|
67 |
-
*/
|
68 |
-
public function constants() {
|
69 |
-
|
70 |
-
// Set constant path to the plugin directory.
|
71 |
-
define( 'ARPW_DIR', trailingslashit( plugin_dir_path( __FILE__ ) ) );
|
72 |
-
|
73 |
-
// Set the constant path to the plugin directory URI.
|
74 |
-
define( 'ARPW_URI', trailingslashit( plugin_dir_url( __FILE__ ) ) );
|
75 |
-
|
76 |
-
// Set the constant path to the includes directory.
|
77 |
-
define( 'ARPW_INC', ARPW_DIR . trailingslashit( 'includes' ) );
|
78 |
-
|
79 |
-
// Set the constant path to the classes directory.
|
80 |
-
define( 'ARPW_CLASS', ARPW_DIR . trailingslashit( 'classes' ) );
|
81 |
-
|
82 |
-
// Set the constant path to the assets directory.
|
83 |
-
define( 'ARPW_ASSETS', ARPW_URI . trailingslashit( 'assets' ) );
|
84 |
-
|
85 |
-
}
|
86 |
-
|
87 |
-
/**
|
88 |
-
* Loads the translation files.
|
89 |
-
*
|
90 |
-
* @since 0.0.1
|
91 |
-
*/
|
92 |
-
public function i18n() {
|
93 |
-
load_plugin_textdomain( 'arpw', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
|
94 |
-
}
|
95 |
-
|
96 |
-
/**
|
97 |
-
* Loads the initial files needed by the plugin.
|
98 |
-
*
|
99 |
-
* @since 0.0.1
|
100 |
-
*/
|
101 |
-
public function includes() {
|
102 |
-
require_once( ARPW_INC . 'resizer.php' );
|
103 |
-
require_once( ARPW_INC . 'functions.php' );
|
104 |
-
require_once( ARPW_INC . 'shortcode.php' );
|
105 |
-
}
|
106 |
-
|
107 |
-
/**
|
108 |
-
* Register custom style for the widget settings.
|
109 |
-
*
|
110 |
-
* @since 0.0.1
|
111 |
-
*/
|
112 |
-
function admin_style() {
|
113 |
-
|
114 |
-
// Check if current screen is Widgets page.
|
115 |
-
if ( 'widgets' != get_current_screen()->base ) {
|
116 |
-
return;
|
117 |
-
}
|
118 |
-
|
119 |
-
// Loads the widget style.
|
120 |
-
wp_enqueue_style( 'arpw-admin-style', trailingslashit( ARPW_ASSETS ) . 'css/arpw-admin.css', array(), null );
|
121 |
-
|
122 |
-
}
|
123 |
-
|
124 |
-
/**
|
125 |
-
* Register the widget.
|
126 |
-
*
|
127 |
-
* @since 0.0.1
|
128 |
-
*/
|
129 |
-
function register_widget() {
|
130 |
-
require_once( ARPW_CLASS . 'widget.php' );
|
131 |
-
register_widget( 'Advanced_Random_Posts_Widget' );
|
132 |
-
}
|
133 |
-
|
134 |
-
/**
|
135 |
-
* Register new image size.
|
136 |
-
*
|
137 |
-
* @since 0.0.1
|
138 |
-
*/
|
139 |
-
function register_image_size() {
|
140 |
-
add_image_size( 'arpw-thumbnail', 50, 50, true );
|
141 |
-
}
|
142 |
-
|
143 |
-
/**
|
144 |
-
* Enqueue front-end style.
|
145 |
-
*
|
146 |
-
* @since 0.0.1
|
147 |
-
*/
|
148 |
-
function plugin_style() {
|
149 |
-
wp_enqueue_style( 'arpw-style', trailingslashit( ARPW_ASSETS ) . 'css/arpw-frontend.css', array(), null );
|
150 |
-
}
|
151 |
-
|
152 |
-
}
|
153 |
-
|
154 |
new ARP_Widget;
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Plugin Name: Advanced Random Posts Widget
|
4 |
+
* Plugin URI: http://wordpress.org/plugins/advanced-random-posts-widget/
|
5 |
+
* Description: Easy to display random posts via shortcode or widget.
|
6 |
+
* Version: 2.0.2
|
7 |
+
* Author: Satrya
|
8 |
+
* Author URI: http://satrya.me/
|
9 |
+
* Author Email: satrya@satrya.me
|
10 |
+
*
|
11 |
+
* This program is free software; you can redistribute it and/or modify it under the terms of the GNU
|
12 |
+
* General Public License as published by the Free Software Foundation; either version 2 of the License,
|
13 |
+
* or (at your option) any later version.
|
14 |
+
*
|
15 |
+
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
|
16 |
+
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
17 |
+
*
|
18 |
+
* You should have received a copy of the GNU General Public License along with this program; if not, write
|
19 |
+
* to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
20 |
+
*
|
21 |
+
* @package Advanced_Random_Posts_Widget
|
22 |
+
* @since 0.0.1
|
23 |
+
* @author Satrya
|
24 |
+
* @copyright Copyright (c) 2014, Satrya
|
25 |
+
* @license http://www.gnu.org/licenses/gpl-2.0.html
|
26 |
+
*/
|
27 |
+
|
28 |
+
// Exit if accessed directly
|
29 |
+
if ( ! defined( 'ABSPATH' ) ) exit;
|
30 |
+
|
31 |
+
class ARP_Widget {
|
32 |
+
|
33 |
+
/**
|
34 |
+
* PHP5 constructor method.
|
35 |
+
*
|
36 |
+
* @since 0.0.1
|
37 |
+
*/
|
38 |
+
public function __construct() {
|
39 |
+
|
40 |
+
// Set the constants needed by the plugin.
|
41 |
+
add_action( 'plugins_loaded', array( &$this, 'constants' ), 1 );
|
42 |
+
|
43 |
+
// Internationalize the text strings used.
|
44 |
+
add_action( 'plugins_loaded', array( &$this, 'i18n' ), 2 );
|
45 |
+
|
46 |
+
// Load the functions files.
|
47 |
+
add_action( 'plugins_loaded', array( &$this, 'includes' ), 3 );
|
48 |
+
|
49 |
+
// Load the admin style.
|
50 |
+
add_action( 'admin_enqueue_scripts', array( &$this, 'admin_style' ) );
|
51 |
+
|
52 |
+
// Register widget.
|
53 |
+
add_action( 'widgets_init', array( &$this, 'register_widget' ) );
|
54 |
+
|
55 |
+
// Register new image size.
|
56 |
+
add_action( 'init', array( &$this, 'register_image_size' ) );
|
57 |
+
|
58 |
+
// Enqueue the front-end style.
|
59 |
+
add_action( 'wp_enqueue_scripts', array( &$this, 'plugin_style' ) );
|
60 |
+
|
61 |
+
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Defines constants used by the plugin.
|
65 |
+
*
|
66 |
+
* @since 0.0.1
|
67 |
+
*/
|
68 |
+
public function constants() {
|
69 |
+
|
70 |
+
// Set constant path to the plugin directory.
|
71 |
+
define( 'ARPW_DIR', trailingslashit( plugin_dir_path( __FILE__ ) ) );
|
72 |
+
|
73 |
+
// Set the constant path to the plugin directory URI.
|
74 |
+
define( 'ARPW_URI', trailingslashit( plugin_dir_url( __FILE__ ) ) );
|
75 |
+
|
76 |
+
// Set the constant path to the includes directory.
|
77 |
+
define( 'ARPW_INC', ARPW_DIR . trailingslashit( 'includes' ) );
|
78 |
+
|
79 |
+
// Set the constant path to the classes directory.
|
80 |
+
define( 'ARPW_CLASS', ARPW_DIR . trailingslashit( 'classes' ) );
|
81 |
+
|
82 |
+
// Set the constant path to the assets directory.
|
83 |
+
define( 'ARPW_ASSETS', ARPW_URI . trailingslashit( 'assets' ) );
|
84 |
+
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* Loads the translation files.
|
89 |
+
*
|
90 |
+
* @since 0.0.1
|
91 |
+
*/
|
92 |
+
public function i18n() {
|
93 |
+
load_plugin_textdomain( 'arpw', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
|
94 |
+
}
|
95 |
+
|
96 |
+
/**
|
97 |
+
* Loads the initial files needed by the plugin.
|
98 |
+
*
|
99 |
+
* @since 0.0.1
|
100 |
+
*/
|
101 |
+
public function includes() {
|
102 |
+
require_once( ARPW_INC . 'resizer.php' );
|
103 |
+
require_once( ARPW_INC . 'functions.php' );
|
104 |
+
require_once( ARPW_INC . 'shortcode.php' );
|
105 |
+
}
|
106 |
+
|
107 |
+
/**
|
108 |
+
* Register custom style for the widget settings.
|
109 |
+
*
|
110 |
+
* @since 0.0.1
|
111 |
+
*/
|
112 |
+
function admin_style() {
|
113 |
+
|
114 |
+
// Check if current screen is Widgets page.
|
115 |
+
if ( 'widgets' != get_current_screen()->base ) {
|
116 |
+
return;
|
117 |
+
}
|
118 |
+
|
119 |
+
// Loads the widget style.
|
120 |
+
wp_enqueue_style( 'arpw-admin-style', trailingslashit( ARPW_ASSETS ) . 'css/arpw-admin.css', array(), null );
|
121 |
+
|
122 |
+
}
|
123 |
+
|
124 |
+
/**
|
125 |
+
* Register the widget.
|
126 |
+
*
|
127 |
+
* @since 0.0.1
|
128 |
+
*/
|
129 |
+
function register_widget() {
|
130 |
+
require_once( ARPW_CLASS . 'widget.php' );
|
131 |
+
register_widget( 'Advanced_Random_Posts_Widget' );
|
132 |
+
}
|
133 |
+
|
134 |
+
/**
|
135 |
+
* Register new image size.
|
136 |
+
*
|
137 |
+
* @since 0.0.1
|
138 |
+
*/
|
139 |
+
function register_image_size() {
|
140 |
+
add_image_size( 'arpw-thumbnail', 50, 50, true );
|
141 |
+
}
|
142 |
+
|
143 |
+
/**
|
144 |
+
* Enqueue front-end style.
|
145 |
+
*
|
146 |
+
* @since 0.0.1
|
147 |
+
*/
|
148 |
+
function plugin_style() {
|
149 |
+
wp_enqueue_style( 'arpw-style', trailingslashit( ARPW_ASSETS ) . 'css/arpw-frontend.css', array(), null );
|
150 |
+
}
|
151 |
+
|
152 |
+
}
|
153 |
+
|
154 |
new ARP_Widget;
|
assets/css/arpw-admin.css
CHANGED
@@ -1,53 +1,53 @@
|
|
1 |
-
.widgets-php .arpw-columns-3 {
|
2 |
-
overflow: hidden;
|
3 |
-
float: left;
|
4 |
-
width: 31%;
|
5 |
-
margin-right: 3.5%;
|
6 |
-
}
|
7 |
-
|
8 |
-
.widgets-php .arpw-columns-3 select.widefat {
|
9 |
-
width: 98.5%;
|
10 |
-
}
|
11 |
-
|
12 |
-
.widgets-php .arpw-column-last {
|
13 |
-
float: right;
|
14 |
-
margin-right: 0;
|
15 |
-
}
|
16 |
-
|
17 |
-
.widgets-php .arpw-columns-3 label {
|
18 |
-
font-size: 11px;
|
19 |
-
}
|
20 |
-
|
21 |
-
.widgets-php .arpw-columns-3 p small {
|
22 |
-
color: #777;
|
23 |
-
font-style: italic;
|
24 |
-
}
|
25 |
-
|
26 |
-
.arpw-input-half {
|
27 |
-
width: 47%;
|
28 |
-
}
|
29 |
-
|
30 |
-
.arpw-block {
|
31 |
-
display: block;
|
32 |
-
}
|
33 |
-
|
34 |
-
label.input-checkbox {
|
35 |
-
width: 100px;
|
36 |
-
display: inline-block;
|
37 |
-
}
|
38 |
-
|
39 |
-
.arpw-multiple-check-form {
|
40 |
-
margin: 1em 0;
|
41 |
-
}
|
42 |
-
|
43 |
-
.arpw-multiple-check-form ul {
|
44 |
-
border: 1px solid #eee;
|
45 |
-
padding: 10px;
|
46 |
-
max-height: 110px;
|
47 |
-
overflow: auto;
|
48 |
-
margin-top: 0;
|
49 |
-
}
|
50 |
-
|
51 |
-
.arpw-multiple-check-form ul li:last-child {
|
52 |
-
margin-bottom: 0;
|
53 |
}
|
1 |
+
.widgets-php .arpw-columns-3 {
|
2 |
+
overflow: hidden;
|
3 |
+
float: left;
|
4 |
+
width: 31%;
|
5 |
+
margin-right: 3.5%;
|
6 |
+
}
|
7 |
+
|
8 |
+
.widgets-php .arpw-columns-3 select.widefat {
|
9 |
+
width: 98.5%;
|
10 |
+
}
|
11 |
+
|
12 |
+
.widgets-php .arpw-column-last {
|
13 |
+
float: right;
|
14 |
+
margin-right: 0;
|
15 |
+
}
|
16 |
+
|
17 |
+
.widgets-php .arpw-columns-3 label {
|
18 |
+
font-size: 11px;
|
19 |
+
}
|
20 |
+
|
21 |
+
.widgets-php .arpw-columns-3 p small {
|
22 |
+
color: #777;
|
23 |
+
font-style: italic;
|
24 |
+
}
|
25 |
+
|
26 |
+
.arpw-input-half {
|
27 |
+
width: 47%;
|
28 |
+
}
|
29 |
+
|
30 |
+
.arpw-block {
|
31 |
+
display: block;
|
32 |
+
}
|
33 |
+
|
34 |
+
label.input-checkbox {
|
35 |
+
width: 100px;
|
36 |
+
display: inline-block;
|
37 |
+
}
|
38 |
+
|
39 |
+
.arpw-multiple-check-form {
|
40 |
+
margin: 1em 0;
|
41 |
+
}
|
42 |
+
|
43 |
+
.arpw-multiple-check-form ul {
|
44 |
+
border: 1px solid #eee;
|
45 |
+
padding: 10px;
|
46 |
+
max-height: 110px;
|
47 |
+
overflow: auto;
|
48 |
+
margin-top: 0;
|
49 |
+
}
|
50 |
+
|
51 |
+
.arpw-multiple-check-form ul li:last-child {
|
52 |
+
margin-bottom: 0;
|
53 |
}
|
assets/css/arpw-frontend.css
CHANGED
@@ -1,26 +1,26 @@
|
|
1 |
-
.arpw-ul {
|
2 |
-
list-style: none;
|
3 |
-
}
|
4 |
-
|
5 |
-
.arpw-li {
|
6 |
-
margin-bottom: 10px;
|
7 |
-
}
|
8 |
-
|
9 |
-
.arpw-time {
|
10 |
-
display: block;
|
11 |
-
color: #aaa;
|
12 |
-
}
|
13 |
-
|
14 |
-
.arpw-clearfix:before,
|
15 |
-
.arpw-clearfix:after {
|
16 |
-
content: "";
|
17 |
-
display: table;
|
18 |
-
}
|
19 |
-
|
20 |
-
.arpw-clearfix:after {
|
21 |
-
clear:both;
|
22 |
-
}
|
23 |
-
|
24 |
-
.arpw-clearfix {
|
25 |
-
zoom:1;
|
26 |
}
|
1 |
+
.arpw-ul {
|
2 |
+
list-style: none;
|
3 |
+
}
|
4 |
+
|
5 |
+
.arpw-li {
|
6 |
+
margin-bottom: 10px;
|
7 |
+
}
|
8 |
+
|
9 |
+
.arpw-time {
|
10 |
+
display: block;
|
11 |
+
color: #aaa;
|
12 |
+
}
|
13 |
+
|
14 |
+
.arpw-clearfix:before,
|
15 |
+
.arpw-clearfix:after {
|
16 |
+
content: "";
|
17 |
+
display: table;
|
18 |
+
}
|
19 |
+
|
20 |
+
.arpw-clearfix:after {
|
21 |
+
clear:both;
|
22 |
+
}
|
23 |
+
|
24 |
+
.arpw-clearfix {
|
25 |
+
zoom:1;
|
26 |
}
|
classes/widget.php
CHANGED
@@ -1,127 +1,127 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Custom random posts widget.
|
4 |
-
*
|
5 |
-
* @package Advanced_Random_Posts_Widget
|
6 |
-
* @since 0.0.1
|
7 |
-
* @author Satrya
|
8 |
-
* @copyright Copyright (c) 2014, Satrya
|
9 |
-
* @license http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
-
*/
|
11 |
-
class Advanced_Random_Posts_Widget extends WP_Widget {
|
12 |
-
|
13 |
-
/**
|
14 |
-
* Sets up the widgets.
|
15 |
-
*
|
16 |
-
* @since 0.0.1
|
17 |
-
*/
|
18 |
-
function __construct() {
|
19 |
-
|
20 |
-
// Set up the widget options.
|
21 |
-
$widget_options = array(
|
22 |
-
'classname' => 'arpw-widget-random',
|
23 |
-
'description' => __( 'An advanced widget that gives you total control over the output of the random posts.', 'arpw' )
|
24 |
-
);
|
25 |
-
|
26 |
-
$control_ops = array(
|
27 |
-
'width' => 700,
|
28 |
-
'height' => 350,
|
29 |
-
);
|
30 |
-
|
31 |
-
// Create the widget.
|
32 |
-
$this->WP_Widget(
|
33 |
-
'arpw-widget', // $this->id_base
|
34 |
-
__( 'Random Posts', 'arpw' ), // $this->name
|
35 |
-
$widget_options, // $this->widget_options
|
36 |
-
$control_ops // $this->control_options
|
37 |
-
);
|
38 |
-
|
39 |
-
}
|
40 |
-
|
41 |
-
/**
|
42 |
-
* Outputs the widget based on the arguments input through the widget controls.
|
43 |
-
*
|
44 |
-
* @since 0.0.1
|
45 |
-
*/
|
46 |
-
function widget( $args, $instance ) {
|
47 |
-
extract( $args );
|
48 |
-
|
49 |
-
// Output the theme's $before_widget wrapper.
|
50 |
-
echo $before_widget;
|
51 |
-
|
52 |
-
// If both title and title url is not empty, display it.
|
53 |
-
if ( ! empty( $instance['title_url'] ) && ! empty( $instance['title'] ) ) {
|
54 |
-
echo $before_title . '<a href="' . esc_url( $instance['title_url'] ) . '" title="' . esc_attr( $instance['title'] ) . '">' . apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ) . '</a>' . $after_title;
|
55 |
-
|
56 |
-
// If the title not empty, display it.
|
57 |
-
} elseif ( ! empty( $instance['title'] ) ) {
|
58 |
-
echo $before_title . apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ) . $after_title;
|
59 |
-
}
|
60 |
-
|
61 |
-
// Get the random posts query.
|
62 |
-
echo arpw_get_random_posts( $instance );
|
63 |
-
|
64 |
-
// Close the theme's widget wrapper.
|
65 |
-
echo $after_widget;
|
66 |
-
|
67 |
-
}
|
68 |
-
|
69 |
-
/**
|
70 |
-
* Updates the widget control options for the particular instance of the widget.
|
71 |
-
*
|
72 |
-
* @since 0.0.1
|
73 |
-
*/
|
74 |
-
function update( $new_instance, $old_instance ) {
|
75 |
-
|
76 |
-
$instance = $old_instance;
|
77 |
-
|
78 |
-
$instance['title'] = strip_tags( $new_instance['title'] );
|
79 |
-
$instance['title_url'] = esc_url( $new_instance['title_url'] );
|
80 |
-
|
81 |
-
$instance['offset'] = (int) $new_instance['offset'];
|
82 |
-
$instance['limit'] = (int) $new_instance['limit'];
|
83 |
-
$instance['ignore_sticky'] = isset( $new_instance['ignore_sticky'] ) ? (bool) $new_instance['ignore_sticky'] : 0;
|
84 |
-
$instance['post_type'] = esc_attr( $new_instance['post_type'] );
|
85 |
-
$instance['post_status'] = esc_attr( $new_instance['post_status'] );
|
86 |
-
$instance['taxonomy'] = esc_attr( $new_instance['taxonomy'] );
|
87 |
-
$instance['cat'] = $new_instance['cat'];
|
88 |
-
$instance['tag'] = $new_instance['tag'];
|
89 |
-
|
90 |
-
$instance['thumbnail'] = isset( $new_instance['thumbnail'] ) ? (bool) $new_instance['thumbnail'] : false;
|
91 |
-
$instance['thumbnail_size'] = esc_attr( $new_instance['thumbnail_size'] );
|
92 |
-
$instance['thumbnail_align'] = esc_attr( $new_instance['thumbnail_align'] );
|
93 |
-
$instance['thumbnail_custom'] = isset( $new_instance['thumbnail_custom'] ) ? (bool) $new_instance['thumbnail_custom'] : false;
|
94 |
-
$instance['thumbnail_width'] = (int) $new_instance['thumbnail_width'];
|
95 |
-
$instance['thumbnail_height'] = (int) $new_instance['thumbnail_height'];
|
96 |
-
|
97 |
-
$instance['excerpt'] = isset( $new_instance['excerpt'] ) ? (bool) $new_instance['excerpt'] : false;
|
98 |
-
$instance['excerpt_length'] = (int) $new_instance['excerpt_length'];
|
99 |
-
$instance['date'] = isset( $new_instance['date'] ) ? (bool) $new_instance['date'] : false;
|
100 |
-
$instance['date_relative'] = isset( $new_instance['date_relative'] ) ? (bool) $new_instance['date_relative'] : false;
|
101 |
-
|
102 |
-
$instance['css_class'] = sanitize_html_class( $new_instance['css_class'] );
|
103 |
-
$instance['before'] =
|
104 |
-
$instance['after'] =
|
105 |
-
|
106 |
-
return $instance;
|
107 |
-
}
|
108 |
-
|
109 |
-
/**
|
110 |
-
* Displays the widget control options in the Widgets admin screen.
|
111 |
-
*
|
112 |
-
* @since 0.0.1
|
113 |
-
*/
|
114 |
-
function form( $instance ) {
|
115 |
-
|
116 |
-
// Merge the user-selected arguments with the defaults.
|
117 |
-
$instance = wp_parse_args( (array) $instance, arpw_get_default_args() );
|
118 |
-
|
119 |
-
// Extract the array to allow easy use of variables.
|
120 |
-
extract( $instance );
|
121 |
-
|
122 |
-
// Loads the widget form.
|
123 |
-
include( ARPW_INC . 'form.php' );
|
124 |
-
|
125 |
-
}
|
126 |
-
|
127 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Custom random posts widget.
|
4 |
+
*
|
5 |
+
* @package Advanced_Random_Posts_Widget
|
6 |
+
* @since 0.0.1
|
7 |
+
* @author Satrya
|
8 |
+
* @copyright Copyright (c) 2014, Satrya
|
9 |
+
* @license http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
+
*/
|
11 |
+
class Advanced_Random_Posts_Widget extends WP_Widget {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Sets up the widgets.
|
15 |
+
*
|
16 |
+
* @since 0.0.1
|
17 |
+
*/
|
18 |
+
function __construct() {
|
19 |
+
|
20 |
+
// Set up the widget options.
|
21 |
+
$widget_options = array(
|
22 |
+
'classname' => 'arpw-widget-random',
|
23 |
+
'description' => __( 'An advanced widget that gives you total control over the output of the random posts.', 'arpw' )
|
24 |
+
);
|
25 |
+
|
26 |
+
$control_ops = array(
|
27 |
+
'width' => 700,
|
28 |
+
'height' => 350,
|
29 |
+
);
|
30 |
+
|
31 |
+
// Create the widget.
|
32 |
+
$this->WP_Widget(
|
33 |
+
'arpw-widget', // $this->id_base
|
34 |
+
__( 'Random Posts', 'arpw' ), // $this->name
|
35 |
+
$widget_options, // $this->widget_options
|
36 |
+
$control_ops // $this->control_options
|
37 |
+
);
|
38 |
+
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Outputs the widget based on the arguments input through the widget controls.
|
43 |
+
*
|
44 |
+
* @since 0.0.1
|
45 |
+
*/
|
46 |
+
function widget( $args, $instance ) {
|
47 |
+
extract( $args );
|
48 |
+
|
49 |
+
// Output the theme's $before_widget wrapper.
|
50 |
+
echo $before_widget;
|
51 |
+
|
52 |
+
// If both title and title url is not empty, display it.
|
53 |
+
if ( ! empty( $instance['title_url'] ) && ! empty( $instance['title'] ) ) {
|
54 |
+
echo $before_title . '<a href="' . esc_url( $instance['title_url'] ) . '" title="' . esc_attr( $instance['title'] ) . '">' . apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ) . '</a>' . $after_title;
|
55 |
+
|
56 |
+
// If the title not empty, display it.
|
57 |
+
} elseif ( ! empty( $instance['title'] ) ) {
|
58 |
+
echo $before_title . apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ) . $after_title;
|
59 |
+
}
|
60 |
+
|
61 |
+
// Get the random posts query.
|
62 |
+
echo arpw_get_random_posts( $instance );
|
63 |
+
|
64 |
+
// Close the theme's widget wrapper.
|
65 |
+
echo $after_widget;
|
66 |
+
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Updates the widget control options for the particular instance of the widget.
|
71 |
+
*
|
72 |
+
* @since 0.0.1
|
73 |
+
*/
|
74 |
+
function update( $new_instance, $old_instance ) {
|
75 |
+
|
76 |
+
$instance = $old_instance;
|
77 |
+
|
78 |
+
$instance['title'] = strip_tags( $new_instance['title'] );
|
79 |
+
$instance['title_url'] = esc_url( $new_instance['title_url'] );
|
80 |
+
|
81 |
+
$instance['offset'] = (int) $new_instance['offset'];
|
82 |
+
$instance['limit'] = (int) $new_instance['limit'];
|
83 |
+
$instance['ignore_sticky'] = isset( $new_instance['ignore_sticky'] ) ? (bool) $new_instance['ignore_sticky'] : 0;
|
84 |
+
$instance['post_type'] = esc_attr( $new_instance['post_type'] );
|
85 |
+
$instance['post_status'] = esc_attr( $new_instance['post_status'] );
|
86 |
+
$instance['taxonomy'] = esc_attr( $new_instance['taxonomy'] );
|
87 |
+
$instance['cat'] = $new_instance['cat'];
|
88 |
+
$instance['tag'] = $new_instance['tag'];
|
89 |
+
|
90 |
+
$instance['thumbnail'] = isset( $new_instance['thumbnail'] ) ? (bool) $new_instance['thumbnail'] : false;
|
91 |
+
$instance['thumbnail_size'] = esc_attr( $new_instance['thumbnail_size'] );
|
92 |
+
$instance['thumbnail_align'] = esc_attr( $new_instance['thumbnail_align'] );
|
93 |
+
$instance['thumbnail_custom'] = isset( $new_instance['thumbnail_custom'] ) ? (bool) $new_instance['thumbnail_custom'] : false;
|
94 |
+
$instance['thumbnail_width'] = (int) $new_instance['thumbnail_width'];
|
95 |
+
$instance['thumbnail_height'] = (int) $new_instance['thumbnail_height'];
|
96 |
+
|
97 |
+
$instance['excerpt'] = isset( $new_instance['excerpt'] ) ? (bool) $new_instance['excerpt'] : false;
|
98 |
+
$instance['excerpt_length'] = (int) $new_instance['excerpt_length'];
|
99 |
+
$instance['date'] = isset( $new_instance['date'] ) ? (bool) $new_instance['date'] : false;
|
100 |
+
$instance['date_relative'] = isset( $new_instance['date_relative'] ) ? (bool) $new_instance['date_relative'] : false;
|
101 |
+
|
102 |
+
$instance['css_class'] = sanitize_html_class( $new_instance['css_class'] );
|
103 |
+
$instance['before'] = stripslashes( $new_instance['before'] );
|
104 |
+
$instance['after'] = stripslashes( $new_instance['after'] );
|
105 |
+
|
106 |
+
return $instance;
|
107 |
+
}
|
108 |
+
|
109 |
+
/**
|
110 |
+
* Displays the widget control options in the Widgets admin screen.
|
111 |
+
*
|
112 |
+
* @since 0.0.1
|
113 |
+
*/
|
114 |
+
function form( $instance ) {
|
115 |
+
|
116 |
+
// Merge the user-selected arguments with the defaults.
|
117 |
+
$instance = wp_parse_args( (array) $instance, arpw_get_default_args() );
|
118 |
+
|
119 |
+
// Extract the array to allow easy use of variables.
|
120 |
+
extract( $instance );
|
121 |
+
|
122 |
+
// Loads the widget form.
|
123 |
+
include( ARPW_INC . 'form.php' );
|
124 |
+
|
125 |
+
}
|
126 |
+
|
127 |
}
|
includes/form.php
CHANGED
@@ -1,224 +1,224 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Widget forms.
|
4 |
-
*
|
5 |
-
* @package Advanced_Random_Posts_Widget
|
6 |
-
* @since 0.0.1
|
7 |
-
* @author Satrya
|
8 |
-
* @copyright Copyright (c) 2014, Satrya
|
9 |
-
* @license http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
-
*/
|
11 |
-
?>
|
12 |
-
|
13 |
-
<div class="arpw-columns-3">
|
14 |
-
|
15 |
-
<p>
|
16 |
-
<label for="<?php echo $this->get_field_id( 'title' ); ?>">
|
17 |
-
<?php _e( 'Title', 'arpw' ); ?>
|
18 |
-
</label>
|
19 |
-
<input type="text" class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo esc_attr( $instance['title'] ); ?>" />
|
20 |
-
</p>
|
21 |
-
|
22 |
-
<p>
|
23 |
-
<label for="<?php echo $this->get_field_id( 'title_url' ); ?>">
|
24 |
-
<?php _e( 'Title URL', 'arpw' ); ?>
|
25 |
-
</label>
|
26 |
-
<input type="text" class="widefat" id="<?php echo $this->get_field_id( 'title_url' ); ?>" name="<?php echo $this->get_field_name( 'title_url' ); ?>" value="<?php echo esc_url( $instance['title_url'] ); ?>" placeholder="<?php echo esc_attr( 'http://' ); ?>" />
|
27 |
-
</p>
|
28 |
-
|
29 |
-
<p>
|
30 |
-
<label for="<?php echo $this->get_field_id( 'css_class' ); ?>">
|
31 |
-
<?php _e( 'CSS Class', 'arpw' ); ?>
|
32 |
-
</label>
|
33 |
-
<input type="text" class="widefat" id="<?php echo $this->get_field_id( 'css_class' ); ?>" name="<?php echo $this->get_field_name( 'css_class' ); ?>" value="<?php echo sanitize_html_class( $instance['css_class'] ); ?>" />
|
34 |
-
</p>
|
35 |
-
|
36 |
-
<p>
|
37 |
-
<label for="<?php echo $this->get_field_id( 'before' ); ?>">
|
38 |
-
<?php _e( 'HTML or text before the random posts', 'arpw' );?>
|
39 |
-
</label>
|
40 |
-
<textarea class="widefat" id="<?php echo $this->get_field_id( 'before' ); ?>" name="<?php echo $this->get_field_name( 'before' ); ?>" rows="5"><?php echo htmlspecialchars( stripslashes( $instance['before'] ) ); ?></textarea>
|
41 |
-
</p>
|
42 |
-
|
43 |
-
<p>
|
44 |
-
<label for="<?php echo $this->get_field_id( 'after' ); ?>">
|
45 |
-
<?php _e( 'HTML or text after the random posts', 'arpw' );?>
|
46 |
-
</label>
|
47 |
-
<textarea class="widefat" id="<?php echo $this->get_field_id( 'after' ); ?>" name="<?php echo $this->get_field_name( 'after' ); ?>" rows="5"><?php echo htmlspecialchars( stripslashes( $instance['after'] ) ); ?></textarea>
|
48 |
-
</p>
|
49 |
-
|
50 |
-
</div>
|
51 |
-
|
52 |
-
<div class="arpw-columns-3">
|
53 |
-
|
54 |
-
<p>
|
55 |
-
<input class="checkbox" type="checkbox" <?php checked( $instance['ignore_sticky'], 1 ); ?> id="<?php echo $this->get_field_id( 'ignore_sticky' ); ?>" name="<?php echo $this->get_field_name( 'ignore_sticky' ); ?>" />
|
56 |
-
<label for="<?php echo $this->get_field_id( 'ignore_sticky' ); ?>">
|
57 |
-
<?php _e( 'Ignore sticky posts', 'arpw' ); ?>
|
58 |
-
</label>
|
59 |
-
</p>
|
60 |
-
|
61 |
-
<p>
|
62 |
-
<label for="<?php echo $this->get_field_id( 'limit' ); ?>">
|
63 |
-
<?php _e( 'Number of posts to show', 'arpw' ); ?>
|
64 |
-
</label>
|
65 |
-
<input class="widefat" id="<?php echo $this->get_field_id( 'limit' ); ?>" name="<?php echo $this->get_field_name( 'limit' ); ?>" type="number" step="1" min="-1" value="<?php echo (int) $instance['limit']; ?>" />
|
66 |
-
<small>-1 <?php _e( 'to show all posts.', 'arpw' ); ?></small>
|
67 |
-
</p>
|
68 |
-
|
69 |
-
<p>
|
70 |
-
<label for="<?php echo $this->get_field_id( 'offset' ); ?>">
|
71 |
-
<?php _e( 'Offset', 'arpw' ); ?>
|
72 |
-
</label>
|
73 |
-
<input type="number" step="1" min="0" class="widefat" id="<?php echo $this->get_field_id( 'offset' ); ?>" name="<?php echo $this->get_field_name( 'offset' ); ?>" value="<?php echo (int) $instance['offset']; ?>" />
|
74 |
-
<small><?php _e( 'The number of posts to skip', 'arpw' ); ?></small>
|
75 |
-
</p>
|
76 |
-
|
77 |
-
<p>
|
78 |
-
<label for="<?php echo $this->get_field_id( 'post_type' ); ?>">
|
79 |
-
<?php _e( 'Post type', 'arpw' ); ?>
|
80 |
-
</label>
|
81 |
-
<select class="widefat" id="<?php echo $this->get_field_id( 'post_type' ); ?>" name="<?php echo $this->get_field_name( 'post_type' ); ?>">
|
82 |
-
<?php foreach ( get_post_types( array( 'public' => true ), 'objects' ) as $post_type ) { ?>
|
83 |
-
<option value="<?php echo esc_attr( $post_type->name ); ?>" <?php selected( $instance['post_type'], $post_type->name ); ?>><?php echo esc_html( $post_type->labels->singular_name ); ?></option>
|
84 |
-
<?php } ?>
|
85 |
-
</select>
|
86 |
-
</p>
|
87 |
-
|
88 |
-
<p>
|
89 |
-
<label for="<?php echo $this->get_field_id( 'post_status' ); ?>">
|
90 |
-
<?php _e( 'Post status', 'arpw' ); ?>
|
91 |
-
</label>
|
92 |
-
<select class="widefat" id="<?php echo $this->get_field_id( 'post_status' ); ?>" name="<?php echo $this->get_field_name( 'post_status' ); ?>" style="width:100%;">
|
93 |
-
<?php foreach ( get_available_post_statuses() as $status_value => $status_label ) { ?>
|
94 |
-
<option value="<?php echo esc_attr( $status_label ); ?>" <?php selected( $instance['post_status'], $status_label ); ?>><?php echo esc_html( ucfirst( $status_label ) ); ?></option>
|
95 |
-
<?php } ?>
|
96 |
-
</select>
|
97 |
-
</p>
|
98 |
-
|
99 |
-
<div class="arpw-multiple-check-form">
|
100 |
-
<label>
|
101 |
-
<?php _e( 'Limit to Category', 'arpw' ); ?>
|
102 |
-
</label>
|
103 |
-
<ul>
|
104 |
-
<?php foreach ( get_terms( 'category' ) as $category ) : ?>
|
105 |
-
<li>
|
106 |
-
<input type="checkbox" value="<?php echo (int) $category->term_id; ?>" id="<?php echo $this->get_field_id( 'cat' ) . '-' . (int) $category->term_id; ?>" name="<?php echo $this->get_field_name( 'cat' ); ?>[]" <?php checked( is_array( $instance['cat'] ) && in_array( $category->term_id, $instance['cat'] ) ); ?> />
|
107 |
-
<label for="<?php echo $this->get_field_id( 'cat' ) . '-' . (int) $category->term_id; ?>">
|
108 |
-
<?php echo esc_html( $category->name ); ?>
|
109 |
-
</label>
|
110 |
-
</li>
|
111 |
-
<?php endforeach; ?>
|
112 |
-
</ul>
|
113 |
-
</div>
|
114 |
-
|
115 |
-
<div class="arpw-multiple-check-form">
|
116 |
-
<label>
|
117 |
-
<?php _e( 'Limit to Tag', 'arpw' ); ?>
|
118 |
-
</label>
|
119 |
-
<ul>
|
120 |
-
<?php foreach ( get_terms( 'post_tag' ) as $post_tag ) : ?>
|
121 |
-
<li>
|
122 |
-
<input type="checkbox" value="<?php echo (int) $post_tag->term_id; ?>" id="<?php echo $this->get_field_id( 'tag' ) . '-' . (int) $post_tag->term_id; ?>" name="<?php echo $this->get_field_name( 'tag' ); ?>[]" <?php checked( is_array( $instance['tag'] ) && in_array( $post_tag->term_id, $instance['tag'] ) ); ?> />
|
123 |
-
<label for="<?php echo $this->get_field_id( 'tag' ) . '-' . (int) $post_tag->term_id; ?>">
|
124 |
-
<?php echo esc_html( $post_tag->name ); ?>
|
125 |
-
</label>
|
126 |
-
</li>
|
127 |
-
<?php endforeach; ?>
|
128 |
-
</ul>
|
129 |
-
</div>
|
130 |
-
|
131 |
-
<p>
|
132 |
-
<label for="<?php echo $this->get_field_id( 'taxonomy' ); ?>">
|
133 |
-
<?php _e( 'Limit to Taxonomy', 'arpw' ); ?>
|
134 |
-
</label>
|
135 |
-
<input type="text" class="widefat" id="<?php echo $this->get_field_id( 'taxonomy' ); ?>" name="<?php echo $this->get_field_name( 'taxonomy' ); ?>" value="<?php echo esc_attr( $instance['taxonomy'] ); ?>" />
|
136 |
-
<small><?php _e( 'Ex: category=1,2,4&post_tag=6,12', 'arpw' );?><br />
|
137 |
-
<?php _e( 'Available: ', 'arpw' ); echo implode( ', ', get_taxonomies( array( 'public' => true ) ) ); ?></small>
|
138 |
-
</p>
|
139 |
-
|
140 |
-
</div>
|
141 |
-
|
142 |
-
<div class="arpw-columns-3 arpw-column-last">
|
143 |
-
|
144 |
-
<?php // Check if the theme support Post Thumbnail feature. ?>
|
145 |
-
<?php if ( current_theme_supports( 'post-thumbnails' ) ) : ?>
|
146 |
-
|
147 |
-
<p>
|
148 |
-
<input class="checkbox" type="checkbox" <?php checked( $instance['thumbnail'] ); ?> id="<?php echo $this->get_field_id( 'thumbnail' ); ?>" name="<?php echo $this->get_field_name( 'thumbnail' ); ?>" />
|
149 |
-
<label for="<?php echo $this->get_field_id( 'thumbnail' ); ?>">
|
150 |
-
<?php _e( 'Display thumbnail', 'arpw' ); ?>
|
151 |
-
</label>
|
152 |
-
</p>
|
153 |
-
|
154 |
-
<p>
|
155 |
-
<label for="<?php echo $this->get_field_id( 'thumbnail_size' ); ?>">
|
156 |
-
<?php _e( 'Thumbnail Size ', 'arpw' ); ?>
|
157 |
-
</label>
|
158 |
-
<select class="widefat" id="<?php echo $this->get_field_id( 'thumbnail_size' ); ?>" name="<?php echo $this->get_field_name( 'thumbnail_size' ); ?>" style="width:100%;">
|
159 |
-
<?php foreach ( get_intermediate_image_sizes() as $size ) { ?>
|
160 |
-
<option value="<?php echo esc_attr( $size ); ?>" <?php selected( $instance['thumbnail_size'], $size ); ?>><?php echo esc_html( $size ); ?></option>
|
161 |
-
<?php } ?>
|
162 |
-
</select>
|
163 |
-
<small><?php printf( __( 'Please read %1$sFAQ%2$s for more information.', 'arpw' ), '<a href="http://wordpress.org/plugins/advanced-random-posts-widget/faq/" target="_blank">', '</a>' ); ?></small>
|
164 |
-
</p>
|
165 |
-
|
166 |
-
<p>
|
167 |
-
<input class="checkbox" type="checkbox" <?php checked( $instance['thumbnail_custom'] ); ?> id="<?php echo $this->get_field_id( 'thumbnail_custom' ); ?>" name="<?php echo $this->get_field_name( 'thumbnail_custom' ); ?>" />
|
168 |
-
<label for="<?php echo $this->get_field_id( 'thumbnail_custom' ); ?>">
|
169 |
-
<?php _e( 'Use custom thumbnail sizes', 'arpw' ); ?>
|
170 |
-
</label>
|
171 |
-
</p>
|
172 |
-
|
173 |
-
<p>
|
174 |
-
<label class="arpw-block" for="<?php echo $this->get_field_id( 'thumbnail_width' ); ?>">
|
175 |
-
<?php _e( 'Width & Height', 'arpw' ); ?>
|
176 |
-
</label>
|
177 |
-
<input class="arpw-input-half" id="<?php echo $this->get_field_id( 'thumbnail_width' ); ?>" name="<?php echo $this->get_field_name( 'thumbnail_width' ); ?>" type="number" step="1" min="0" value="<?php echo (int)( $instance['thumbnail_width'] ); ?>" />
|
178 |
-
<input class="arpw-input-half" id="<?php echo $this->get_field_id( 'thumbnail_height' ); ?>" name="<?php echo $this->get_field_name( 'thumbnail_height' ); ?>" type="number" step="1" min="0" value="<?php echo (int)( $instance['thumbnail_height'] ); ?>" />
|
179 |
-
</p>
|
180 |
-
|
181 |
-
<p>
|
182 |
-
<label for="<?php echo $this->get_field_id( 'thumbnail_align' ); ?>">
|
183 |
-
<?php _e( 'Thumbnail Alignment', 'arpw' ); ?>
|
184 |
-
</label>
|
185 |
-
<select class="widefat" id="<?php echo $this->get_field_id( 'thumbnail_align' ); ?>" name="<?php echo $this->get_field_name( 'thumbnail_align' ); ?>" style="width:100%;">
|
186 |
-
<option value="left" <?php selected( $instance['thumbnail_align'], 'left' ); ?>><?php _e( 'Left', 'arpw' ) ?></option>
|
187 |
-
<option value="right" <?php selected( $instance['thumbnail_align'], 'right' ); ?>><?php _e( 'Right', 'arpw' ) ?></option>
|
188 |
-
<option value="center" <?php selected( $instance['thumbnail_align'], 'center' ); ?>><?php _e( 'Center', 'arpw' ) ?></option>
|
189 |
-
</select>
|
190 |
-
</p>
|
191 |
-
|
192 |
-
<?php endif; ?>
|
193 |
-
|
194 |
-
<p>
|
195 |
-
<input class="checkbox" type="checkbox" <?php checked( $instance['excerpt'] ); ?> id="<?php echo $this->get_field_id( 'excerpt' ); ?>" name="<?php echo $this->get_field_name( 'excerpt' ); ?>" />
|
196 |
-
<label for="<?php echo $this->get_field_id( 'excerpt' ); ?>">
|
197 |
-
<?php _e( 'Display excerpt', 'arpw' ); ?>
|
198 |
-
</label>
|
199 |
-
</p>
|
200 |
-
|
201 |
-
<p>
|
202 |
-
<label for="<?php echo $this->get_field_id( 'excerpt_length' ); ?>">
|
203 |
-
<?php _e( 'Excerpt Length', 'arpw' ); ?>
|
204 |
-
</label>
|
205 |
-
<input class="widefat" id="<?php echo $this->get_field_id( 'excerpt_length' ); ?>" name="<?php echo $this->get_field_name( 'excerpt_length' ); ?>" type="number" step="1" min="0" value="<?php echo (int)( $instance['excerpt_length'] ); ?>" />
|
206 |
-
</p>
|
207 |
-
|
208 |
-
<p>
|
209 |
-
<input class="checkbox" type="checkbox" <?php checked( $instance['date'] ); ?> id="<?php echo $this->get_field_id( 'date' ); ?>" name="<?php echo $this->get_field_name( 'date' ); ?>" />
|
210 |
-
<label for="<?php echo $this->get_field_id( 'date' ); ?>">
|
211 |
-
<?php _e( 'Display Date', 'arpw' ); ?>
|
212 |
-
</label>
|
213 |
-
</p>
|
214 |
-
|
215 |
-
<p>
|
216 |
-
<input id="<?php echo $this->get_field_id( 'date_relative' ); ?>" name="<?php echo $this->get_field_name( 'date_relative' ); ?>" type="checkbox" <?php checked( $instance['date_relative'] ); ?> />
|
217 |
-
<label for="<?php echo $this->get_field_id( 'date_relative' ); ?>">
|
218 |
-
<?php _e( 'Use Relative Date. eg: 5 days ago', 'arpw' ); ?>
|
219 |
-
</label>
|
220 |
-
</p>
|
221 |
-
|
222 |
-
</div>
|
223 |
-
|
224 |
<div class="clear"></div>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Widget forms.
|
4 |
+
*
|
5 |
+
* @package Advanced_Random_Posts_Widget
|
6 |
+
* @since 0.0.1
|
7 |
+
* @author Satrya
|
8 |
+
* @copyright Copyright (c) 2014, Satrya
|
9 |
+
* @license http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
+
*/
|
11 |
+
?>
|
12 |
+
|
13 |
+
<div class="arpw-columns-3">
|
14 |
+
|
15 |
+
<p>
|
16 |
+
<label for="<?php echo $this->get_field_id( 'title' ); ?>">
|
17 |
+
<?php _e( 'Title', 'arpw' ); ?>
|
18 |
+
</label>
|
19 |
+
<input type="text" class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo esc_attr( $instance['title'] ); ?>" />
|
20 |
+
</p>
|
21 |
+
|
22 |
+
<p>
|
23 |
+
<label for="<?php echo $this->get_field_id( 'title_url' ); ?>">
|
24 |
+
<?php _e( 'Title URL', 'arpw' ); ?>
|
25 |
+
</label>
|
26 |
+
<input type="text" class="widefat" id="<?php echo $this->get_field_id( 'title_url' ); ?>" name="<?php echo $this->get_field_name( 'title_url' ); ?>" value="<?php echo esc_url( $instance['title_url'] ); ?>" placeholder="<?php echo esc_attr( 'http://' ); ?>" />
|
27 |
+
</p>
|
28 |
+
|
29 |
+
<p>
|
30 |
+
<label for="<?php echo $this->get_field_id( 'css_class' ); ?>">
|
31 |
+
<?php _e( 'CSS Class', 'arpw' ); ?>
|
32 |
+
</label>
|
33 |
+
<input type="text" class="widefat" id="<?php echo $this->get_field_id( 'css_class' ); ?>" name="<?php echo $this->get_field_name( 'css_class' ); ?>" value="<?php echo sanitize_html_class( $instance['css_class'] ); ?>" />
|
34 |
+
</p>
|
35 |
+
|
36 |
+
<p>
|
37 |
+
<label for="<?php echo $this->get_field_id( 'before' ); ?>">
|
38 |
+
<?php _e( 'HTML or text before the random posts', 'arpw' );?>
|
39 |
+
</label>
|
40 |
+
<textarea class="widefat" id="<?php echo $this->get_field_id( 'before' ); ?>" name="<?php echo $this->get_field_name( 'before' ); ?>" rows="5"><?php echo htmlspecialchars( stripslashes( $instance['before'] ) ); ?></textarea>
|
41 |
+
</p>
|
42 |
+
|
43 |
+
<p>
|
44 |
+
<label for="<?php echo $this->get_field_id( 'after' ); ?>">
|
45 |
+
<?php _e( 'HTML or text after the random posts', 'arpw' );?>
|
46 |
+
</label>
|
47 |
+
<textarea class="widefat" id="<?php echo $this->get_field_id( 'after' ); ?>" name="<?php echo $this->get_field_name( 'after' ); ?>" rows="5"><?php echo htmlspecialchars( stripslashes( $instance['after'] ) ); ?></textarea>
|
48 |
+
</p>
|
49 |
+
|
50 |
+
</div>
|
51 |
+
|
52 |
+
<div class="arpw-columns-3">
|
53 |
+
|
54 |
+
<p>
|
55 |
+
<input class="checkbox" type="checkbox" <?php checked( $instance['ignore_sticky'], 1 ); ?> id="<?php echo $this->get_field_id( 'ignore_sticky' ); ?>" name="<?php echo $this->get_field_name( 'ignore_sticky' ); ?>" />
|
56 |
+
<label for="<?php echo $this->get_field_id( 'ignore_sticky' ); ?>">
|
57 |
+
<?php _e( 'Ignore sticky posts', 'arpw' ); ?>
|
58 |
+
</label>
|
59 |
+
</p>
|
60 |
+
|
61 |
+
<p>
|
62 |
+
<label for="<?php echo $this->get_field_id( 'limit' ); ?>">
|
63 |
+
<?php _e( 'Number of posts to show', 'arpw' ); ?>
|
64 |
+
</label>
|
65 |
+
<input class="widefat" id="<?php echo $this->get_field_id( 'limit' ); ?>" name="<?php echo $this->get_field_name( 'limit' ); ?>" type="number" step="1" min="-1" value="<?php echo (int) $instance['limit']; ?>" />
|
66 |
+
<small>-1 <?php _e( 'to show all posts.', 'arpw' ); ?></small>
|
67 |
+
</p>
|
68 |
+
|
69 |
+
<p>
|
70 |
+
<label for="<?php echo $this->get_field_id( 'offset' ); ?>">
|
71 |
+
<?php _e( 'Offset', 'arpw' ); ?>
|
72 |
+
</label>
|
73 |
+
<input type="number" step="1" min="0" class="widefat" id="<?php echo $this->get_field_id( 'offset' ); ?>" name="<?php echo $this->get_field_name( 'offset' ); ?>" value="<?php echo (int) $instance['offset']; ?>" />
|
74 |
+
<small><?php _e( 'The number of posts to skip', 'arpw' ); ?></small>
|
75 |
+
</p>
|
76 |
+
|
77 |
+
<p>
|
78 |
+
<label for="<?php echo $this->get_field_id( 'post_type' ); ?>">
|
79 |
+
<?php _e( 'Post type', 'arpw' ); ?>
|
80 |
+
</label>
|
81 |
+
<select class="widefat" id="<?php echo $this->get_field_id( 'post_type' ); ?>" name="<?php echo $this->get_field_name( 'post_type' ); ?>">
|
82 |
+
<?php foreach ( get_post_types( array( 'public' => true ), 'objects' ) as $post_type ) { ?>
|
83 |
+
<option value="<?php echo esc_attr( $post_type->name ); ?>" <?php selected( $instance['post_type'], $post_type->name ); ?>><?php echo esc_html( $post_type->labels->singular_name ); ?></option>
|
84 |
+
<?php } ?>
|
85 |
+
</select>
|
86 |
+
</p>
|
87 |
+
|
88 |
+
<p>
|
89 |
+
<label for="<?php echo $this->get_field_id( 'post_status' ); ?>">
|
90 |
+
<?php _e( 'Post status', 'arpw' ); ?>
|
91 |
+
</label>
|
92 |
+
<select class="widefat" id="<?php echo $this->get_field_id( 'post_status' ); ?>" name="<?php echo $this->get_field_name( 'post_status' ); ?>" style="width:100%;">
|
93 |
+
<?php foreach ( get_available_post_statuses() as $status_value => $status_label ) { ?>
|
94 |
+
<option value="<?php echo esc_attr( $status_label ); ?>" <?php selected( $instance['post_status'], $status_label ); ?>><?php echo esc_html( ucfirst( $status_label ) ); ?></option>
|
95 |
+
<?php } ?>
|
96 |
+
</select>
|
97 |
+
</p>
|
98 |
+
|
99 |
+
<div class="arpw-multiple-check-form">
|
100 |
+
<label>
|
101 |
+
<?php _e( 'Limit to Category', 'arpw' ); ?>
|
102 |
+
</label>
|
103 |
+
<ul>
|
104 |
+
<?php foreach ( get_terms( 'category' ) as $category ) : ?>
|
105 |
+
<li>
|
106 |
+
<input type="checkbox" value="<?php echo (int) $category->term_id; ?>" id="<?php echo $this->get_field_id( 'cat' ) . '-' . (int) $category->term_id; ?>" name="<?php echo $this->get_field_name( 'cat' ); ?>[]" <?php checked( is_array( $instance['cat'] ) && in_array( $category->term_id, $instance['cat'] ) ); ?> />
|
107 |
+
<label for="<?php echo $this->get_field_id( 'cat' ) . '-' . (int) $category->term_id; ?>">
|
108 |
+
<?php echo esc_html( $category->name ); ?>
|
109 |
+
</label>
|
110 |
+
</li>
|
111 |
+
<?php endforeach; ?>
|
112 |
+
</ul>
|
113 |
+
</div>
|
114 |
+
|
115 |
+
<div class="arpw-multiple-check-form">
|
116 |
+
<label>
|
117 |
+
<?php _e( 'Limit to Tag', 'arpw' ); ?>
|
118 |
+
</label>
|
119 |
+
<ul>
|
120 |
+
<?php foreach ( get_terms( 'post_tag' ) as $post_tag ) : ?>
|
121 |
+
<li>
|
122 |
+
<input type="checkbox" value="<?php echo (int) $post_tag->term_id; ?>" id="<?php echo $this->get_field_id( 'tag' ) . '-' . (int) $post_tag->term_id; ?>" name="<?php echo $this->get_field_name( 'tag' ); ?>[]" <?php checked( is_array( $instance['tag'] ) && in_array( $post_tag->term_id, $instance['tag'] ) ); ?> />
|
123 |
+
<label for="<?php echo $this->get_field_id( 'tag' ) . '-' . (int) $post_tag->term_id; ?>">
|
124 |
+
<?php echo esc_html( $post_tag->name ); ?>
|
125 |
+
</label>
|
126 |
+
</li>
|
127 |
+
<?php endforeach; ?>
|
128 |
+
</ul>
|
129 |
+
</div>
|
130 |
+
|
131 |
+
<p>
|
132 |
+
<label for="<?php echo $this->get_field_id( 'taxonomy' ); ?>">
|
133 |
+
<?php _e( 'Limit to Taxonomy', 'arpw' ); ?>
|
134 |
+
</label>
|
135 |
+
<input type="text" class="widefat" id="<?php echo $this->get_field_id( 'taxonomy' ); ?>" name="<?php echo $this->get_field_name( 'taxonomy' ); ?>" value="<?php echo esc_attr( $instance['taxonomy'] ); ?>" />
|
136 |
+
<small><?php _e( 'Ex: category=1,2,4&post_tag=6,12', 'arpw' );?><br />
|
137 |
+
<?php _e( 'Available: ', 'arpw' ); echo implode( ', ', get_taxonomies( array( 'public' => true ) ) ); ?></small>
|
138 |
+
</p>
|
139 |
+
|
140 |
+
</div>
|
141 |
+
|
142 |
+
<div class="arpw-columns-3 arpw-column-last">
|
143 |
+
|
144 |
+
<?php // Check if the theme support Post Thumbnail feature. ?>
|
145 |
+
<?php if ( current_theme_supports( 'post-thumbnails' ) ) : ?>
|
146 |
+
|
147 |
+
<p>
|
148 |
+
<input class="checkbox" type="checkbox" <?php checked( $instance['thumbnail'] ); ?> id="<?php echo $this->get_field_id( 'thumbnail' ); ?>" name="<?php echo $this->get_field_name( 'thumbnail' ); ?>" />
|
149 |
+
<label for="<?php echo $this->get_field_id( 'thumbnail' ); ?>">
|
150 |
+
<?php _e( 'Display thumbnail', 'arpw' ); ?>
|
151 |
+
</label>
|
152 |
+
</p>
|
153 |
+
|
154 |
+
<p>
|
155 |
+
<label for="<?php echo $this->get_field_id( 'thumbnail_size' ); ?>">
|
156 |
+
<?php _e( 'Thumbnail Size ', 'arpw' ); ?>
|
157 |
+
</label>
|
158 |
+
<select class="widefat" id="<?php echo $this->get_field_id( 'thumbnail_size' ); ?>" name="<?php echo $this->get_field_name( 'thumbnail_size' ); ?>" style="width:100%;">
|
159 |
+
<?php foreach ( get_intermediate_image_sizes() as $size ) { ?>
|
160 |
+
<option value="<?php echo esc_attr( $size ); ?>" <?php selected( $instance['thumbnail_size'], $size ); ?>><?php echo esc_html( $size ); ?></option>
|
161 |
+
<?php } ?>
|
162 |
+
</select>
|
163 |
+
<small><?php printf( __( 'Please read %1$sFAQ%2$s for more information.', 'arpw' ), '<a href="http://wordpress.org/plugins/advanced-random-posts-widget/faq/" target="_blank">', '</a>' ); ?></small>
|
164 |
+
</p>
|
165 |
+
|
166 |
+
<p>
|
167 |
+
<input class="checkbox" type="checkbox" <?php checked( $instance['thumbnail_custom'] ); ?> id="<?php echo $this->get_field_id( 'thumbnail_custom' ); ?>" name="<?php echo $this->get_field_name( 'thumbnail_custom' ); ?>" />
|
168 |
+
<label for="<?php echo $this->get_field_id( 'thumbnail_custom' ); ?>">
|
169 |
+
<?php _e( 'Use custom thumbnail sizes', 'arpw' ); ?>
|
170 |
+
</label>
|
171 |
+
</p>
|
172 |
+
|
173 |
+
<p>
|
174 |
+
<label class="arpw-block" for="<?php echo $this->get_field_id( 'thumbnail_width' ); ?>">
|
175 |
+
<?php _e( 'Width & Height', 'arpw' ); ?>
|
176 |
+
</label>
|
177 |
+
<input class="arpw-input-half" id="<?php echo $this->get_field_id( 'thumbnail_width' ); ?>" name="<?php echo $this->get_field_name( 'thumbnail_width' ); ?>" type="number" step="1" min="0" value="<?php echo (int)( $instance['thumbnail_width'] ); ?>" />
|
178 |
+
<input class="arpw-input-half" id="<?php echo $this->get_field_id( 'thumbnail_height' ); ?>" name="<?php echo $this->get_field_name( 'thumbnail_height' ); ?>" type="number" step="1" min="0" value="<?php echo (int)( $instance['thumbnail_height'] ); ?>" />
|
179 |
+
</p>
|
180 |
+
|
181 |
+
<p>
|
182 |
+
<label for="<?php echo $this->get_field_id( 'thumbnail_align' ); ?>">
|
183 |
+
<?php _e( 'Thumbnail Alignment', 'arpw' ); ?>
|
184 |
+
</label>
|
185 |
+
<select class="widefat" id="<?php echo $this->get_field_id( 'thumbnail_align' ); ?>" name="<?php echo $this->get_field_name( 'thumbnail_align' ); ?>" style="width:100%;">
|
186 |
+
<option value="left" <?php selected( $instance['thumbnail_align'], 'left' ); ?>><?php _e( 'Left', 'arpw' ) ?></option>
|
187 |
+
<option value="right" <?php selected( $instance['thumbnail_align'], 'right' ); ?>><?php _e( 'Right', 'arpw' ) ?></option>
|
188 |
+
<option value="center" <?php selected( $instance['thumbnail_align'], 'center' ); ?>><?php _e( 'Center', 'arpw' ) ?></option>
|
189 |
+
</select>
|
190 |
+
</p>
|
191 |
+
|
192 |
+
<?php endif; ?>
|
193 |
+
|
194 |
+
<p>
|
195 |
+
<input class="checkbox" type="checkbox" <?php checked( $instance['excerpt'] ); ?> id="<?php echo $this->get_field_id( 'excerpt' ); ?>" name="<?php echo $this->get_field_name( 'excerpt' ); ?>" />
|
196 |
+
<label for="<?php echo $this->get_field_id( 'excerpt' ); ?>">
|
197 |
+
<?php _e( 'Display excerpt', 'arpw' ); ?>
|
198 |
+
</label>
|
199 |
+
</p>
|
200 |
+
|
201 |
+
<p>
|
202 |
+
<label for="<?php echo $this->get_field_id( 'excerpt_length' ); ?>">
|
203 |
+
<?php _e( 'Excerpt Length', 'arpw' ); ?>
|
204 |
+
</label>
|
205 |
+
<input class="widefat" id="<?php echo $this->get_field_id( 'excerpt_length' ); ?>" name="<?php echo $this->get_field_name( 'excerpt_length' ); ?>" type="number" step="1" min="0" value="<?php echo (int)( $instance['excerpt_length'] ); ?>" />
|
206 |
+
</p>
|
207 |
+
|
208 |
+
<p>
|
209 |
+
<input class="checkbox" type="checkbox" <?php checked( $instance['date'] ); ?> id="<?php echo $this->get_field_id( 'date' ); ?>" name="<?php echo $this->get_field_name( 'date' ); ?>" />
|
210 |
+
<label for="<?php echo $this->get_field_id( 'date' ); ?>">
|
211 |
+
<?php _e( 'Display Date', 'arpw' ); ?>
|
212 |
+
</label>
|
213 |
+
</p>
|
214 |
+
|
215 |
+
<p>
|
216 |
+
<input id="<?php echo $this->get_field_id( 'date_relative' ); ?>" name="<?php echo $this->get_field_name( 'date_relative' ); ?>" type="checkbox" <?php checked( $instance['date_relative'] ); ?> />
|
217 |
+
<label for="<?php echo $this->get_field_id( 'date_relative' ); ?>">
|
218 |
+
<?php _e( 'Use Relative Date. eg: 5 days ago', 'arpw' ); ?>
|
219 |
+
</label>
|
220 |
+
</p>
|
221 |
+
|
222 |
+
</div>
|
223 |
+
|
224 |
<div class="clear"></div>
|
includes/functions.php
CHANGED
@@ -1,239 +1,241 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Various functions used by the plugin.
|
4 |
-
*
|
5 |
-
* @package Advanced_Random_Posts_Widget
|
6 |
-
* @since 0.0.1
|
7 |
-
* @author Satrya
|
8 |
-
* @copyright Copyright (c) 2014, Satrya
|
9 |
-
* @license http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
-
*/
|
11 |
-
|
12 |
-
/**
|
13 |
-
* Sets up the default arguments.
|
14 |
-
*
|
15 |
-
* @since 0.0.1
|
16 |
-
*/
|
17 |
-
function arpw_get_default_args() {
|
18 |
-
|
19 |
-
$defaults = array(
|
20 |
-
'title' => esc_attr__( 'Random Posts', 'arpw' ),
|
21 |
-
'title_url' => '',
|
22 |
-
|
23 |
-
'offset' => 0,
|
24 |
-
'limit' => 5,
|
25 |
-
'orderby' => 'rand',
|
26 |
-
'post_type' => 'post',
|
27 |
-
'post_status' => 'publish',
|
28 |
-
'ignore_sticky' => 1,
|
29 |
-
'taxonomy' => '',
|
30 |
-
'cat' => array(),
|
31 |
-
'tag' => array(),
|
32 |
-
|
33 |
-
'thumbnail' => false,
|
34 |
-
'thumbnail_size' => 'arpw-thumbnail',
|
35 |
-
'thumbnail_align' => 'left',
|
36 |
-
'thumbnail_custom' => false,
|
37 |
-
'thumbnail_width' => '',
|
38 |
-
'thumbnail_height' => '',
|
39 |
-
|
40 |
-
'excerpt' => false,
|
41 |
-
'excerpt_length' => 10,
|
42 |
-
'date' => false,
|
43 |
-
'date_relative' => false,
|
44 |
-
|
45 |
-
'css_class' => '',
|
46 |
-
'before' => '',
|
47 |
-
'after' => ''
|
48 |
-
);
|
49 |
-
|
50 |
-
// Allow plugins/themes developer to filter the default arguments.
|
51 |
-
return apply_filters( 'arpw_default_args', $defaults );
|
52 |
-
|
53 |
-
}
|
54 |
-
|
55 |
-
/**
|
56 |
-
* Outputs the random posts.
|
57 |
-
*
|
58 |
-
* @since 0.0.1
|
59 |
-
*/
|
60 |
-
function arpw_random_posts( $args = array() ) {
|
61 |
-
echo arpw_get_random_posts( $args );
|
62 |
-
}
|
63 |
-
|
64 |
-
/**
|
65 |
-
* Generates the random posts markup.
|
66 |
-
*
|
67 |
-
* @since 0.0.1
|
68 |
-
* @param array $args
|
69 |
-
* @return string|array The HTML for the random posts.
|
70 |
-
*/
|
71 |
-
function arpw_get_random_posts( $args = array() ) {
|
72 |
-
|
73 |
-
// Set up a default, empty $html variable.
|
74 |
-
$html = '';
|
75 |
-
|
76 |
-
// Get the default arguments.
|
77 |
-
$defaults = arpw_get_default_args();
|
78 |
-
|
79 |
-
// Merge the input arguments and the defaults.
|
80 |
-
$args = wp_parse_args( $args, $defaults );
|
81 |
-
|
82 |
-
// Extract the array to allow easy use of variables.
|
83 |
-
extract( $args );
|
84 |
-
|
85 |
-
// Allow devs to hook in stuff before the loop.
|
86 |
-
do_action( 'arpw_before_loop' );
|
87 |
-
|
88 |
-
// Get the posts query.
|
89 |
-
$posts = arpw_get_posts( $args );
|
90 |
-
|
91 |
-
if ( $posts->have_posts() ) :
|
92 |
-
|
93 |
-
$html = '<div id="arpw-random-posts" class="arpw-random-' . sanitize_html_class( $args['post_type'] ) . ' ' . sanitize_html_class( $args['css_class'] ) . '">';
|
94 |
-
|
95 |
-
$html .= '<ul class="arpw-ul">';
|
96 |
-
|
97 |
-
while ( $posts->have_posts() ) : $posts->the_post();
|
98 |
-
|
99 |
-
$html .= '<li class="arpw-li arpw-clearfix">';
|
100 |
-
|
101 |
-
if ( $args['thumbnail'] ) :
|
102 |
-
|
103 |
-
// Check if post has post thumbnail.
|
104 |
-
if ( has_post_thumbnail() ) :
|
105 |
-
|
106 |
-
// Custom thumbnail sizes.
|
107 |
-
$thumb_id = get_post_thumbnail_id(); // Get the featured image id.
|
108 |
-
$img_url = wp_get_attachment_url( $thumb_id ); // Get img URL.
|
109 |
-
$image = arpw_resize( $img_url, $args['thumbnail_width'], $args['thumbnail_height'], true );
|
110 |
-
|
111 |
-
$html .= '<a href="' . esc_url( get_permalink() ) . '" rel="bookmark">';
|
112 |
-
if ( $args['thumbnail_custom'] ) :
|
113 |
-
$html .= '<img class="arpw-thumbnail align' . esc_attr( $args['thumbnail_align'] ) . '" src="' . esc_url( $image ) . '" alt="' . esc_attr( get_the_title() ) . '">';
|
114 |
-
else :
|
115 |
-
$html .= get_the_post_thumbnail( get_the_ID(), $args['thumbnail_size'], array( 'alt' => esc_attr( get_the_title() ), 'class' => 'arpw-thumbnail align' . esc_attr( $args['thumbnail_align'] ) ) );
|
116 |
-
endif;
|
117 |
-
$html .= '</a>';
|
118 |
-
|
119 |
-
// If no post thumbnail found, check if Get The Image plugin exist and display the image.
|
120 |
-
elseif ( function_exists( 'get_the_image' ) ) :
|
121 |
-
if ( $args['thumbnail_custom'] ) :
|
122 |
-
$html .= get_the_image( array(
|
123 |
-
'width' => (int) $args['thumbnail_width'],
|
124 |
-
'height' => (int) $args['thumbnail_height'],
|
125 |
-
'image_class' => 'arpw-thumbnail align' . esc_attr( $args['thumbnail_align'] ),
|
126 |
-
'image_scan' => true,
|
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 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
*
|
184 |
-
*
|
185 |
-
* @
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
'
|
194 |
-
'
|
195 |
-
'
|
196 |
-
'
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
'
|
223 |
-
'
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
|
|
|
|
239 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Various functions used by the plugin.
|
4 |
+
*
|
5 |
+
* @package Advanced_Random_Posts_Widget
|
6 |
+
* @since 0.0.1
|
7 |
+
* @author Satrya
|
8 |
+
* @copyright Copyright (c) 2014, Satrya
|
9 |
+
* @license http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Sets up the default arguments.
|
14 |
+
*
|
15 |
+
* @since 0.0.1
|
16 |
+
*/
|
17 |
+
function arpw_get_default_args() {
|
18 |
+
|
19 |
+
$defaults = array(
|
20 |
+
'title' => esc_attr__( 'Random Posts', 'arpw' ),
|
21 |
+
'title_url' => '',
|
22 |
+
|
23 |
+
'offset' => 0,
|
24 |
+
'limit' => 5,
|
25 |
+
'orderby' => 'rand',
|
26 |
+
'post_type' => 'post',
|
27 |
+
'post_status' => 'publish',
|
28 |
+
'ignore_sticky' => 1,
|
29 |
+
'taxonomy' => '',
|
30 |
+
'cat' => array(),
|
31 |
+
'tag' => array(),
|
32 |
+
|
33 |
+
'thumbnail' => false,
|
34 |
+
'thumbnail_size' => 'arpw-thumbnail',
|
35 |
+
'thumbnail_align' => 'left',
|
36 |
+
'thumbnail_custom' => false,
|
37 |
+
'thumbnail_width' => '',
|
38 |
+
'thumbnail_height' => '',
|
39 |
+
|
40 |
+
'excerpt' => false,
|
41 |
+
'excerpt_length' => 10,
|
42 |
+
'date' => false,
|
43 |
+
'date_relative' => false,
|
44 |
+
|
45 |
+
'css_class' => '',
|
46 |
+
'before' => '',
|
47 |
+
'after' => ''
|
48 |
+
);
|
49 |
+
|
50 |
+
// Allow plugins/themes developer to filter the default arguments.
|
51 |
+
return apply_filters( 'arpw_default_args', $defaults );
|
52 |
+
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Outputs the random posts.
|
57 |
+
*
|
58 |
+
* @since 0.0.1
|
59 |
+
*/
|
60 |
+
function arpw_random_posts( $args = array() ) {
|
61 |
+
echo arpw_get_random_posts( $args );
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* Generates the random posts markup.
|
66 |
+
*
|
67 |
+
* @since 0.0.1
|
68 |
+
* @param array $args
|
69 |
+
* @return string|array The HTML for the random posts.
|
70 |
+
*/
|
71 |
+
function arpw_get_random_posts( $args = array() ) {
|
72 |
+
|
73 |
+
// Set up a default, empty $html variable.
|
74 |
+
$html = '';
|
75 |
+
|
76 |
+
// Get the default arguments.
|
77 |
+
$defaults = arpw_get_default_args();
|
78 |
+
|
79 |
+
// Merge the input arguments and the defaults.
|
80 |
+
$args = wp_parse_args( $args, $defaults );
|
81 |
+
|
82 |
+
// Extract the array to allow easy use of variables.
|
83 |
+
extract( $args );
|
84 |
+
|
85 |
+
// Allow devs to hook in stuff before the loop.
|
86 |
+
do_action( 'arpw_before_loop' );
|
87 |
+
|
88 |
+
// Get the posts query.
|
89 |
+
$posts = arpw_get_posts( $args );
|
90 |
+
|
91 |
+
if ( $posts->have_posts() ) :
|
92 |
+
|
93 |
+
$html = '<div id="arpw-random-posts" class="arpw-random-' . sanitize_html_class( $args['post_type'] ) . ' ' . sanitize_html_class( $args['css_class'] ) . '">';
|
94 |
+
|
95 |
+
$html .= '<ul class="arpw-ul">';
|
96 |
+
|
97 |
+
while ( $posts->have_posts() ) : $posts->the_post();
|
98 |
+
|
99 |
+
$html .= '<li class="arpw-li arpw-clearfix">';
|
100 |
+
|
101 |
+
if ( $args['thumbnail'] ) :
|
102 |
+
|
103 |
+
// Check if post has post thumbnail.
|
104 |
+
if ( has_post_thumbnail() ) :
|
105 |
+
|
106 |
+
// Custom thumbnail sizes.
|
107 |
+
$thumb_id = get_post_thumbnail_id(); // Get the featured image id.
|
108 |
+
$img_url = wp_get_attachment_url( $thumb_id ); // Get img URL.
|
109 |
+
$image = arpw_resize( $img_url, $args['thumbnail_width'], $args['thumbnail_height'], true );
|
110 |
+
|
111 |
+
$html .= '<a href="' . esc_url( get_permalink() ) . '" rel="bookmark">';
|
112 |
+
if ( $args['thumbnail_custom'] ) :
|
113 |
+
$html .= '<img class="arpw-thumbnail align' . esc_attr( $args['thumbnail_align'] ) . '" src="' . esc_url( $image ) . '" alt="' . esc_attr( get_the_title() ) . '">';
|
114 |
+
else :
|
115 |
+
$html .= get_the_post_thumbnail( get_the_ID(), $args['thumbnail_size'], array( 'alt' => esc_attr( get_the_title() ), 'class' => 'arpw-thumbnail align' . esc_attr( $args['thumbnail_align'] ) ) );
|
116 |
+
endif;
|
117 |
+
$html .= '</a>';
|
118 |
+
|
119 |
+
// If no post thumbnail found, check if Get The Image plugin exist and display the image.
|
120 |
+
elseif ( function_exists( 'get_the_image' ) ) :
|
121 |
+
if ( $args['thumbnail_custom'] ) :
|
122 |
+
$html .= get_the_image( array(
|
123 |
+
'width' => (int) $args['thumbnail_width'],
|
124 |
+
'height' => (int) $args['thumbnail_height'],
|
125 |
+
'image_class' => 'arpw-thumbnail align' . esc_attr( $args['thumbnail_align'] ),
|
126 |
+
'image_scan' => true,
|
127 |
+
'echo' => false,
|
128 |
+
'link_to_post' => true,
|
129 |
+
) );
|
130 |
+
else:
|
131 |
+
$html .= get_the_image( array(
|
132 |
+
'size' => $args['thumbnail_size'],
|
133 |
+
'image_class' => 'arpw-thumbnail align' . esc_attr( $args['thumbnail_align'] ),
|
134 |
+
'image_scan' => true,
|
135 |
+
'echo' => false,
|
136 |
+
'link_to_post' => true,
|
137 |
+
) );
|
138 |
+
endif;
|
139 |
+
|
140 |
+
// Display nothing.
|
141 |
+
else :
|
142 |
+
$html .= null;
|
143 |
+
endif;
|
144 |
+
|
145 |
+
endif;
|
146 |
+
|
147 |
+
$html .= '<a class="arpw-title" href="' . esc_url( get_permalink() ) . '" title="' . sprintf( esc_attr__( 'Permalink to %s', 'arpw' ), the_title_attribute( 'echo=0' ) ) . '" rel="bookmark">' . esc_attr( get_the_title() ) . '</a>';
|
148 |
+
|
149 |
+
if ( $args['date'] ) :
|
150 |
+
$date = get_the_date();
|
151 |
+
if ( $args['date_relative'] ) :
|
152 |
+
$date = sprintf( __( '%s ago', 'arpw' ), human_time_diff( get_the_date( 'U' ), current_time( 'timestamp' ) ) );
|
153 |
+
endif;
|
154 |
+
$html .= '<time class="arpw-time published" datetime="' . esc_html( get_the_date( 'c' ) ) . '">' . esc_html( $date ) . '</time>';
|
155 |
+
endif;
|
156 |
+
|
157 |
+
if ( $args['excerpt'] ) :
|
158 |
+
$html .= '<div class="arpw-summary">' . wp_trim_words( apply_filters( 'arpw_excerpt', get_the_excerpt() ), $args['excerpt_length'], ' …' ) . '</div>';
|
159 |
+
endif;
|
160 |
+
|
161 |
+
$html .= '</li>';
|
162 |
+
|
163 |
+
endwhile;
|
164 |
+
|
165 |
+
$html .= '</ul>';
|
166 |
+
|
167 |
+
$html .= '</div><!-- Generated by https://wordpress.org/plugins/advanced-random-posts-widget/ -->';
|
168 |
+
|
169 |
+
endif;
|
170 |
+
|
171 |
+
// Restore original Post Data.
|
172 |
+
wp_reset_postdata();
|
173 |
+
|
174 |
+
// Allow devs to hook in stuff after the loop.
|
175 |
+
do_action( 'arpw_after_loop' );
|
176 |
+
|
177 |
+
// Return the related posts markup.
|
178 |
+
return $args['before'] . $html . $args['after'];
|
179 |
+
|
180 |
+
}
|
181 |
+
|
182 |
+
/**
|
183 |
+
* The posts query.
|
184 |
+
*
|
185 |
+
* @since 0.0.1
|
186 |
+
* @param array $args
|
187 |
+
* @return array
|
188 |
+
*/
|
189 |
+
function arpw_get_posts( $args = array() ) {
|
190 |
+
|
191 |
+
// Query arguments.
|
192 |
+
$query = array(
|
193 |
+
'offset' => $args['offset'],
|
194 |
+
'posts_per_page' => $args['limit'],
|
195 |
+
'orderby' => $args['orderby'],
|
196 |
+
'post_type' => $args['post_type'],
|
197 |
+
'post_status' => $args['post_status'],
|
198 |
+
'ignore_sticky_posts' => $args['ignore_sticky'],
|
199 |
+
);
|
200 |
+
|
201 |
+
// Limit posts based on category.
|
202 |
+
if ( ! empty( $args['cat'] ) ) {
|
203 |
+
$query['category__in'] = $args['cat'];
|
204 |
+
}
|
205 |
+
|
206 |
+
// Limit posts based on post tag.
|
207 |
+
if ( ! empty( $args['tag'] ) ) {
|
208 |
+
$query['tag__in'] = $args['tag'];
|
209 |
+
}
|
210 |
+
|
211 |
+
/**
|
212 |
+
* Taxonomy query.
|
213 |
+
* Prop Miniloop plugin by Kailey Lampert.
|
214 |
+
*/
|
215 |
+
if ( ! empty( $args['taxonomy'] ) ) {
|
216 |
+
|
217 |
+
parse_str( $args['taxonomy'], $taxes );
|
218 |
+
$tax_query = array();
|
219 |
+
foreach( array_keys( $taxes ) as $k => $slug ) {
|
220 |
+
$ids = explode( ',', $taxes[ $slug ] );
|
221 |
+
$tax_query[] = array(
|
222 |
+
'taxonomy' => $slug,
|
223 |
+
'field' => 'id',
|
224 |
+
'terms' => $ids,
|
225 |
+
'operator' => 'IN'
|
226 |
+
);
|
227 |
+
}
|
228 |
+
|
229 |
+
$query['tax_query'] = $tax_query;
|
230 |
+
|
231 |
+
}
|
232 |
+
|
233 |
+
// Allow plugins/themes developer to filter the default query.
|
234 |
+
$query = apply_filters( 'arpw_query', $query );
|
235 |
+
|
236 |
+
// Perform the query.
|
237 |
+
$posts = new WP_Query( $query );
|
238 |
+
|
239 |
+
return $posts;
|
240 |
+
|
241 |
}
|
includes/resizer.php
CHANGED
@@ -1,209 +1,209 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Title : Aqua Resizer
|
5 |
-
* Description : Resizes WordPress images on the fly
|
6 |
-
* Version : 1.2.0
|
7 |
-
* Author : Syamil MJ
|
8 |
-
* Author URI : http://aquagraphite.com
|
9 |
-
* License : WTFPL - http://sam.zoy.org/wtfpl/
|
10 |
-
* Documentation : https://github.com/sy4mil/Aqua-Resizer/
|
11 |
-
*
|
12 |
-
* I changed the function and class name for compatibility purpose. It somtimes conflicted with a theme which uses the same library.
|
13 |
-
*
|
14 |
-
* @param string $url - (required) must be uploaded using wp media uploader
|
15 |
-
* @param int $width - (required)
|
16 |
-
* @param int $height - (optional)
|
17 |
-
* @param bool $crop - (optional) default to soft crop
|
18 |
-
* @param bool $single - (optional) returns an array if false
|
19 |
-
* @param bool $upscale - (optional) resizes smaller images
|
20 |
-
* @uses wp_upload_dir()
|
21 |
-
* @uses image_resize_dimensions()
|
22 |
-
* @uses wp_get_image_editor()
|
23 |
-
*
|
24 |
-
* @return str|array
|
25 |
-
*/
|
26 |
-
|
27 |
-
if(!class_exists('Arpw_Resize')) {
|
28 |
-
class Arpw_Resize
|
29 |
-
{
|
30 |
-
/**
|
31 |
-
* The singleton instance
|
32 |
-
*/
|
33 |
-
static private $instance = null;
|
34 |
-
|
35 |
-
/**
|
36 |
-
* No initialization allowed
|
37 |
-
*/
|
38 |
-
private function __construct() {}
|
39 |
-
|
40 |
-
/**
|
41 |
-
* No cloning allowed
|
42 |
-
*/
|
43 |
-
private function __clone() {}
|
44 |
-
|
45 |
-
/**
|
46 |
-
* For your custom default usage you may want to initialize an Arpw_Resize object by yourself and then have own defaults
|
47 |
-
*/
|
48 |
-
static public function getInstance() {
|
49 |
-
if(self::$instance == null) {
|
50 |
-
self::$instance = new self;
|
51 |
-
}
|
52 |
-
|
53 |
-
return self::$instance;
|
54 |
-
}
|
55 |
-
|
56 |
-
/**
|
57 |
-
* Run, forest.
|
58 |
-
*/
|
59 |
-
public function process( $url, $width = null, $height = null, $crop = null, $single = true, $upscale = false ) {
|
60 |
-
// Validate inputs.
|
61 |
-
if ( ! $url || ( ! $width && ! $height ) ) return false;
|
62 |
-
|
63 |
-
// Caipt'n, ready to hook.
|
64 |
-
if ( true === $upscale ) add_filter( 'image_resize_dimensions', array($this, 'arpw_upscale'), 10, 6 );
|
65 |
-
|
66 |
-
// Define upload path & dir.
|
67 |
-
$upload_info = wp_upload_dir();
|
68 |
-
$upload_dir = $upload_info['basedir'];
|
69 |
-
$upload_url = $upload_info['baseurl'];
|
70 |
-
|
71 |
-
$http_prefix = "http://";
|
72 |
-
$https_prefix = "https://";
|
73 |
-
|
74 |
-
/* if the $url scheme differs from $upload_url scheme, make them match
|
75 |
-
if the schemes differe, images don't show up. */
|
76 |
-
if(!strncmp($url,$https_prefix,strlen($https_prefix))){ //if url begins with https:// make $upload_url begin with https:// as well
|
77 |
-
$upload_url = str_replace($http_prefix,$https_prefix,$upload_url);
|
78 |
-
}
|
79 |
-
elseif(!strncmp($url,$http_prefix,strlen($http_prefix))){ //if url begins with http:// make $upload_url begin with http:// as well
|
80 |
-
$upload_url = str_replace($https_prefix,$http_prefix,$upload_url);
|
81 |
-
}
|
82 |
-
|
83 |
-
|
84 |
-
// Check if $img_url is local.
|
85 |
-
if ( false === strpos( $url, $upload_url ) ) return false;
|
86 |
-
|
87 |
-
// Define path of image.
|
88 |
-
$rel_path = str_replace( $upload_url, '', $url );
|
89 |
-
$img_path = $upload_dir . $rel_path;
|
90 |
-
|
91 |
-
// Check if img path exists, and is an image indeed.
|
92 |
-
if ( ! file_exists( $img_path ) or ! getimagesize( $img_path ) ) return false;
|
93 |
-
|
94 |
-
// Get image info.
|
95 |
-
$info = pathinfo( $img_path );
|
96 |
-
$ext = $info['extension'];
|
97 |
-
list( $orig_w, $orig_h ) = getimagesize( $img_path );
|
98 |
-
|
99 |
-
// Get image size after cropping.
|
100 |
-
$dims = image_resize_dimensions( $orig_w, $orig_h, $width, $height, $crop );
|
101 |
-
$dst_w = $dims[4];
|
102 |
-
$dst_h = $dims[5];
|
103 |
-
|
104 |
-
// Return the original image only if it exactly fits the needed measures.
|
105 |
-
if ( ! $dims && ( ( ( null === $height && $orig_w == $width ) xor ( null === $width && $orig_h == $height ) ) xor ( $height == $orig_h && $width == $orig_w ) ) ) {
|
106 |
-
$img_url = $url;
|
107 |
-
$dst_w = $orig_w;
|
108 |
-
$dst_h = $orig_h;
|
109 |
-
} else {
|
110 |
-
// Use this to check if cropped image already exists, so we can return that instead.
|
111 |
-
$suffix = "{$dst_w}x{$dst_h}";
|
112 |
-
$dst_rel_path = str_replace( '.' . $ext, '', $rel_path );
|
113 |
-
$destfilename = "{$upload_dir}{$dst_rel_path}-{$suffix}.{$ext}";
|
114 |
-
|
115 |
-
if ( ! $dims || ( true == $crop && false == $upscale && ( $dst_w < $width || $dst_h < $height ) ) ) {
|
116 |
-
// Can't resize, so return false saying that the action to do could not be processed as planned.
|
117 |
-
return false;
|
118 |
-
}
|
119 |
-
// Else check if cache exists.
|
120 |
-
elseif ( file_exists( $destfilename ) && getimagesize( $destfilename ) ) {
|
121 |
-
$img_url = "{$upload_url}{$dst_rel_path}-{$suffix}.{$ext}";
|
122 |
-
}
|
123 |
-
// Else, we resize the image and return the new resized image url.
|
124 |
-
else {
|
125 |
-
|
126 |
-
$editor = wp_get_image_editor( $img_path );
|
127 |
-
|
128 |
-
if ( is_wp_error( $editor ) || is_wp_error( $editor->resize( $width, $height, $crop ) ) )
|
129 |
-
return false;
|
130 |
-
|
131 |
-
$resized_file = $editor->save();
|
132 |
-
|
133 |
-
if ( ! is_wp_error( $resized_file ) ) {
|
134 |
-
$resized_rel_path = str_replace( $upload_dir, '', $resized_file['path'] );
|
135 |
-
$img_url = $upload_url . $resized_rel_path;
|
136 |
-
} else {
|
137 |
-
return false;
|
138 |
-
}
|
139 |
-
|
140 |
-
}
|
141 |
-
}
|
142 |
-
|
143 |
-
// Okay, leave the ship.
|
144 |
-
if ( true === $upscale ) remove_filter( 'image_resize_dimensions', array( $this, 'arpw_upscale' ) );
|
145 |
-
|
146 |
-
// Return the output.
|
147 |
-
if ( $single ) {
|
148 |
-
// str return.
|
149 |
-
$image = $img_url;
|
150 |
-
} else {
|
151 |
-
// array return.
|
152 |
-
$image = array (
|
153 |
-
0 => $img_url,
|
154 |
-
1 => $dst_w,
|
155 |
-
2 => $dst_h
|
156 |
-
);
|
157 |
-
}
|
158 |
-
|
159 |
-
return $image;
|
160 |
-
}
|
161 |
-
|
162 |
-
/**
|
163 |
-
* Callback to overwrite WP computing of thumbnail measures
|
164 |
-
*/
|
165 |
-
function arpw_upscale( $default, $orig_w, $orig_h, $dest_w, $dest_h, $crop ) {
|
166 |
-
if ( ! $crop ) return null; // Let the wordpress default function handle this.
|
167 |
-
|
168 |
-
// Here is the point we allow to use larger image size than the original one.
|
169 |
-
$aspect_ratio = $orig_w / $orig_h;
|
170 |
-
$new_w = $dest_w;
|
171 |
-
$new_h = $dest_h;
|
172 |
-
|
173 |
-
if ( ! $new_w ) {
|
174 |
-
$new_w = intval( $new_h * $aspect_ratio );
|
175 |
-
}
|
176 |
-
|
177 |
-
if ( ! $new_h ) {
|
178 |
-
$new_h = intval( $new_w / $aspect_ratio );
|
179 |
-
}
|
180 |
-
|
181 |
-
$size_ratio = max( $new_w / $orig_w, $new_h / $orig_h );
|
182 |
-
|
183 |
-
$crop_w = round( $new_w / $size_ratio );
|
184 |
-
$crop_h = round( $new_h / $size_ratio );
|
185 |
-
|
186 |
-
$s_x = floor( ( $orig_w - $crop_w ) / 2 );
|
187 |
-
$s_y = floor( ( $orig_h - $crop_h ) / 2 );
|
188 |
-
|
189 |
-
return array( 0, 0, (int) $s_x, (int) $s_y, (int) $new_w, (int) $new_h, (int) $crop_w, (int) $crop_h );
|
190 |
-
}
|
191 |
-
}
|
192 |
-
}
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
if(!function_exists('arpw_resize')) {
|
199 |
-
|
200 |
-
/**
|
201 |
-
* This is just a tiny wrapper function for the class above so that there is no
|
202 |
-
* need to change any code in your own WP themes. Usage is still the same :)
|
203 |
-
*/
|
204 |
-
function arpw_resize( $url, $width = null, $height = null, $crop = null, $single = true, $upscale = false ) {
|
205 |
-
$arpw_resize = Arpw_Resize::getInstance();
|
206 |
-
return $arpw_resize->process( $url, $width, $height, $crop, $single, $upscale );
|
207 |
-
}
|
208 |
-
}
|
209 |
-
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Title : Aqua Resizer
|
5 |
+
* Description : Resizes WordPress images on the fly
|
6 |
+
* Version : 1.2.0
|
7 |
+
* Author : Syamil MJ
|
8 |
+
* Author URI : http://aquagraphite.com
|
9 |
+
* License : WTFPL - http://sam.zoy.org/wtfpl/
|
10 |
+
* Documentation : https://github.com/sy4mil/Aqua-Resizer/
|
11 |
+
*
|
12 |
+
* I changed the function and class name for compatibility purpose. It somtimes conflicted with a theme which uses the same library.
|
13 |
+
*
|
14 |
+
* @param string $url - (required) must be uploaded using wp media uploader
|
15 |
+
* @param int $width - (required)
|
16 |
+
* @param int $height - (optional)
|
17 |
+
* @param bool $crop - (optional) default to soft crop
|
18 |
+
* @param bool $single - (optional) returns an array if false
|
19 |
+
* @param bool $upscale - (optional) resizes smaller images
|
20 |
+
* @uses wp_upload_dir()
|
21 |
+
* @uses image_resize_dimensions()
|
22 |
+
* @uses wp_get_image_editor()
|
23 |
+
*
|
24 |
+
* @return str|array
|
25 |
+
*/
|
26 |
+
|
27 |
+
if(!class_exists('Arpw_Resize')) {
|
28 |
+
class Arpw_Resize
|
29 |
+
{
|
30 |
+
/**
|
31 |
+
* The singleton instance
|
32 |
+
*/
|
33 |
+
static private $instance = null;
|
34 |
+
|
35 |
+
/**
|
36 |
+
* No initialization allowed
|
37 |
+
*/
|
38 |
+
private function __construct() {}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* No cloning allowed
|
42 |
+
*/
|
43 |
+
private function __clone() {}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* For your custom default usage you may want to initialize an Arpw_Resize object by yourself and then have own defaults
|
47 |
+
*/
|
48 |
+
static public function getInstance() {
|
49 |
+
if(self::$instance == null) {
|
50 |
+
self::$instance = new self;
|
51 |
+
}
|
52 |
+
|
53 |
+
return self::$instance;
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Run, forest.
|
58 |
+
*/
|
59 |
+
public function process( $url, $width = null, $height = null, $crop = null, $single = true, $upscale = false ) {
|
60 |
+
// Validate inputs.
|
61 |
+
if ( ! $url || ( ! $width && ! $height ) ) return false;
|
62 |
+
|
63 |
+
// Caipt'n, ready to hook.
|
64 |
+
if ( true === $upscale ) add_filter( 'image_resize_dimensions', array($this, 'arpw_upscale'), 10, 6 );
|
65 |
+
|
66 |
+
// Define upload path & dir.
|
67 |
+
$upload_info = wp_upload_dir();
|
68 |
+
$upload_dir = $upload_info['basedir'];
|
69 |
+
$upload_url = $upload_info['baseurl'];
|
70 |
+
|
71 |
+
$http_prefix = "http://";
|
72 |
+
$https_prefix = "https://";
|
73 |
+
|
74 |
+
/* if the $url scheme differs from $upload_url scheme, make them match
|
75 |
+
if the schemes differe, images don't show up. */
|
76 |
+
if(!strncmp($url,$https_prefix,strlen($https_prefix))){ //if url begins with https:// make $upload_url begin with https:// as well
|
77 |
+
$upload_url = str_replace($http_prefix,$https_prefix,$upload_url);
|
78 |
+
}
|
79 |
+
elseif(!strncmp($url,$http_prefix,strlen($http_prefix))){ //if url begins with http:// make $upload_url begin with http:// as well
|
80 |
+
$upload_url = str_replace($https_prefix,$http_prefix,$upload_url);
|
81 |
+
}
|
82 |
+
|
83 |
+
|
84 |
+
// Check if $img_url is local.
|
85 |
+
if ( false === strpos( $url, $upload_url ) ) return false;
|
86 |
+
|
87 |
+
// Define path of image.
|
88 |
+
$rel_path = str_replace( $upload_url, '', $url );
|
89 |
+
$img_path = $upload_dir . $rel_path;
|
90 |
+
|
91 |
+
// Check if img path exists, and is an image indeed.
|
92 |
+
if ( ! file_exists( $img_path ) or ! getimagesize( $img_path ) ) return false;
|
93 |
+
|
94 |
+
// Get image info.
|
95 |
+
$info = pathinfo( $img_path );
|
96 |
+
$ext = $info['extension'];
|
97 |
+
list( $orig_w, $orig_h ) = getimagesize( $img_path );
|
98 |
+
|
99 |
+
// Get image size after cropping.
|
100 |
+
$dims = image_resize_dimensions( $orig_w, $orig_h, $width, $height, $crop );
|
101 |
+
$dst_w = $dims[4];
|
102 |
+
$dst_h = $dims[5];
|
103 |
+
|
104 |
+
// Return the original image only if it exactly fits the needed measures.
|
105 |
+
if ( ! $dims && ( ( ( null === $height && $orig_w == $width ) xor ( null === $width && $orig_h == $height ) ) xor ( $height == $orig_h && $width == $orig_w ) ) ) {
|
106 |
+
$img_url = $url;
|
107 |
+
$dst_w = $orig_w;
|
108 |
+
$dst_h = $orig_h;
|
109 |
+
} else {
|
110 |
+
// Use this to check if cropped image already exists, so we can return that instead.
|
111 |
+
$suffix = "{$dst_w}x{$dst_h}";
|
112 |
+
$dst_rel_path = str_replace( '.' . $ext, '', $rel_path );
|
113 |
+
$destfilename = "{$upload_dir}{$dst_rel_path}-{$suffix}.{$ext}";
|
114 |
+
|
115 |
+
if ( ! $dims || ( true == $crop && false == $upscale && ( $dst_w < $width || $dst_h < $height ) ) ) {
|
116 |
+
// Can't resize, so return false saying that the action to do could not be processed as planned.
|
117 |
+
return false;
|
118 |
+
}
|
119 |
+
// Else check if cache exists.
|
120 |
+
elseif ( file_exists( $destfilename ) && getimagesize( $destfilename ) ) {
|
121 |
+
$img_url = "{$upload_url}{$dst_rel_path}-{$suffix}.{$ext}";
|
122 |
+
}
|
123 |
+
// Else, we resize the image and return the new resized image url.
|
124 |
+
else {
|
125 |
+
|
126 |
+
$editor = wp_get_image_editor( $img_path );
|
127 |
+
|
128 |
+
if ( is_wp_error( $editor ) || is_wp_error( $editor->resize( $width, $height, $crop ) ) )
|
129 |
+
return false;
|
130 |
+
|
131 |
+
$resized_file = $editor->save();
|
132 |
+
|
133 |
+
if ( ! is_wp_error( $resized_file ) ) {
|
134 |
+
$resized_rel_path = str_replace( $upload_dir, '', $resized_file['path'] );
|
135 |
+
$img_url = $upload_url . $resized_rel_path;
|
136 |
+
} else {
|
137 |
+
return false;
|
138 |
+
}
|
139 |
+
|
140 |
+
}
|
141 |
+
}
|
142 |
+
|
143 |
+
// Okay, leave the ship.
|
144 |
+
if ( true === $upscale ) remove_filter( 'image_resize_dimensions', array( $this, 'arpw_upscale' ) );
|
145 |
+
|
146 |
+
// Return the output.
|
147 |
+
if ( $single ) {
|
148 |
+
// str return.
|
149 |
+
$image = $img_url;
|
150 |
+
} else {
|
151 |
+
// array return.
|
152 |
+
$image = array (
|
153 |
+
0 => $img_url,
|
154 |
+
1 => $dst_w,
|
155 |
+
2 => $dst_h
|
156 |
+
);
|
157 |
+
}
|
158 |
+
|
159 |
+
return $image;
|
160 |
+
}
|
161 |
+
|
162 |
+
/**
|
163 |
+
* Callback to overwrite WP computing of thumbnail measures
|
164 |
+
*/
|
165 |
+
function arpw_upscale( $default, $orig_w, $orig_h, $dest_w, $dest_h, $crop ) {
|
166 |
+
if ( ! $crop ) return null; // Let the wordpress default function handle this.
|
167 |
+
|
168 |
+
// Here is the point we allow to use larger image size than the original one.
|
169 |
+
$aspect_ratio = $orig_w / $orig_h;
|
170 |
+
$new_w = $dest_w;
|
171 |
+
$new_h = $dest_h;
|
172 |
+
|
173 |
+
if ( ! $new_w ) {
|
174 |
+
$new_w = intval( $new_h * $aspect_ratio );
|
175 |
+
}
|
176 |
+
|
177 |
+
if ( ! $new_h ) {
|
178 |
+
$new_h = intval( $new_w / $aspect_ratio );
|
179 |
+
}
|
180 |
+
|
181 |
+
$size_ratio = max( $new_w / $orig_w, $new_h / $orig_h );
|
182 |
+
|
183 |
+
$crop_w = round( $new_w / $size_ratio );
|
184 |
+
$crop_h = round( $new_h / $size_ratio );
|
185 |
+
|
186 |
+
$s_x = floor( ( $orig_w - $crop_w ) / 2 );
|
187 |
+
$s_y = floor( ( $orig_h - $crop_h ) / 2 );
|
188 |
+
|
189 |
+
return array( 0, 0, (int) $s_x, (int) $s_y, (int) $new_w, (int) $new_h, (int) $crop_w, (int) $crop_h );
|
190 |
+
}
|
191 |
+
}
|
192 |
+
}
|
193 |
+
|
194 |
+
|
195 |
+
|
196 |
+
|
197 |
+
|
198 |
+
if(!function_exists('arpw_resize')) {
|
199 |
+
|
200 |
+
/**
|
201 |
+
* This is just a tiny wrapper function for the class above so that there is no
|
202 |
+
* need to change any code in your own WP themes. Usage is still the same :)
|
203 |
+
*/
|
204 |
+
function arpw_resize( $url, $width = null, $height = null, $crop = null, $single = true, $upscale = false ) {
|
205 |
+
$arpw_resize = Arpw_Resize::getInstance();
|
206 |
+
return $arpw_resize->process( $url, $width, $height, $crop, $single, $upscale );
|
207 |
+
}
|
208 |
+
}
|
209 |
+
|
includes/shortcode.php
CHANGED
@@ -1,21 +1,21 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Shortcode helper
|
4 |
-
*
|
5 |
-
* @package Advanced_Random_Posts_Widget
|
6 |
-
* @since 0.0.1
|
7 |
-
* @author Satrya
|
8 |
-
* @copyright Copyright (c) 2014, Satrya
|
9 |
-
* @license http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
-
*/
|
11 |
-
|
12 |
-
/**
|
13 |
-
* Display random posts with shortcode
|
14 |
-
*
|
15 |
-
* @since 0.0.1
|
16 |
-
*/
|
17 |
-
function arpw_shortcode( $atts, $content ) {
|
18 |
-
$args = shortcode_atts( arpw_get_default_args(), $atts );
|
19 |
-
return arpw_get_random_posts( $args );
|
20 |
-
}
|
21 |
add_shortcode( 'arpw', 'arpw_shortcode' );
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Shortcode helper
|
4 |
+
*
|
5 |
+
* @package Advanced_Random_Posts_Widget
|
6 |
+
* @since 0.0.1
|
7 |
+
* @author Satrya
|
8 |
+
* @copyright Copyright (c) 2014, Satrya
|
9 |
+
* @license http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Display random posts with shortcode
|
14 |
+
*
|
15 |
+
* @since 0.0.1
|
16 |
+
*/
|
17 |
+
function arpw_shortcode( $atts, $content ) {
|
18 |
+
$args = shortcode_atts( arpw_get_default_args(), $atts );
|
19 |
+
return arpw_get_random_posts( $args );
|
20 |
+
}
|
21 |
add_shortcode( 'arpw', 'arpw_shortcode' );
|
license.txt
CHANGED
@@ -1,339 +1,339 @@
|
|
1 |
-
GNU GENERAL PUBLIC LICENSE
|
2 |
-
Version 2, June 1991
|
3 |
-
|
4 |
-
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
5 |
-
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
6 |
-
Everyone is permitted to copy and distribute verbatim copies
|
7 |
-
of this license document, but changing it is not allowed.
|
8 |
-
|
9 |
-
Preamble
|
10 |
-
|
11 |
-
The licenses for most software are designed to take away your
|
12 |
-
freedom to share and change it. By contrast, the GNU General Public
|
13 |
-
License is intended to guarantee your freedom to share and change free
|
14 |
-
software--to make sure the software is free for all its users. This
|
15 |
-
General Public License applies to most of the Free Software
|
16 |
-
Foundation's software and to any other program whose authors commit to
|
17 |
-
using it. (Some other Free Software Foundation software is covered by
|
18 |
-
the GNU Lesser General Public License instead.) You can apply it to
|
19 |
-
your programs, too.
|
20 |
-
|
21 |
-
When we speak of free software, we are referring to freedom, not
|
22 |
-
price. Our General Public Licenses are designed to make sure that you
|
23 |
-
have the freedom to distribute copies of free software (and charge for
|
24 |
-
this service if you wish), that you receive source code or can get it
|
25 |
-
if you want it, that you can change the software or use pieces of it
|
26 |
-
in new free programs; and that you know you can do these things.
|
27 |
-
|
28 |
-
To protect your rights, we need to make restrictions that forbid
|
29 |
-
anyone to deny you these rights or to ask you to surrender the rights.
|
30 |
-
These restrictions translate to certain responsibilities for you if you
|
31 |
-
distribute copies of the software, or if you modify it.
|
32 |
-
|
33 |
-
For example, if you distribute copies of such a program, whether
|
34 |
-
gratis or for a fee, you must give the recipients all the rights that
|
35 |
-
you have. You must make sure that they, too, receive or can get the
|
36 |
-
source code. And you must show them these terms so they know their
|
37 |
-
rights.
|
38 |
-
|
39 |
-
We protect your rights with two steps: (1) copyright the software, and
|
40 |
-
(2) offer you this license which gives you legal permission to copy,
|
41 |
-
distribute and/or modify the software.
|
42 |
-
|
43 |
-
Also, for each author's protection and ours, we want to make certain
|
44 |
-
that everyone understands that there is no warranty for this free
|
45 |
-
software. If the software is modified by someone else and passed on, we
|
46 |
-
want its recipients to know that what they have is not the original, so
|
47 |
-
that any problems introduced by others will not reflect on the original
|
48 |
-
authors' reputations.
|
49 |
-
|
50 |
-
Finally, any free program is threatened constantly by software
|
51 |
-
patents. We wish to avoid the danger that redistributors of a free
|
52 |
-
program will individually obtain patent licenses, in effect making the
|
53 |
-
program proprietary. To prevent this, we have made it clear that any
|
54 |
-
patent must be licensed for everyone's free use or not licensed at all.
|
55 |
-
|
56 |
-
The precise terms and conditions for copying, distribution and
|
57 |
-
modification follow.
|
58 |
-
|
59 |
-
GNU GENERAL PUBLIC LICENSE
|
60 |
-
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
61 |
-
|
62 |
-
0. This License applies to any program or other work which contains
|
63 |
-
a notice placed by the copyright holder saying it may be distributed
|
64 |
-
under the terms of this General Public License. The "Program", below,
|
65 |
-
refers to any such program or work, and a "work based on the Program"
|
66 |
-
means either the Program or any derivative work under copyright law:
|
67 |
-
that is to say, a work containing the Program or a portion of it,
|
68 |
-
either verbatim or with modifications and/or translated into another
|
69 |
-
language. (Hereinafter, translation is included without limitation in
|
70 |
-
the term "modification".) Each licensee is addressed as "you".
|
71 |
-
|
72 |
-
Activities other than copying, distribution and modification are not
|
73 |
-
covered by this License; they are outside its scope. The act of
|
74 |
-
running the Program is not restricted, and the output from the Program
|
75 |
-
is covered only if its contents constitute a work based on the
|
76 |
-
Program (independent of having been made by running the Program).
|
77 |
-
Whether that is true depends on what the Program does.
|
78 |
-
|
79 |
-
1. You may copy and distribute verbatim copies of the Program's
|
80 |
-
source code as you receive it, in any medium, provided that you
|
81 |
-
conspicuously and appropriately publish on each copy an appropriate
|
82 |
-
copyright notice and disclaimer of warranty; keep intact all the
|
83 |
-
notices that refer to this License and to the absence of any warranty;
|
84 |
-
and give any other recipients of the Program a copy of this License
|
85 |
-
along with the Program.
|
86 |
-
|
87 |
-
You may charge a fee for the physical act of transferring a copy, and
|
88 |
-
you may at your option offer warranty protection in exchange for a fee.
|
89 |
-
|
90 |
-
2. You may modify your copy or copies of the Program or any portion
|
91 |
-
of it, thus forming a work based on the Program, and copy and
|
92 |
-
distribute such modifications or work under the terms of Section 1
|
93 |
-
above, provided that you also meet all of these conditions:
|
94 |
-
|
95 |
-
a) You must cause the modified files to carry prominent notices
|
96 |
-
stating that you changed the files and the date of any change.
|
97 |
-
|
98 |
-
b) You must cause any work that you distribute or publish, that in
|
99 |
-
whole or in part contains or is derived from the Program or any
|
100 |
-
part thereof, to be licensed as a whole at no charge to all third
|
101 |
-
parties under the terms of this License.
|
102 |
-
|
103 |
-
c) If the modified program normally reads commands interactively
|
104 |
-
when run, you must cause it, when started running for such
|
105 |
-
interactive use in the most ordinary way, to print or display an
|
106 |
-
announcement including an appropriate copyright notice and a
|
107 |
-
notice that there is no warranty (or else, saying that you provide
|
108 |
-
a warranty) and that users may redistribute the program under
|
109 |
-
these conditions, and telling the user how to view a copy of this
|
110 |
-
License. (Exception: if the Program itself is interactive but
|
111 |
-
does not normally print such an announcement, your work based on
|
112 |
-
the Program is not required to print an announcement.)
|
113 |
-
|
114 |
-
These requirements apply to the modified work as a whole. If
|
115 |
-
identifiable sections of that work are not derived from the Program,
|
116 |
-
and can be reasonably considered independent and separate works in
|
117 |
-
themselves, then this License, and its terms, do not apply to those
|
118 |
-
sections when you distribute them as separate works. But when you
|
119 |
-
distribute the same sections as part of a whole which is a work based
|
120 |
-
on the Program, the distribution of the whole must be on the terms of
|
121 |
-
this License, whose permissions for other licensees extend to the
|
122 |
-
entire whole, and thus to each and every part regardless of who wrote it.
|
123 |
-
|
124 |
-
Thus, it is not the intent of this section to claim rights or contest
|
125 |
-
your rights to work written entirely by you; rather, the intent is to
|
126 |
-
exercise the right to control the distribution of derivative or
|
127 |
-
collective works based on the Program.
|
128 |
-
|
129 |
-
In addition, mere aggregation of another work not based on the Program
|
130 |
-
with the Program (or with a work based on the Program) on a volume of
|
131 |
-
a storage or distribution medium does not bring the other work under
|
132 |
-
the scope of this License.
|
133 |
-
|
134 |
-
3. You may copy and distribute the Program (or a work based on it,
|
135 |
-
under Section 2) in object code or executable form under the terms of
|
136 |
-
Sections 1 and 2 above provided that you also do one of the following:
|
137 |
-
|
138 |
-
a) Accompany it with the complete corresponding machine-readable
|
139 |
-
source code, which must be distributed under the terms of Sections
|
140 |
-
1 and 2 above on a medium customarily used for software interchange; or,
|
141 |
-
|
142 |
-
b) Accompany it with a written offer, valid for at least three
|
143 |
-
years, to give any third party, for a charge no more than your
|
144 |
-
cost of physically performing source distribution, a complete
|
145 |
-
machine-readable copy of the corresponding source code, to be
|
146 |
-
distributed under the terms of Sections 1 and 2 above on a medium
|
147 |
-
customarily used for software interchange; or,
|
148 |
-
|
149 |
-
c) Accompany it with the information you received as to the offer
|
150 |
-
to distribute corresponding source code. (This alternative is
|
151 |
-
allowed only for noncommercial distribution and only if you
|
152 |
-
received the program in object code or executable form with such
|
153 |
-
an offer, in accord with Subsection b above.)
|
154 |
-
|
155 |
-
The source code for a work means the preferred form of the work for
|
156 |
-
making modifications to it. For an executable work, complete source
|
157 |
-
code means all the source code for all modules it contains, plus any
|
158 |
-
associated interface definition files, plus the scripts used to
|
159 |
-
control compilation and installation of the executable. However, as a
|
160 |
-
special exception, the source code distributed need not include
|
161 |
-
anything that is normally distributed (in either source or binary
|
162 |
-
form) with the major components (compiler, kernel, and so on) of the
|
163 |
-
operating system on which the executable runs, unless that component
|
164 |
-
itself accompanies the executable.
|
165 |
-
|
166 |
-
If distribution of executable or object code is made by offering
|
167 |
-
access to copy from a designated place, then offering equivalent
|
168 |
-
access to copy the source code from the same place counts as
|
169 |
-
distribution of the source code, even though third parties are not
|
170 |
-
compelled to copy the source along with the object code.
|
171 |
-
|
172 |
-
4. You may not copy, modify, sublicense, or distribute the Program
|
173 |
-
except as expressly provided under this License. Any attempt
|
174 |
-
otherwise to copy, modify, sublicense or distribute the Program is
|
175 |
-
void, and will automatically terminate your rights under this License.
|
176 |
-
However, parties who have received copies, or rights, from you under
|
177 |
-
this License will not have their licenses terminated so long as such
|
178 |
-
parties remain in full compliance.
|
179 |
-
|
180 |
-
5. You are not required to accept this License, since you have not
|
181 |
-
signed it. However, nothing else grants you permission to modify or
|
182 |
-
distribute the Program or its derivative works. These actions are
|
183 |
-
prohibited by law if you do not accept this License. Therefore, by
|
184 |
-
modifying or distributing the Program (or any work based on the
|
185 |
-
Program), you indicate your acceptance of this License to do so, and
|
186 |
-
all its terms and conditions for copying, distributing or modifying
|
187 |
-
the Program or works based on it.
|
188 |
-
|
189 |
-
6. Each time you redistribute the Program (or any work based on the
|
190 |
-
Program), the recipient automatically receives a license from the
|
191 |
-
original licensor to copy, distribute or modify the Program subject to
|
192 |
-
these terms and conditions. You may not impose any further
|
193 |
-
restrictions on the recipients' exercise of the rights granted herein.
|
194 |
-
You are not responsible for enforcing compliance by third parties to
|
195 |
-
this License.
|
196 |
-
|
197 |
-
7. If, as a consequence of a court judgment or allegation of patent
|
198 |
-
infringement or for any other reason (not limited to patent issues),
|
199 |
-
conditions are imposed on you (whether by court order, agreement or
|
200 |
-
otherwise) that contradict the conditions of this License, they do not
|
201 |
-
excuse you from the conditions of this License. If you cannot
|
202 |
-
distribute so as to satisfy simultaneously your obligations under this
|
203 |
-
License and any other pertinent obligations, then as a consequence you
|
204 |
-
may not distribute the Program at all. For example, if a patent
|
205 |
-
license would not permit royalty-free redistribution of the Program by
|
206 |
-
all those who receive copies directly or indirectly through you, then
|
207 |
-
the only way you could satisfy both it and this License would be to
|
208 |
-
refrain entirely from distribution of the Program.
|
209 |
-
|
210 |
-
If any portion of this section is held invalid or unenforceable under
|
211 |
-
any particular circumstance, the balance of the section is intended to
|
212 |
-
apply and the section as a whole is intended to apply in other
|
213 |
-
circumstances.
|
214 |
-
|
215 |
-
It is not the purpose of this section to induce you to infringe any
|
216 |
-
patents or other property right claims or to contest validity of any
|
217 |
-
such claims; this section has the sole purpose of protecting the
|
218 |
-
integrity of the free software distribution system, which is
|
219 |
-
implemented by public license practices. Many people have made
|
220 |
-
generous contributions to the wide range of software distributed
|
221 |
-
through that system in reliance on consistent application of that
|
222 |
-
system; it is up to the author/donor to decide if he or she is willing
|
223 |
-
to distribute software through any other system and a licensee cannot
|
224 |
-
impose that choice.
|
225 |
-
|
226 |
-
This section is intended to make thoroughly clear what is believed to
|
227 |
-
be a consequence of the rest of this License.
|
228 |
-
|
229 |
-
8. If the distribution and/or use of the Program is restricted in
|
230 |
-
certain countries either by patents or by copyrighted interfaces, the
|
231 |
-
original copyright holder who places the Program under this License
|
232 |
-
may add an explicit geographical distribution limitation excluding
|
233 |
-
those countries, so that distribution is permitted only in or among
|
234 |
-
countries not thus excluded. In such case, this License incorporates
|
235 |
-
the limitation as if written in the body of this License.
|
236 |
-
|
237 |
-
9. The Free Software Foundation may publish revised and/or new versions
|
238 |
-
of the General Public License from time to time. Such new versions will
|
239 |
-
be similar in spirit to the present version, but may differ in detail to
|
240 |
-
address new problems or concerns.
|
241 |
-
|
242 |
-
Each version is given a distinguishing version number. If the Program
|
243 |
-
specifies a version number of this License which applies to it and "any
|
244 |
-
later version", you have the option of following the terms and conditions
|
245 |
-
either of that version or of any later version published by the Free
|
246 |
-
Software Foundation. If the Program does not specify a version number of
|
247 |
-
this License, you may choose any version ever published by the Free Software
|
248 |
-
Foundation.
|
249 |
-
|
250 |
-
10. If you wish to incorporate parts of the Program into other free
|
251 |
-
programs whose distribution conditions are different, write to the author
|
252 |
-
to ask for permission. For software which is copyrighted by the Free
|
253 |
-
Software Foundation, write to the Free Software Foundation; we sometimes
|
254 |
-
make exceptions for this. Our decision will be guided by the two goals
|
255 |
-
of preserving the free status of all derivatives of our free software and
|
256 |
-
of promoting the sharing and reuse of software generally.
|
257 |
-
|
258 |
-
NO WARRANTY
|
259 |
-
|
260 |
-
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
261 |
-
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
262 |
-
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
263 |
-
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
264 |
-
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
265 |
-
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
266 |
-
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
267 |
-
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
268 |
-
REPAIR OR CORRECTION.
|
269 |
-
|
270 |
-
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
271 |
-
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
272 |
-
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
273 |
-
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
274 |
-
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
275 |
-
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
276 |
-
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
277 |
-
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
278 |
-
POSSIBILITY OF SUCH DAMAGES.
|
279 |
-
|
280 |
-
END OF TERMS AND CONDITIONS
|
281 |
-
|
282 |
-
How to Apply These Terms to Your New Programs
|
283 |
-
|
284 |
-
If you develop a new program, and you want it to be of the greatest
|
285 |
-
possible use to the public, the best way to achieve this is to make it
|
286 |
-
free software which everyone can redistribute and change under these terms.
|
287 |
-
|
288 |
-
To do so, attach the following notices to the program. It is safest
|
289 |
-
to attach them to the start of each source file to most effectively
|
290 |
-
convey the exclusion of warranty; and each file should have at least
|
291 |
-
the "copyright" line and a pointer to where the full notice is found.
|
292 |
-
|
293 |
-
<one line to give the program's name and a brief idea of what it does.>
|
294 |
-
Copyright (C) <year> <name of author>
|
295 |
-
|
296 |
-
This program is free software; you can redistribute it and/or modify
|
297 |
-
it under the terms of the GNU General Public License as published by
|
298 |
-
the Free Software Foundation; either version 2 of the License, or
|
299 |
-
(at your option) any later version.
|
300 |
-
|
301 |
-
This program is distributed in the hope that it will be useful,
|
302 |
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
303 |
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
304 |
-
GNU General Public License for more details.
|
305 |
-
|
306 |
-
You should have received a copy of the GNU General Public License along
|
307 |
-
with this program; if not, write to the Free Software Foundation, Inc.,
|
308 |
-
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
309 |
-
|
310 |
-
Also add information on how to contact you by electronic and paper mail.
|
311 |
-
|
312 |
-
If the program is interactive, make it output a short notice like this
|
313 |
-
when it starts in an interactive mode:
|
314 |
-
|
315 |
-
Gnomovision version 69, Copyright (C) year name of author
|
316 |
-
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
317 |
-
This is free software, and you are welcome to redistribute it
|
318 |
-
under certain conditions; type `show c' for details.
|
319 |
-
|
320 |
-
The hypothetical commands `show w' and `show c' should show the appropriate
|
321 |
-
parts of the General Public License. Of course, the commands you use may
|
322 |
-
be called something other than `show w' and `show c'; they could even be
|
323 |
-
mouse-clicks or menu items--whatever suits your program.
|
324 |
-
|
325 |
-
You should also get your employer (if you work as a programmer) or your
|
326 |
-
school, if any, to sign a "copyright disclaimer" for the program, if
|
327 |
-
necessary. Here is a sample; alter the names:
|
328 |
-
|
329 |
-
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
330 |
-
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
331 |
-
|
332 |
-
<signature of Ty Coon>, 1 April 1989
|
333 |
-
Ty Coon, President of Vice
|
334 |
-
|
335 |
-
This General Public License does not permit incorporating your program into
|
336 |
-
proprietary programs. If your program is a subroutine library, you may
|
337 |
-
consider it more useful to permit linking proprietary applications with the
|
338 |
-
library. If this is what you want to do, use the GNU Lesser General
|
339 |
Public License instead of this License.
|
1 |
+
GNU GENERAL PUBLIC LICENSE
|
2 |
+
Version 2, June 1991
|
3 |
+
|
4 |
+
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
5 |
+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
6 |
+
Everyone is permitted to copy and distribute verbatim copies
|
7 |
+
of this license document, but changing it is not allowed.
|
8 |
+
|
9 |
+
Preamble
|
10 |
+
|
11 |
+
The licenses for most software are designed to take away your
|
12 |
+
freedom to share and change it. By contrast, the GNU General Public
|
13 |
+
License is intended to guarantee your freedom to share and change free
|
14 |
+
software--to make sure the software is free for all its users. This
|
15 |
+
General Public License applies to most of the Free Software
|
16 |
+
Foundation's software and to any other program whose authors commit to
|
17 |
+
using it. (Some other Free Software Foundation software is covered by
|
18 |
+
the GNU Lesser General Public License instead.) You can apply it to
|
19 |
+
your programs, too.
|
20 |
+
|
21 |
+
When we speak of free software, we are referring to freedom, not
|
22 |
+
price. Our General Public Licenses are designed to make sure that you
|
23 |
+
have the freedom to distribute copies of free software (and charge for
|
24 |
+
this service if you wish), that you receive source code or can get it
|
25 |
+
if you want it, that you can change the software or use pieces of it
|
26 |
+
in new free programs; and that you know you can do these things.
|
27 |
+
|
28 |
+
To protect your rights, we need to make restrictions that forbid
|
29 |
+
anyone to deny you these rights or to ask you to surrender the rights.
|
30 |
+
These restrictions translate to certain responsibilities for you if you
|
31 |
+
distribute copies of the software, or if you modify it.
|
32 |
+
|
33 |
+
For example, if you distribute copies of such a program, whether
|
34 |
+
gratis or for a fee, you must give the recipients all the rights that
|
35 |
+
you have. You must make sure that they, too, receive or can get the
|
36 |
+
source code. And you must show them these terms so they know their
|
37 |
+
rights.
|
38 |
+
|
39 |
+
We protect your rights with two steps: (1) copyright the software, and
|
40 |
+
(2) offer you this license which gives you legal permission to copy,
|
41 |
+
distribute and/or modify the software.
|
42 |
+
|
43 |
+
Also, for each author's protection and ours, we want to make certain
|
44 |
+
that everyone understands that there is no warranty for this free
|
45 |
+
software. If the software is modified by someone else and passed on, we
|
46 |
+
want its recipients to know that what they have is not the original, so
|
47 |
+
that any problems introduced by others will not reflect on the original
|
48 |
+
authors' reputations.
|
49 |
+
|
50 |
+
Finally, any free program is threatened constantly by software
|
51 |
+
patents. We wish to avoid the danger that redistributors of a free
|
52 |
+
program will individually obtain patent licenses, in effect making the
|
53 |
+
program proprietary. To prevent this, we have made it clear that any
|
54 |
+
patent must be licensed for everyone's free use or not licensed at all.
|
55 |
+
|
56 |
+
The precise terms and conditions for copying, distribution and
|
57 |
+
modification follow.
|
58 |
+
|
59 |
+
GNU GENERAL PUBLIC LICENSE
|
60 |
+
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
61 |
+
|
62 |
+
0. This License applies to any program or other work which contains
|
63 |
+
a notice placed by the copyright holder saying it may be distributed
|
64 |
+
under the terms of this General Public License. The "Program", below,
|
65 |
+
refers to any such program or work, and a "work based on the Program"
|
66 |
+
means either the Program or any derivative work under copyright law:
|
67 |
+
that is to say, a work containing the Program or a portion of it,
|
68 |
+
either verbatim or with modifications and/or translated into another
|
69 |
+
language. (Hereinafter, translation is included without limitation in
|
70 |
+
the term "modification".) Each licensee is addressed as "you".
|
71 |
+
|
72 |
+
Activities other than copying, distribution and modification are not
|
73 |
+
covered by this License; they are outside its scope. The act of
|
74 |
+
running the Program is not restricted, and the output from the Program
|
75 |
+
is covered only if its contents constitute a work based on the
|
76 |
+
Program (independent of having been made by running the Program).
|
77 |
+
Whether that is true depends on what the Program does.
|
78 |
+
|
79 |
+
1. You may copy and distribute verbatim copies of the Program's
|
80 |
+
source code as you receive it, in any medium, provided that you
|
81 |
+
conspicuously and appropriately publish on each copy an appropriate
|
82 |
+
copyright notice and disclaimer of warranty; keep intact all the
|
83 |
+
notices that refer to this License and to the absence of any warranty;
|
84 |
+
and give any other recipients of the Program a copy of this License
|
85 |
+
along with the Program.
|
86 |
+
|
87 |
+
You may charge a fee for the physical act of transferring a copy, and
|
88 |
+
you may at your option offer warranty protection in exchange for a fee.
|
89 |
+
|
90 |
+
2. You may modify your copy or copies of the Program or any portion
|
91 |
+
of it, thus forming a work based on the Program, and copy and
|
92 |
+
distribute such modifications or work under the terms of Section 1
|
93 |
+
above, provided that you also meet all of these conditions:
|
94 |
+
|
95 |
+
a) You must cause the modified files to carry prominent notices
|
96 |
+
stating that you changed the files and the date of any change.
|
97 |
+
|
98 |
+
b) You must cause any work that you distribute or publish, that in
|
99 |
+
whole or in part contains or is derived from the Program or any
|
100 |
+
part thereof, to be licensed as a whole at no charge to all third
|
101 |
+
parties under the terms of this License.
|
102 |
+
|
103 |
+
c) If the modified program normally reads commands interactively
|
104 |
+
when run, you must cause it, when started running for such
|
105 |
+
interactive use in the most ordinary way, to print or display an
|
106 |
+
announcement including an appropriate copyright notice and a
|
107 |
+
notice that there is no warranty (or else, saying that you provide
|
108 |
+
a warranty) and that users may redistribute the program under
|
109 |
+
these conditions, and telling the user how to view a copy of this
|
110 |
+
License. (Exception: if the Program itself is interactive but
|
111 |
+
does not normally print such an announcement, your work based on
|
112 |
+
the Program is not required to print an announcement.)
|
113 |
+
|
114 |
+
These requirements apply to the modified work as a whole. If
|
115 |
+
identifiable sections of that work are not derived from the Program,
|
116 |
+
and can be reasonably considered independent and separate works in
|
117 |
+
themselves, then this License, and its terms, do not apply to those
|
118 |
+
sections when you distribute them as separate works. But when you
|
119 |
+
distribute the same sections as part of a whole which is a work based
|
120 |
+
on the Program, the distribution of the whole must be on the terms of
|
121 |
+
this License, whose permissions for other licensees extend to the
|
122 |
+
entire whole, and thus to each and every part regardless of who wrote it.
|
123 |
+
|
124 |
+
Thus, it is not the intent of this section to claim rights or contest
|
125 |
+
your rights to work written entirely by you; rather, the intent is to
|
126 |
+
exercise the right to control the distribution of derivative or
|
127 |
+
collective works based on the Program.
|
128 |
+
|
129 |
+
In addition, mere aggregation of another work not based on the Program
|
130 |
+
with the Program (or with a work based on the Program) on a volume of
|
131 |
+
a storage or distribution medium does not bring the other work under
|
132 |
+
the scope of this License.
|
133 |
+
|
134 |
+
3. You may copy and distribute the Program (or a work based on it,
|
135 |
+
under Section 2) in object code or executable form under the terms of
|
136 |
+
Sections 1 and 2 above provided that you also do one of the following:
|
137 |
+
|
138 |
+
a) Accompany it with the complete corresponding machine-readable
|
139 |
+
source code, which must be distributed under the terms of Sections
|
140 |
+
1 and 2 above on a medium customarily used for software interchange; or,
|
141 |
+
|
142 |
+
b) Accompany it with a written offer, valid for at least three
|
143 |
+
years, to give any third party, for a charge no more than your
|
144 |
+
cost of physically performing source distribution, a complete
|
145 |
+
machine-readable copy of the corresponding source code, to be
|
146 |
+
distributed under the terms of Sections 1 and 2 above on a medium
|
147 |
+
customarily used for software interchange; or,
|
148 |
+
|
149 |
+
c) Accompany it with the information you received as to the offer
|
150 |
+
to distribute corresponding source code. (This alternative is
|
151 |
+
allowed only for noncommercial distribution and only if you
|
152 |
+
received the program in object code or executable form with such
|
153 |
+
an offer, in accord with Subsection b above.)
|
154 |
+
|
155 |
+
The source code for a work means the preferred form of the work for
|
156 |
+
making modifications to it. For an executable work, complete source
|
157 |
+
code means all the source code for all modules it contains, plus any
|
158 |
+
associated interface definition files, plus the scripts used to
|
159 |
+
control compilation and installation of the executable. However, as a
|
160 |
+
special exception, the source code distributed need not include
|
161 |
+
anything that is normally distributed (in either source or binary
|
162 |
+
form) with the major components (compiler, kernel, and so on) of the
|
163 |
+
operating system on which the executable runs, unless that component
|
164 |
+
itself accompanies the executable.
|
165 |
+
|
166 |
+
If distribution of executable or object code is made by offering
|
167 |
+
access to copy from a designated place, then offering equivalent
|
168 |
+
access to copy the source code from the same place counts as
|
169 |
+
distribution of the source code, even though third parties are not
|
170 |
+
compelled to copy the source along with the object code.
|
171 |
+
|
172 |
+
4. You may not copy, modify, sublicense, or distribute the Program
|
173 |
+
except as expressly provided under this License. Any attempt
|
174 |
+
otherwise to copy, modify, sublicense or distribute the Program is
|
175 |
+
void, and will automatically terminate your rights under this License.
|
176 |
+
However, parties who have received copies, or rights, from you under
|
177 |
+
this License will not have their licenses terminated so long as such
|
178 |
+
parties remain in full compliance.
|
179 |
+
|
180 |
+
5. You are not required to accept this License, since you have not
|
181 |
+
signed it. However, nothing else grants you permission to modify or
|
182 |
+
distribute the Program or its derivative works. These actions are
|
183 |
+
prohibited by law if you do not accept this License. Therefore, by
|
184 |
+
modifying or distributing the Program (or any work based on the
|
185 |
+
Program), you indicate your acceptance of this License to do so, and
|
186 |
+
all its terms and conditions for copying, distributing or modifying
|
187 |
+
the Program or works based on it.
|
188 |
+
|
189 |
+
6. Each time you redistribute the Program (or any work based on the
|
190 |
+
Program), the recipient automatically receives a license from the
|
191 |
+
original licensor to copy, distribute or modify the Program subject to
|
192 |
+
these terms and conditions. You may not impose any further
|
193 |
+
restrictions on the recipients' exercise of the rights granted herein.
|
194 |
+
You are not responsible for enforcing compliance by third parties to
|
195 |
+
this License.
|
196 |
+
|
197 |
+
7. If, as a consequence of a court judgment or allegation of patent
|
198 |
+
infringement or for any other reason (not limited to patent issues),
|
199 |
+
conditions are imposed on you (whether by court order, agreement or
|
200 |
+
otherwise) that contradict the conditions of this License, they do not
|
201 |
+
excuse you from the conditions of this License. If you cannot
|
202 |
+
distribute so as to satisfy simultaneously your obligations under this
|
203 |
+
License and any other pertinent obligations, then as a consequence you
|
204 |
+
may not distribute the Program at all. For example, if a patent
|
205 |
+
license would not permit royalty-free redistribution of the Program by
|
206 |
+
all those who receive copies directly or indirectly through you, then
|
207 |
+
the only way you could satisfy both it and this License would be to
|
208 |
+
refrain entirely from distribution of the Program.
|
209 |
+
|
210 |
+
If any portion of this section is held invalid or unenforceable under
|
211 |
+
any particular circumstance, the balance of the section is intended to
|
212 |
+
apply and the section as a whole is intended to apply in other
|
213 |
+
circumstances.
|
214 |
+
|
215 |
+
It is not the purpose of this section to induce you to infringe any
|
216 |
+
patents or other property right claims or to contest validity of any
|
217 |
+
such claims; this section has the sole purpose of protecting the
|
218 |
+
integrity of the free software distribution system, which is
|
219 |
+
implemented by public license practices. Many people have made
|
220 |
+
generous contributions to the wide range of software distributed
|
221 |
+
through that system in reliance on consistent application of that
|
222 |
+
system; it is up to the author/donor to decide if he or she is willing
|
223 |
+
to distribute software through any other system and a licensee cannot
|
224 |
+
impose that choice.
|
225 |
+
|
226 |
+
This section is intended to make thoroughly clear what is believed to
|
227 |
+
be a consequence of the rest of this License.
|
228 |
+
|
229 |
+
8. If the distribution and/or use of the Program is restricted in
|
230 |
+
certain countries either by patents or by copyrighted interfaces, the
|
231 |
+
original copyright holder who places the Program under this License
|
232 |
+
may add an explicit geographical distribution limitation excluding
|
233 |
+
those countries, so that distribution is permitted only in or among
|
234 |
+
countries not thus excluded. In such case, this License incorporates
|
235 |
+
the limitation as if written in the body of this License.
|
236 |
+
|
237 |
+
9. The Free Software Foundation may publish revised and/or new versions
|
238 |
+
of the General Public License from time to time. Such new versions will
|
239 |
+
be similar in spirit to the present version, but may differ in detail to
|
240 |
+
address new problems or concerns.
|
241 |
+
|
242 |
+
Each version is given a distinguishing version number. If the Program
|
243 |
+
specifies a version number of this License which applies to it and "any
|
244 |
+
later version", you have the option of following the terms and conditions
|
245 |
+
either of that version or of any later version published by the Free
|
246 |
+
Software Foundation. If the Program does not specify a version number of
|
247 |
+
this License, you may choose any version ever published by the Free Software
|
248 |
+
Foundation.
|
249 |
+
|
250 |
+
10. If you wish to incorporate parts of the Program into other free
|
251 |
+
programs whose distribution conditions are different, write to the author
|
252 |
+
to ask for permission. For software which is copyrighted by the Free
|
253 |
+
Software Foundation, write to the Free Software Foundation; we sometimes
|
254 |
+
make exceptions for this. Our decision will be guided by the two goals
|
255 |
+
of preserving the free status of all derivatives of our free software and
|
256 |
+
of promoting the sharing and reuse of software generally.
|
257 |
+
|
258 |
+
NO WARRANTY
|
259 |
+
|
260 |
+
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
261 |
+
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
262 |
+
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
263 |
+
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
264 |
+
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
265 |
+
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
266 |
+
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
267 |
+
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
268 |
+
REPAIR OR CORRECTION.
|
269 |
+
|
270 |
+
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
271 |
+
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
272 |
+
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
273 |
+
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
274 |
+
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
275 |
+
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
276 |
+
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
277 |
+
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
278 |
+
POSSIBILITY OF SUCH DAMAGES.
|
279 |
+
|
280 |
+
END OF TERMS AND CONDITIONS
|
281 |
+
|
282 |
+
How to Apply These Terms to Your New Programs
|
283 |
+
|
284 |
+
If you develop a new program, and you want it to be of the greatest
|
285 |
+
possible use to the public, the best way to achieve this is to make it
|
286 |
+
free software which everyone can redistribute and change under these terms.
|
287 |
+
|
288 |
+
To do so, attach the following notices to the program. It is safest
|
289 |
+
to attach them to the start of each source file to most effectively
|
290 |
+
convey the exclusion of warranty; and each file should have at least
|
291 |
+
the "copyright" line and a pointer to where the full notice is found.
|
292 |
+
|
293 |
+
<one line to give the program's name and a brief idea of what it does.>
|
294 |
+
Copyright (C) <year> <name of author>
|
295 |
+
|
296 |
+
This program is free software; you can redistribute it and/or modify
|
297 |
+
it under the terms of the GNU General Public License as published by
|
298 |
+
the Free Software Foundation; either version 2 of the License, or
|
299 |
+
(at your option) any later version.
|
300 |
+
|
301 |
+
This program is distributed in the hope that it will be useful,
|
302 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
303 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
304 |
+
GNU General Public License for more details.
|
305 |
+
|
306 |
+
You should have received a copy of the GNU General Public License along
|
307 |
+
with this program; if not, write to the Free Software Foundation, Inc.,
|
308 |
+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
309 |
+
|
310 |
+
Also add information on how to contact you by electronic and paper mail.
|
311 |
+
|
312 |
+
If the program is interactive, make it output a short notice like this
|
313 |
+
when it starts in an interactive mode:
|
314 |
+
|
315 |
+
Gnomovision version 69, Copyright (C) year name of author
|
316 |
+
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
317 |
+
This is free software, and you are welcome to redistribute it
|
318 |
+
under certain conditions; type `show c' for details.
|
319 |
+
|
320 |
+
The hypothetical commands `show w' and `show c' should show the appropriate
|
321 |
+
parts of the General Public License. Of course, the commands you use may
|
322 |
+
be called something other than `show w' and `show c'; they could even be
|
323 |
+
mouse-clicks or menu items--whatever suits your program.
|
324 |
+
|
325 |
+
You should also get your employer (if you work as a programmer) or your
|
326 |
+
school, if any, to sign a "copyright disclaimer" for the program, if
|
327 |
+
necessary. Here is a sample; alter the names:
|
328 |
+
|
329 |
+
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
330 |
+
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
331 |
+
|
332 |
+
<signature of Ty Coon>, 1 April 1989
|
333 |
+
Ty Coon, President of Vice
|
334 |
+
|
335 |
+
This General Public License does not permit incorporating your program into
|
336 |
+
proprietary programs. If your program is a subroutine library, you may
|
337 |
+
consider it more useful to permit linking proprietary applications with the
|
338 |
+
library. If this is what you want to do, use the GNU Lesser General
|
339 |
Public License instead of this License.
|
readme.txt
CHANGED
@@ -1,174 +1,178 @@
|
|
1 |
-
=== Advanced Random Posts Widget ===
|
2 |
-
Contributors: satrya, themejunkie
|
3 |
-
Donate link: http://satrya.me/donate/
|
4 |
-
Tags: random posts, thumbnail, widget, widgets, sidebar, excerpt, category, post tag, post type, taxonomy, shortcode, multiple widgets
|
5 |
-
Requires at least: 3.7
|
6 |
-
Tested up to: 4.0
|
7 |
-
Stable tag: 2.0.
|
8 |
-
License: GPLv2 or later
|
9 |
-
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
-
|
11 |
-
Provides flexible and advanced random posts. Display it via shortcode or widget with thumbnails, post excerpt, and much more!
|
12 |
-
|
13 |
-
== Description ==
|
14 |
-
|
15 |
-
This plugin will enable a custom, flexible and advanced random posts. It allows you to display a list of random posts via shortcode or widget with thumbnail, excerpt and post date, also you can display it from all or specific or multiple taxonomy.
|
16 |
-
|
17 |
-
= Important! =
|
18 |
-
Before asking a support question:
|
19 |
-
|
20 |
-
* Please see [FAQ](http://wordpress.org/plugins/advanced-random-posts-widget/faq/) page to read common questions.
|
21 |
-
* Please see [Other Notes](http://wordpress.org/plugins/advanced-random-posts-widget/other_notes/) to read how to use shortcode.
|
22 |
-
|
23 |
-
= Features Include =
|
24 |
-
|
25 |
-
* WordPress 4.0 Support.
|
26 |
-
* Allow you to set title url.
|
27 |
-
* Display thumbnails, with customizable size and alignment.
|
28 |
-
* Display excerpt, with customizable length.
|
29 |
-
* Display from all, specific or multiple category.
|
30 |
-
* Display from all, specific or multiple tag.
|
31 |
-
* Display from all, specific or multiple taxonomy.
|
32 |
-
* Display post date.
|
33 |
-
* Post types.
|
34 |
-
* Post status.
|
35 |
-
* Allow you to set custom css class per widget.
|
36 |
-
* Add custom html or text before and/or after random posts.
|
37 |
-
* Multiple widgets.
|
38 |
-
|
39 |
-
= Plugin Support =
|
40 |
-
* [Get the Image](http://wordpress.org/plugins/get-the-image/).
|
41 |
-
* [Page Builder by SiteOrigin](http://wordpress.org/plugins/siteorigin-panels/).
|
42 |
-
|
43 |
-
= Image Sizes Issue =
|
44 |
-
|
45 |
-
This plugin creates custom image sizes. If you use images that were uploaded to the media library before you installed this plugin, please install [Regenerate Thumbnails](http://wordpress.org/extend/plugins/regenerate-thumbnails/) plugin to fix the image size.
|
46 |
-
|
47 |
-
= Support =
|
48 |
-
|
49 |
-
* Go to [forum support](http://wordpress.org/support/plugin/advanced-random-posts-widget).
|
50 |
-
* [Rate/Review the plugin](http://wordpress.org/support/view/plugin-reviews/advanced-random-posts-widget).
|
51 |
-
* Submit translation.
|
52 |
-
|
53 |
-
= Plugin Info =
|
54 |
-
* Developed by [Satrya](http://satrya.me/) & [Theme Junkie](http://www.theme-junkie.com/)
|
55 |
-
* Check out the [Github](https://github.com/satrya/advanced-random-posts-widget) repo to contribute.
|
56 |
-
|
57 |
-
= Posts Plugin Series =
|
58 |
-
* [Recent Posts Widget Extended](http://wordpress.org/plugins/recent-posts-widget-extended/)
|
59 |
-
* [Advanced Random Posts Widget](http://wordpress.org/plugins/advanced-random-posts-widget/)
|
60 |
-
|
61 |
-
== Installation ==
|
62 |
-
|
63 |
-
**Through Dashboard**
|
64 |
-
|
65 |
-
1. Log in to your WordPress admin panel and go to Plugins -> Add New
|
66 |
-
2. Type **advanced random posts widget** in the search box and click on search button.
|
67 |
-
3. Find **Advanced Random Posts Widget** plugin.
|
68 |
-
4. Then click on Install Now after that activate the plugin.
|
69 |
-
5. Go to the widgets page **Appearance -> Widgets**.
|
70 |
-
6. Find **Random Posts** widget.
|
71 |
-
|
72 |
-
**Installing Via FTP**
|
73 |
-
|
74 |
-
1. Download the plugin to your hardisk.
|
75 |
-
2. Unzip.
|
76 |
-
3. Upload the **advanced-random-posts-widget** folder into your plugins directory.
|
77 |
-
4. Log in to your WordPress admin panel and click the Plugins menu.
|
78 |
-
5. Then activate the plugin.
|
79 |
-
6. Go to the widgets page **Appearance -> Widgets**.
|
80 |
-
6. Find **Random Posts** widget.
|
81 |
-
|
82 |
-
== Frequently Asked Questions ==
|
83 |
-
|
84 |
-
= No image/thumbnail options? =
|
85 |
-
Your theme needs to support Post Thumbnail, please go to http://codex.wordpress.org/Post_Thumbnails to read more info and how to activate it in your theme.
|
86 |
-
|
87 |
-
= Thumbnail Size =
|
88 |
-
By default it uses **arpw-thumbnail** which have **50x50** size. If you want to use custom image size, you can install http://wordpress.org/plugins/simple-image-sizes/ then create new image size, it will appear in the **Thumbnail Size** selectbox in the widget option.
|
89 |
-
|
90 |
-
= Thumbnail Size Not Working Properly =
|
91 |
-
I have mentioned it in the plugin description. If you use images that were uploaded to the media library before you installed this plugin and/or you have your own custom image sizes, please install [Regenerate Thumbnails](http://wordpress.org/extend/plugins/regenerate-thumbnails/) plugin to fix the image size.
|
92 |
-
|
93 |
-
= How to add custom style? =
|
94 |
-
The plugin comes with a very basic style, if you want to add custom style please do `wp_dequeue_style` to remove the default stylesheet. Place the code below in your theme `functions.php`.
|
95 |
-
`
|
96 |
-
function prefix_remove_arpw_style() {
|
97 |
-
wp_dequeue_style( 'arpw-style' );
|
98 |
-
}
|
99 |
-
add_action( 'wp_enqueue_scripts', 'prefix_remove_arpw_style', 10 );
|
100 |
-
`
|
101 |
-
Then you can add your custom style using Custom CSS plugin or in your theme `style.css`. Here's the plugin selector
|
102 |
-
`
|
103 |
-
/* wrapper */
|
104 |
-
#arpw-random-posts {}
|
105 |
-
|
106 |
-
/* ul */
|
107 |
-
.arpw-ul {}
|
108 |
-
|
109 |
-
/* li */
|
110 |
-
.arpw-li {}
|
111 |
-
|
112 |
-
/* title */
|
113 |
-
.arpw-title {}
|
114 |
-
|
115 |
-
/* thumbnail */
|
116 |
-
.arpw-thumbnail {}
|
117 |
-
|
118 |
-
/* date */
|
119 |
-
.arpw-time {}
|
120 |
-
|
121 |
-
/* excerpt */
|
122 |
-
.arpw-summary {}
|
123 |
-
`
|
124 |
-
|
125 |
-
== Screenshots ==
|
126 |
-
|
127 |
-
1. The widget settings
|
128 |
-
|
129 |
-
== Shorcode Explanation ==
|
130 |
-
|
131 |
-
Explanation of shortcode options:
|
132 |
-
|
133 |
-
Basic shortcode
|
134 |
-
`
|
135 |
-
[arpw]
|
136 |
-
`
|
137 |
-
|
138 |
-
Display 10 random posts
|
139 |
-
`
|
140 |
-
[arpw limit="10"]
|
141 |
-
`
|
142 |
-
|
143 |
-
Display with thumbnail and set the size
|
144 |
-
`
|
145 |
-
[arpw thumbnail="true" thumbnail_size="thumbnail"]
|
146 |
-
`
|
147 |
-
|
148 |
-
**Here's the full default shortcode arguments**
|
149 |
-
`
|
150 |
-
title=""
|
151 |
-
title_url=""
|
152 |
-
offset=""
|
153 |
-
limit="5"
|
154 |
-
post_type="post"
|
155 |
-
post_status="publish"
|
156 |
-
ignore_sticky="1"
|
157 |
-
taxonomy=""
|
158 |
-
thumbnail="false"
|
159 |
-
thumbnail_size="arpw-thumbnail"
|
160 |
-
thumbnail_align="left"
|
161 |
-
excerpt="false"
|
162 |
-
excerpt_length="10"
|
163 |
-
date="false"
|
164 |
-
css_class=""
|
165 |
-
before=""
|
166 |
-
after=""
|
167 |
-
`
|
168 |
-
|
169 |
-
== Changelog ==
|
170 |
-
|
171 |
-
= 2.0.
|
172 |
-
*
|
173 |
-
*
|
|
|
|
|
|
|
|
|
174 |
* Added: Relative date option `eg: 5 days ago`.
|
1 |
+
=== Advanced Random Posts Widget ===
|
2 |
+
Contributors: satrya, themejunkie
|
3 |
+
Donate link: http://satrya.me/donate/
|
4 |
+
Tags: random posts, thumbnail, widget, widgets, sidebar, excerpt, category, post tag, post type, taxonomy, shortcode, multiple widgets
|
5 |
+
Requires at least: 3.7
|
6 |
+
Tested up to: 4.0.1
|
7 |
+
Stable tag: 2.0.2
|
8 |
+
License: GPLv2 or later
|
9 |
+
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
+
|
11 |
+
Provides flexible and advanced random posts. Display it via shortcode or widget with thumbnails, post excerpt, and much more!
|
12 |
+
|
13 |
+
== Description ==
|
14 |
+
|
15 |
+
This plugin will enable a custom, flexible and advanced random posts. It allows you to display a list of random posts via shortcode or widget with thumbnail, excerpt and post date, also you can display it from all or specific or multiple taxonomy.
|
16 |
+
|
17 |
+
= Important! =
|
18 |
+
Before asking a support question:
|
19 |
+
|
20 |
+
* Please see [FAQ](http://wordpress.org/plugins/advanced-random-posts-widget/faq/) page to read common questions.
|
21 |
+
* Please see [Other Notes](http://wordpress.org/plugins/advanced-random-posts-widget/other_notes/) to read how to use shortcode.
|
22 |
+
|
23 |
+
= Features Include =
|
24 |
+
|
25 |
+
* WordPress 4.0 Support.
|
26 |
+
* Allow you to set title url.
|
27 |
+
* Display thumbnails, with customizable size and alignment.
|
28 |
+
* Display excerpt, with customizable length.
|
29 |
+
* Display from all, specific or multiple category.
|
30 |
+
* Display from all, specific or multiple tag.
|
31 |
+
* Display from all, specific or multiple taxonomy.
|
32 |
+
* Display post date.
|
33 |
+
* Post types.
|
34 |
+
* Post status.
|
35 |
+
* Allow you to set custom css class per widget.
|
36 |
+
* Add custom html or text before and/or after random posts.
|
37 |
+
* Multiple widgets.
|
38 |
+
|
39 |
+
= Plugin Support =
|
40 |
+
* [Get the Image](http://wordpress.org/plugins/get-the-image/).
|
41 |
+
* [Page Builder by SiteOrigin](http://wordpress.org/plugins/siteorigin-panels/).
|
42 |
+
|
43 |
+
= Image Sizes Issue =
|
44 |
+
|
45 |
+
This plugin creates custom image sizes. If you use images that were uploaded to the media library before you installed this plugin, please install [Regenerate Thumbnails](http://wordpress.org/extend/plugins/regenerate-thumbnails/) plugin to fix the image size.
|
46 |
+
|
47 |
+
= Support =
|
48 |
+
|
49 |
+
* Go to [forum support](http://wordpress.org/support/plugin/advanced-random-posts-widget).
|
50 |
+
* [Rate/Review the plugin](http://wordpress.org/support/view/plugin-reviews/advanced-random-posts-widget).
|
51 |
+
* Submit translation.
|
52 |
+
|
53 |
+
= Plugin Info =
|
54 |
+
* Developed by [Satrya](http://satrya.me/) & [Theme Junkie](http://www.theme-junkie.com/)
|
55 |
+
* Check out the [Github](https://github.com/satrya/advanced-random-posts-widget) repo to contribute.
|
56 |
+
|
57 |
+
= Posts Plugin Series =
|
58 |
+
* [Recent Posts Widget Extended](http://wordpress.org/plugins/recent-posts-widget-extended/)
|
59 |
+
* [Advanced Random Posts Widget](http://wordpress.org/plugins/advanced-random-posts-widget/)
|
60 |
+
|
61 |
+
== Installation ==
|
62 |
+
|
63 |
+
**Through Dashboard**
|
64 |
+
|
65 |
+
1. Log in to your WordPress admin panel and go to Plugins -> Add New
|
66 |
+
2. Type **advanced random posts widget** in the search box and click on search button.
|
67 |
+
3. Find **Advanced Random Posts Widget** plugin.
|
68 |
+
4. Then click on Install Now after that activate the plugin.
|
69 |
+
5. Go to the widgets page **Appearance -> Widgets**.
|
70 |
+
6. Find **Random Posts** widget.
|
71 |
+
|
72 |
+
**Installing Via FTP**
|
73 |
+
|
74 |
+
1. Download the plugin to your hardisk.
|
75 |
+
2. Unzip.
|
76 |
+
3. Upload the **advanced-random-posts-widget** folder into your plugins directory.
|
77 |
+
4. Log in to your WordPress admin panel and click the Plugins menu.
|
78 |
+
5. Then activate the plugin.
|
79 |
+
6. Go to the widgets page **Appearance -> Widgets**.
|
80 |
+
6. Find **Random Posts** widget.
|
81 |
+
|
82 |
+
== Frequently Asked Questions ==
|
83 |
+
|
84 |
+
= No image/thumbnail options? =
|
85 |
+
Your theme needs to support Post Thumbnail, please go to http://codex.wordpress.org/Post_Thumbnails to read more info and how to activate it in your theme.
|
86 |
+
|
87 |
+
= Thumbnail Size =
|
88 |
+
By default it uses **arpw-thumbnail** which have **50x50** size. If you want to use custom image size, you can install http://wordpress.org/plugins/simple-image-sizes/ then create new image size, it will appear in the **Thumbnail Size** selectbox in the widget option.
|
89 |
+
|
90 |
+
= Thumbnail Size Not Working Properly =
|
91 |
+
I have mentioned it in the plugin description. If you use images that were uploaded to the media library before you installed this plugin and/or you have your own custom image sizes, please install [Regenerate Thumbnails](http://wordpress.org/extend/plugins/regenerate-thumbnails/) plugin to fix the image size.
|
92 |
+
|
93 |
+
= How to add custom style? =
|
94 |
+
The plugin comes with a very basic style, if you want to add custom style please do `wp_dequeue_style` to remove the default stylesheet. Place the code below in your theme `functions.php`.
|
95 |
+
`
|
96 |
+
function prefix_remove_arpw_style() {
|
97 |
+
wp_dequeue_style( 'arpw-style' );
|
98 |
+
}
|
99 |
+
add_action( 'wp_enqueue_scripts', 'prefix_remove_arpw_style', 10 );
|
100 |
+
`
|
101 |
+
Then you can add your custom style using Custom CSS plugin or in your theme `style.css`. Here's the plugin selector
|
102 |
+
`
|
103 |
+
/* wrapper */
|
104 |
+
#arpw-random-posts {}
|
105 |
+
|
106 |
+
/* ul */
|
107 |
+
.arpw-ul {}
|
108 |
+
|
109 |
+
/* li */
|
110 |
+
.arpw-li {}
|
111 |
+
|
112 |
+
/* title */
|
113 |
+
.arpw-title {}
|
114 |
+
|
115 |
+
/* thumbnail */
|
116 |
+
.arpw-thumbnail {}
|
117 |
+
|
118 |
+
/* date */
|
119 |
+
.arpw-time {}
|
120 |
+
|
121 |
+
/* excerpt */
|
122 |
+
.arpw-summary {}
|
123 |
+
`
|
124 |
+
|
125 |
+
== Screenshots ==
|
126 |
+
|
127 |
+
1. The widget settings
|
128 |
+
|
129 |
+
== Shorcode Explanation ==
|
130 |
+
|
131 |
+
Explanation of shortcode options:
|
132 |
+
|
133 |
+
Basic shortcode
|
134 |
+
`
|
135 |
+
[arpw]
|
136 |
+
`
|
137 |
+
|
138 |
+
Display 10 random posts
|
139 |
+
`
|
140 |
+
[arpw limit="10"]
|
141 |
+
`
|
142 |
+
|
143 |
+
Display with thumbnail and set the size
|
144 |
+
`
|
145 |
+
[arpw thumbnail="true" thumbnail_size="thumbnail"]
|
146 |
+
`
|
147 |
+
|
148 |
+
**Here's the full default shortcode arguments**
|
149 |
+
`
|
150 |
+
title=""
|
151 |
+
title_url=""
|
152 |
+
offset=""
|
153 |
+
limit="5"
|
154 |
+
post_type="post"
|
155 |
+
post_status="publish"
|
156 |
+
ignore_sticky="1"
|
157 |
+
taxonomy=""
|
158 |
+
thumbnail="false"
|
159 |
+
thumbnail_size="arpw-thumbnail"
|
160 |
+
thumbnail_align="left"
|
161 |
+
excerpt="false"
|
162 |
+
excerpt_length="10"
|
163 |
+
date="false"
|
164 |
+
css_class=""
|
165 |
+
before=""
|
166 |
+
after=""
|
167 |
+
`
|
168 |
+
|
169 |
+
== Changelog ==
|
170 |
+
|
171 |
+
= 2.0.2 - 12/03/2014 =
|
172 |
+
* **Fix:** Compatibility issue with `Get The Image` plugin/extension.
|
173 |
+
* **Fix:** Issue with `html or text before and after recent posts`, now it allow all HTML tags.
|
174 |
+
|
175 |
+
= 2.0.1 - 9/15/2014 =
|
176 |
+
* Bring back custom thumbnail size options!
|
177 |
+
* Bring back category and tag options!
|
178 |
* Added: Relative date option `eg: 5 days ago`.
|