-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
135 lines (113 loc) · 4.28 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<?php
/*
Plugin Name: Simple Colorbox Reloaded
Plugin URI: https://github.com/ThemeAvenue/Simple-Colorbox-Reloaded
Description: Modified version of the Simple Colorbox WordPress plugin which includes some bugfixes. This plugin adds a Colorbox to your site with no configuration required.
Author: ThemeAvenue
Version: 1.0.1
Author URI: http://themeavenue.net/
GitHub Plugin URI: https://github.com/ThemeAvenue/Simple-Colorbox-Reloaded
This fork is based on version 1.3.1 of SImple Colorbox by Ryan Hellyer.
Copyright (c) 2013 Ryan Hellyer
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
license.txt file included with this plugin for more information.
*/
/**
* Define constants
*
* @since 1.0
* @author Ryan Hellyer <[email protected]>
*/
define( 'SIMPLECOLORBOX_DIR', dirname( __FILE__ ) . '/' ); // Plugin folder DIR
define( 'SIMPLECOLORBOX_URL', plugins_url( '', __FILE__ ) ); // Plugin folder URL
define( 'SIMPLECOLORBOX_VERSION', '1.3.1' );
define( 'SIMPLECOLORBOXRELOADED_VERSION', '1.0.1' );
//define( 'SIMPLECOLORBOX_THEME', '5' ); // Can be used to over-ride the default theme
//define( 'SIMPLECOLORBOX_OPACITY', '0.2' );
//define( 'SIMPLECOLORBOX_WIDTH', '50' );
//define( 'SIMPLECOLORBOX_HEIGHT', '50' );
/**
* Simple Colorbox class
* Adds the required CSS and JS files to front-end of the site
*
* This class may be abstracted from the plugin and used in your own theme if you prefer.
* This can allow you to offer easy to use colorbox functionality without the hassle of
* users needing to install a complicated plugin.
*
* @copyright Copyright (c), Ryan Hellyer
* @author Ryan Hellyer <[email protected]>
* @since 1.0
*/
class Simple_Colorbox {
/**
* Class constructor
* Adds all the methods to appropriate hooks or shortcodes
*/
public function __construct() {
// Add action hooks
add_action( 'wp_enqueue_scripts', array( $this, 'external_css' ) );
add_action( 'wp_enqueue_scripts', array( $this, 'external_scripts' ) );
add_action( 'wp_head', array( $this, 'simplecolorbox_ad' ) );
add_action( 'wp_head', array( $this, 'inline_scripts' ) );
}
/**
* Print scripts onto pages
*/
public function external_scripts() {
wp_enqueue_script(
'colorbox',
SIMPLECOLORBOX_URL . '/scripts/jquery.colorbox-min.js',
array( 'jquery' ),
'1.4.33',
true
);
}
/**
* Print scripts onto pages
*/
public function inline_scripts() {
// Do definition check - used by themes/plugins to over-ride the default settings
if ( ! defined( 'SIMPLECOLORBOX_OPACITY' ) )
define( 'SIMPLECOLORBOX_OPACITY', '0.6' );
if ( ! defined( 'SIMPLECOLORBOX_WIDTH' ) )
define( 'SIMPLECOLORBOX_WIDTH', '95' );
if ( ! defined( 'SIMPLECOLORBOX_HEIGHT' ) )
define( 'SIMPLECOLORBOX_HEIGHT', '95' );
if ( ! defined( 'SIMPLECOLORBOX_SLIDESHOW' ) )
define( 'SIMPLECOLORBOX_SLIDESHOW', 'group' );
// Colorbox settings
echo '
<script>
jQuery(function($){
$("a[href$=\'jpg\'],a[href$=\'jpeg\'],a[href$=\'png\'],a[href$=\'bmp\'],a[href$=\'gif\'],a[href$=\'JPG\'],a[href$=\'JPEG\'],a[href$=\'PNG\'],a[href$=\'BMP\'],a[href$=\'GIF\']").colorbox({
maxWidth:\'' . SIMPLECOLORBOX_WIDTH . '%\',
maxHeight:\'' . SIMPLECOLORBOX_HEIGHT . '%\',
opacity:\'' . SIMPLECOLORBOX_OPACITY . '\',
rel:\'' . SIMPLECOLORBOX_SLIDESHOW . '\'
});
});
</script>';
}
/*
* Adds CSS to front end of site
*/
public function external_css() {
// Do definition check - used by themes/plugins to over-ride the default settings
if ( ! defined( 'SIMPLECOLORBOX_THEME' ) )
define( 'SIMPLECOLORBOX_THEME', '1' );
// Load the stylesheet
wp_enqueue_style( 'colorbox', SIMPLECOLORBOX_URL . '/themes/example' . SIMPLECOLORBOX_THEME . '/colorbox.css', false, '', 'screen' );
}
/**
* Display notice about the plugin in head
*/
public function simplecolorbox_ad() {
echo "\n<!-- Simple Colorbox Reloaded Plugin v" . SIMPLECOLORBOXRELOADED_VERSION ." by ThemeAvenue ... http://themeavenue.net.net/ -->\n";
}
}
$simple_colorbox = new Simple_Colorbox();