Version Description
- Added 'mtphr_dnt_tick_before' and 'mtphr_dnt_tick_after' actions.
- Fixed error in 'rotate_scroll_up' script.
- Updated Metabox scripts.
Download this release
Release Info
Developer | metaphorcreations |
Plugin | Ditty News Ticker |
Version | 1.0.2 |
Comparing to | |
See all releases |
Version 1.0.2
- assets/css/style-admin.css +44 -0
- assets/css/style.css +130 -0
- assets/images/button.png +0 -0
- assets/images/button@2x.png +0 -0
- assets/images/icon-16.png +0 -0
- assets/images/icon-32.png +0 -0
- assets/images/navarrows.png +0 -0
- assets/images/navarrows@2x.png +0 -0
- assets/js/ditty-news-ticker.js +762 -0
- assets/js/jquery.easing.1.3.js +205 -0
- ditty-news-ticker.php +84 -0
- includes/edit-columns.php +163 -0
- includes/functions.php +366 -0
- includes/help.php +162 -0
- includes/meta-boxes.php +536 -0
- includes/metaboxer/images/arrow-resize-090.png +0 -0
- includes/metaboxer/images/attachment-audio.png +0 -0
- includes/metaboxer/images/attachment-delete.png +0 -0
- includes/metaboxer/images/attachment-image.png +0 -0
- includes/metaboxer/images/attachment-preview.png +0 -0
- includes/metaboxer/images/attachment-settings.png +0 -0
- includes/metaboxer/images/attachment-video.png +0 -0
- includes/metaboxer/images/attachment-vimeo.png +0 -0
- includes/metaboxer/images/attachment-youtube.png +0 -0
- includes/metaboxer/images/minus-circle.png +0 -0
- includes/metaboxer/images/plus-circle.png +0 -0
- includes/metaboxer/metaboxer-class.php +186 -0
- includes/metaboxer/metaboxer.css +524 -0
- includes/metaboxer/metaboxer.js +383 -0
- includes/metaboxer/metaboxer.php +944 -0
- includes/post-types.php +51 -0
- includes/scripts.php +594 -0
- includes/settings.php +227 -0
- includes/shortcodes.php +29 -0
- includes/taxonomies.php +42 -0
- includes/widget.php +164 -0
- readme.txt +72 -0
assets/css/style-admin.css
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/* Table of Contents
|
2 |
+
|
3 |
+
* Dashboard Menu Icon
|
4 |
+
* Edit Screen
|
5 |
+
|
6 |
+
*/
|
7 |
+
|
8 |
+
/* Dashboard Menu Icon
|
9 |
+
------------------------------------------------------------ */
|
10 |
+
|
11 |
+
#menu-posts-ditty_news_ticker .wp-menu-image {
|
12 |
+
background: url(../images/icon-16.png) no-repeat 6px -32px !important;
|
13 |
+
}
|
14 |
+
#menu-posts-ditty_news_ticker:hover .wp-menu-image,
|
15 |
+
#menu-posts-ditty_news_ticker.wp-has-current-submenu .wp-menu-image {
|
16 |
+
background-position:6px 0px !important;
|
17 |
+
}
|
18 |
+
|
19 |
+
/* Edit Screen
|
20 |
+
------------------------------------------------------------ */
|
21 |
+
|
22 |
+
.ditty_news_ticker_page_mtphr_dnt_settings #icon-themes,
|
23 |
+
#icon-edit.icon32-posts-ditty_news_ticker {
|
24 |
+
background: url(../images/icon-32.png) no-repeat;
|
25 |
+
}
|
26 |
+
.column-dnt_type,
|
27 |
+
.column-dnt_mode {
|
28 |
+
width: 10%;
|
29 |
+
}
|
30 |
+
.column-dnt_shortcode pre,
|
31 |
+
.column-dnt_shortcode p,
|
32 |
+
.column-dnt_function pre,
|
33 |
+
.column-dnt_function p {
|
34 |
+
margin: 0 !important;
|
35 |
+
}
|
36 |
+
.column-dnt_shortcode pre,
|
37 |
+
.column-dnt_function pre {
|
38 |
+
padding: 10px;
|
39 |
+
background: #FFF;
|
40 |
+
border: 1px solid #EEE;
|
41 |
+
-webkit-border-radius: 5px;
|
42 |
+
-moz-border-radius: 5px;
|
43 |
+
border-radius: 5px;
|
44 |
+
}
|
assets/css/style.css
ADDED
@@ -0,0 +1,130 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.mtphr-dnt-wrapper {
|
2 |
+
position: relative;
|
3 |
+
width: 100%;
|
4 |
+
}
|
5 |
+
.mtphr-dnt-inline-title {
|
6 |
+
float: left;
|
7 |
+
padding-right: 5px;
|
8 |
+
}
|
9 |
+
.mtphr-dnt-tick-container {
|
10 |
+
position: relative;
|
11 |
+
overflow: hidden;
|
12 |
+
}
|
13 |
+
.mtphr-dnt-tick {
|
14 |
+
display: none;
|
15 |
+
position: absolute;
|
16 |
+
white-space: nowrap;
|
17 |
+
margin: 0;
|
18 |
+
}
|
19 |
+
.mtphr-dnt-rotate .mtphr-dnt-tick {
|
20 |
+
white-space: normal;
|
21 |
+
}
|
22 |
+
.mtphr-dnt-list .mtphr-dnt-tick {
|
23 |
+
display: block;
|
24 |
+
position: relative;
|
25 |
+
white-space: normal;
|
26 |
+
}
|
27 |
+
|
28 |
+
/* Directional nav
|
29 |
+
------------------------------------------------------------ */
|
30 |
+
.mtphr-dnt-nav {
|
31 |
+
position: absolute;
|
32 |
+
top: 50%;
|
33 |
+
margin-top: -19px;
|
34 |
+
width: 38px;
|
35 |
+
height: 38px;
|
36 |
+
background: url(../images/navarrows.png) no-repeat;
|
37 |
+
background-size: 76px 38px;
|
38 |
+
}
|
39 |
+
.mtphr-dnt-nav:focus {
|
40 |
+
outline: none;
|
41 |
+
}
|
42 |
+
.mtphr-dnt-nav-prev {
|
43 |
+
left: 10px;
|
44 |
+
}
|
45 |
+
.mtphr-dnt-nav-next {
|
46 |
+
right: 10px;
|
47 |
+
background-position: -38px 0;
|
48 |
+
}
|
49 |
+
.mtphr-dnt-nav-hide {
|
50 |
+
opacity: 0;
|
51 |
+
-webkit-transition: opacity .3s linear;
|
52 |
+
-moz-transition: opacity .3s linear;
|
53 |
+
-o-transition: opacity .3s linear;
|
54 |
+
transition: opacity .3s linear;
|
55 |
+
}
|
56 |
+
.mtphr-dnt-tick-container:hover .mtphr-dnt-nav-hide {
|
57 |
+
opacity: 1;
|
58 |
+
}
|
59 |
+
|
60 |
+
/* Control nav
|
61 |
+
------------------------------------------------------------ */
|
62 |
+
|
63 |
+
.mtphr-dnt-control-links {
|
64 |
+
text-align: center;
|
65 |
+
}
|
66 |
+
.mtphr-dnt-control-number {
|
67 |
+
padding: 2px 5px;
|
68 |
+
}
|
69 |
+
.mtphr-dnt-control-button {
|
70 |
+
display: inline-block;
|
71 |
+
width: 18px;
|
72 |
+
height: 18px;
|
73 |
+
background: url(../images/button.png) no-repeat 0 -18px;
|
74 |
+
background-size: 18px 36px;
|
75 |
+
margin: 0 2px;
|
76 |
+
text-indent: -9999px;
|
77 |
+
}
|
78 |
+
.mtphr-dnt-control-button.active {
|
79 |
+
background-position: 0 0;
|
80 |
+
}
|
81 |
+
.mtphr-dnt-control-button:focus {
|
82 |
+
outline: none;
|
83 |
+
}
|
84 |
+
|
85 |
+
/* Add clearfix
|
86 |
+
------------------------------------------------------------ */
|
87 |
+
|
88 |
+
.clearfix {
|
89 |
+
*zoom: 1;
|
90 |
+
}
|
91 |
+
.clearfix:before,
|
92 |
+
.clearfix:after {
|
93 |
+
display: table;
|
94 |
+
line-height: 0;
|
95 |
+
content: "";
|
96 |
+
}
|
97 |
+
.clearfix:after {
|
98 |
+
clear: both;
|
99 |
+
}
|
100 |
+
|
101 |
+
/* Retina displays
|
102 |
+
------------------------------------------------------------ */
|
103 |
+
|
104 |
+
@media only screen and (-Webkit-min-device-pixel-ratio: 1.5),
|
105 |
+
only screen and (-moz-min-device-pixel-ratio: 1.5),
|
106 |
+
only screen and (-o-min-device-pixel-ratio: 3/2),
|
107 |
+
only screen and (min-device-pixel-ratio: 1.5) {
|
108 |
+
|
109 |
+
.mtphr-dnt-nav {
|
110 |
+
background-image: url(../images/navarrows@2x.png);
|
111 |
+
}
|
112 |
+
.mtphr-dnt-control-button {
|
113 |
+
background-image: url(../images/button@2x.png);
|
114 |
+
}
|
115 |
+
}
|
116 |
+
|
117 |
+
|
118 |
+
|
119 |
+
|
120 |
+
/**
|
121 |
+
* Default styles
|
122 |
+
*
|
123 |
+
* @since 1.0.0
|
124 |
+
*/
|
125 |
+
.mtphr-dnt-styled .mtphr-dnt-posts-nav-prev {
|
126 |
+
float: left;
|
127 |
+
}
|
128 |
+
.mtphr-dnt-styled .mtphr-dnt-posts-nav-next {
|
129 |
+
float: right;
|
130 |
+
}
|
assets/images/button.png
ADDED
Binary file
|
assets/images/button@2x.png
ADDED
Binary file
|
assets/images/icon-16.png
ADDED
Binary file
|
assets/images/icon-32.png
ADDED
Binary file
|
assets/images/navarrows.png
ADDED
Binary file
|
assets/images/navarrows@2x.png
ADDED
Binary file
|
assets/js/ditty-news-ticker.js
ADDED
@@ -0,0 +1,762 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* Ditty News Ticker
|
3 |
+
* Date: 1/15/2013
|
4 |
+
*
|
5 |
+
* @author Metaphor Creations
|
6 |
+
* @version 1.0.0
|
7 |
+
*
|
8 |
+
**/
|
9 |
+
|
10 |
+
( function($) {
|
11 |
+
|
12 |
+
var methods = {
|
13 |
+
|
14 |
+
init : function( options ) {
|
15 |
+
|
16 |
+
return this.each( function(){
|
17 |
+
|
18 |
+
// Create default options
|
19 |
+
var settings = {
|
20 |
+
type : 'scroll',
|
21 |
+
scroll_direction : 'left',
|
22 |
+
scroll_speed : 10,
|
23 |
+
scroll_pause : 0,
|
24 |
+
scroll_spacing : 40,
|
25 |
+
scroll_units : 1,
|
26 |
+
rotate_type : 'fade',
|
27 |
+
auto_rotate : 0,
|
28 |
+
rotate_delay : 10,
|
29 |
+
rotate_pause : 0,
|
30 |
+
rotate_speed : 10,
|
31 |
+
rotate_ease : 'easeOutExpo',
|
32 |
+
nav_reverse : 0,
|
33 |
+
before_change : function(){},
|
34 |
+
after_change : function(){},
|
35 |
+
after_load : function(){}
|
36 |
+
};
|
37 |
+
|
38 |
+
// Useful variables. Play carefully.
|
39 |
+
var vars = {
|
40 |
+
tick_count : 0,
|
41 |
+
current_tick : 0,
|
42 |
+
reverse : 0,
|
43 |
+
running : 0
|
44 |
+
};
|
45 |
+
|
46 |
+
// Add any set options
|
47 |
+
if (options) {
|
48 |
+
$.extend(settings, options);
|
49 |
+
}
|
50 |
+
|
51 |
+
// Create variables
|
52 |
+
var $ticker = $(this).find('.mtphr-dnt-tick-container'),
|
53 |
+
$nav_prev = $ticker.find('.mtphr-dnt-nav-prev'),
|
54 |
+
$nav_next = $ticker.find('.mtphr-dnt-nav-next'),
|
55 |
+
$nav_controls = $ticker.siblings('.mtphr-dnt-control-links'),
|
56 |
+
ticker_width = $ticker.width(),
|
57 |
+
ticker_height = 0,
|
58 |
+
ticks = [],
|
59 |
+
ticker_scroll,
|
60 |
+
ticker_delay,
|
61 |
+
rotate_adjustment = settings.rotate_type,
|
62 |
+
after_change_timeout,
|
63 |
+
ticker_pause = false,
|
64 |
+
touch_down_x,
|
65 |
+
touch_down_y,
|
66 |
+
touch_link = '',
|
67 |
+
touch_target = '';
|
68 |
+
|
69 |
+
// Add the vars
|
70 |
+
$ticker.data('ditty:vars', vars);
|
71 |
+
|
72 |
+
// Save the tick count & total
|
73 |
+
vars.tick_count = $ticker.find('.mtphr-dnt-tick').length;
|
74 |
+
|
75 |
+
// Start the first tick
|
76 |
+
if( vars.tick_count > 0 ) {
|
77 |
+
|
78 |
+
// Setup a ticker scroll
|
79 |
+
if( settings.type == 'scroll' ) {
|
80 |
+
mtphr_dnt_scroll_setup();
|
81 |
+
|
82 |
+
// Setup a ticker rotator
|
83 |
+
} else if( settings.type == 'rotate' ) {
|
84 |
+
mtphr_dnt_rotator_setup();
|
85 |
+
}
|
86 |
+
}
|
87 |
+
|
88 |
+
|
89 |
+
|
90 |
+
/**
|
91 |
+
* Setup the ticker scroll
|
92 |
+
*
|
93 |
+
* @since 1.0.0
|
94 |
+
*/
|
95 |
+
function mtphr_dnt_scroll_setup() {
|
96 |
+
|
97 |
+
// Loop through the tick items
|
98 |
+
$ticker.find('.mtphr-dnt-tick').each( function(index) {
|
99 |
+
|
100 |
+
// Find the greatest tick height
|
101 |
+
if( $(this).height() > ticker_height ) {
|
102 |
+
ticker_height = $(this).height();
|
103 |
+
}
|
104 |
+
|
105 |
+
if( settings.scroll_direction == 'up' || settings.scroll_direction == 'down' ) {
|
106 |
+
$(this).css('height', 'auto');
|
107 |
+
}
|
108 |
+
});
|
109 |
+
|
110 |
+
// Set the ticker height
|
111 |
+
$ticker.css('height',ticker_height+'px');
|
112 |
+
|
113 |
+
// Loop through the tick items
|
114 |
+
$ticker.find('.mtphr-dnt-tick').each( function(index) {
|
115 |
+
|
116 |
+
// Set the tick position
|
117 |
+
var position;
|
118 |
+
|
119 |
+
switch( settings.scroll_direction ) {
|
120 |
+
case 'left':
|
121 |
+
position = ticker_width;
|
122 |
+
$(this).css('left',position+'px');
|
123 |
+
break;
|
124 |
+
|
125 |
+
case 'right':
|
126 |
+
position = parseInt('-'+$(this).width());
|
127 |
+
$(this).css('left',position+'px');
|
128 |
+
break;
|
129 |
+
|
130 |
+
case 'up':
|
131 |
+
position = parseInt(ticker_height);
|
132 |
+
$(this).css('top',position+'px');
|
133 |
+
break;
|
134 |
+
|
135 |
+
case 'down':
|
136 |
+
position = parseInt('-'+$(this).height());;
|
137 |
+
$(this).css('top',position+'px');
|
138 |
+
break;
|
139 |
+
}
|
140 |
+
|
141 |
+
// Make sure the ticker is visible
|
142 |
+
$(this).show();
|
143 |
+
|
144 |
+
// Add the tick data
|
145 |
+
var tick = [{'headline':$(this), 'width':$(this).width(), 'height':$(this).height(), 'position':position, 'reset':position, 'visible':false}];
|
146 |
+
|
147 |
+
// Add the tick to the array
|
148 |
+
ticks.push(tick);
|
149 |
+
});
|
150 |
+
|
151 |
+
// Set the first tick visibility
|
152 |
+
ticks[vars.current_tick][0].visible = true;
|
153 |
+
|
154 |
+
// Start the scroll loop
|
155 |
+
mtphr_dnt_scroll_loop();
|
156 |
+
|
157 |
+
// Clear the loop on mouse hover
|
158 |
+
$ticker.hover(
|
159 |
+
function () {
|
160 |
+
if( settings.scroll_pause ) {
|
161 |
+
clearInterval( ticker_scroll );
|
162 |
+
}
|
163 |
+
},
|
164 |
+
function () {
|
165 |
+
if( settings.scroll_pause ) {
|
166 |
+
mtphr_dnt_scroll_loop();
|
167 |
+
}
|
168 |
+
}
|
169 |
+
);
|
170 |
+
}
|
171 |
+
|
172 |
+
/**
|
173 |
+
* Create the ticker scroll loop
|
174 |
+
*
|
175 |
+
* @since 1.0.0
|
176 |
+
*/
|
177 |
+
function mtphr_dnt_scroll_loop() {
|
178 |
+
|
179 |
+
// Start the ticker timer
|
180 |
+
ticker_scroll = setInterval( function() {
|
181 |
+
|
182 |
+
for( var i=0; i<vars.tick_count; i++ ) {
|
183 |
+
|
184 |
+
if( ticks[i][0].visible == true ) {
|
185 |
+
|
186 |
+
var pos = 0;
|
187 |
+
|
188 |
+
switch( settings.scroll_direction ) {
|
189 |
+
case 'left':
|
190 |
+
pos = mtphr_dnt_scroll_left(i);
|
191 |
+
ticks[i][0].headline.css('left',pos+'px');
|
192 |
+
break;
|
193 |
+
|
194 |
+
case 'right':
|
195 |
+
pos = mtphr_dnt_scroll_right(i);
|
196 |
+
ticks[i][0].headline.css('left',pos+'px');
|
197 |
+
break;
|
198 |
+
|
199 |
+
case 'up':
|
200 |
+
pos = mtphr_dnt_scroll_up(i);
|
201 |
+
ticks[i][0].headline.css('top',pos+'px');
|
202 |
+
break;
|
203 |
+
|
204 |
+
case 'down':
|
205 |
+
pos = mtphr_dnt_scroll_down(i);
|
206 |
+
ticks[i][0].headline.css('top',pos+'px');
|
207 |
+
break;
|
208 |
+
}
|
209 |
+
|
210 |
+
ticks[i][0].position = pos;
|
211 |
+
}
|
212 |
+
}
|
213 |
+
}, parseFloat(100/settings.scroll_speed));
|
214 |
+
}
|
215 |
+
|
216 |
+
/**
|
217 |
+
* Scroll the ticker left
|
218 |
+
*
|
219 |
+
* @since 1.0.0
|
220 |
+
*/
|
221 |
+
function mtphr_dnt_scroll_left( i ) {
|
222 |
+
|
223 |
+
// Find the new position
|
224 |
+
var pos = ticks[i][0].position - settings.scroll_units;
|
225 |
+
|
226 |
+
// Reset the tick if off the screen
|
227 |
+
if( pos < -ticks[i][0].width ) {
|
228 |
+
pos = mtphr_dnt_scroll_check_current(i);
|
229 |
+
} else if( pos < ticker_width-ticks[i][0].width-settings.scroll_spacing ) {
|
230 |
+
mtphr_dnt_scroll_check_next(i);
|
231 |
+
}
|
232 |
+
|
233 |
+
return pos;
|
234 |
+
}
|
235 |
+
|
236 |
+
/**
|
237 |
+
* Scroll the ticker right
|
238 |
+
*
|
239 |
+
* @since 1.0.0
|
240 |
+
*/
|
241 |
+
function mtphr_dnt_scroll_right( i ) {
|
242 |
+
|
243 |
+
// Find the new position
|
244 |
+
var pos = ticks[i][0].position + settings.scroll_units;
|
245 |
+
|
246 |
+
// Reset the tick if off the screen
|
247 |
+
if( pos > ticker_width ) {
|
248 |
+
pos = mtphr_dnt_scroll_check_current(i);
|
249 |
+
} else if( pos > settings.scroll_spacing ) {
|
250 |
+
mtphr_dnt_scroll_check_next(i);
|
251 |
+
}
|
252 |
+
|
253 |
+
return pos;
|
254 |
+
}
|
255 |
+
|
256 |
+
/**
|
257 |
+
* Scroll the ticker up
|
258 |
+
*
|
259 |
+
* @since 1.0.0
|
260 |
+
*/
|
261 |
+
function mtphr_dnt_scroll_up( i ) {
|
262 |
+
|
263 |
+
// Find the new position
|
264 |
+
var pos = ticks[i][0].position - settings.scroll_units;
|
265 |
+
|
266 |
+
// Reset the tick if off the screen
|
267 |
+
if( pos < -ticks[i][0].height ) {
|
268 |
+
pos = mtphr_dnt_scroll_check_current(i);
|
269 |
+
} else if( pos < ticker_height-ticks[i][0].height-settings.scroll_spacing ) {
|
270 |
+
mtphr_dnt_scroll_check_next(i);
|
271 |
+
}
|
272 |
+
|
273 |
+
return pos;
|
274 |
+
}
|
275 |
+
|
276 |
+
/**
|
277 |
+
* Scroll the ticker down
|
278 |
+
*
|
279 |
+
* @since 1.0.0
|
280 |
+
*/
|
281 |
+
function mtphr_dnt_scroll_down( i ) {
|
282 |
+
|
283 |
+
// Find the new position
|
284 |
+
var pos = ticks[i][0].position + settings.scroll_units;
|
285 |
+
|
286 |
+
// Reset the tick if off the screen
|
287 |
+
if( pos > ticker_height ) {
|
288 |
+
pos = mtphr_dnt_scroll_check_current(i);
|
289 |
+
} else if( pos > settings.scroll_spacing ) {
|
290 |
+
mtphr_dnt_scroll_check_next(i);
|
291 |
+
}
|
292 |
+
|
293 |
+
return pos;
|
294 |
+
}
|
295 |
+
|
296 |
+
/**
|
297 |
+
* Check the current tick position
|
298 |
+
*
|
299 |
+
* @since 1.0.0
|
300 |
+
*/
|
301 |
+
function mtphr_dnt_scroll_check_current( i ) {
|
302 |
+
|
303 |
+
if( vars.tick_count > 1 ) {
|
304 |
+
ticks[i][0].visible = false;
|
305 |
+
}
|
306 |
+
|
307 |
+
return ticks[i][0].reset;
|
308 |
+
}
|
309 |
+
|
310 |
+
/**
|
311 |
+
* Check the next tick visibility
|
312 |
+
*
|
313 |
+
* @since 1.0.0
|
314 |
+
*/
|
315 |
+
function mtphr_dnt_scroll_check_next( i ) {
|
316 |
+
|
317 |
+
if( i==(vars.tick_count-1) ) {
|
318 |
+
ticks[0][0].visible = true;
|
319 |
+
} else {
|
320 |
+
ticks[(i+1)][0].visible = true;
|
321 |
+
}
|
322 |
+
}
|
323 |
+
|
324 |
+
/**
|
325 |
+
* Resize the scroll ticks
|
326 |
+
*
|
327 |
+
* @since 1.0.0
|
328 |
+
*/
|
329 |
+
function mtphr_dnt_scroll_resize_ticks() {
|
330 |
+
|
331 |
+
for( var i=0; i<vars.tick_count; i++ ) {
|
332 |
+
|
333 |
+
// Set the tick position
|
334 |
+
var position;
|
335 |
+
|
336 |
+
var $tick = ticks[i][0].headline;
|
337 |
+
|
338 |
+
switch( settings.scroll_direction ) {
|
339 |
+
case 'left':
|
340 |
+
position = ticker_width;
|
341 |
+
if( ticks[i][0].visible == false ) {
|
342 |
+
$tick.css('left',position+'px');
|
343 |
+
}
|
344 |
+
break;
|
345 |
+
|
346 |
+
case 'right':
|
347 |
+
position = parseInt('-'+$tick.width());
|
348 |
+
if( ticks[i][0].visible == false ) {
|
349 |
+
$tick.css('left',position+'px');
|
350 |
+
}
|
351 |
+
break;
|
352 |
+
|
353 |
+
case 'up':
|
354 |
+
position = parseInt(ticker_height);
|
355 |
+
if( ticks[i][0].visible == false ) {
|
356 |
+
$tick.css('top',position+'px');
|
357 |
+
}
|
358 |
+
break;
|
359 |
+
|
360 |
+
case 'down':
|
361 |
+
position = parseInt('-'+$tick.height());
|
362 |
+
if( ticks[i][0].visible == false ) {
|
363 |
+
$tick.css('top',position+'px');
|
364 |
+
}
|
365 |
+
break;
|
366 |
+
}
|
367 |
+
|
368 |
+
// Adjust the tick data
|
369 |
+
ticks[i][0].width = $tick.width();
|
370 |
+
ticks[i][0].height = $tick.height();
|
371 |
+
if( ticks[i][0].visible == false ) {
|
372 |
+
ticks[i][0].position = position;
|
373 |
+
}
|
374 |
+
ticks[i][0].reset = position;
|
375 |
+
}
|
376 |
+
}
|
377 |
+
|
378 |
+
|
379 |
+
|
380 |
+
|
381 |
+
/**
|
382 |
+
* Setup the ticker rotator
|
383 |
+
*
|
384 |
+
* @since 1.0.0
|
385 |
+
*/
|
386 |
+
function mtphr_dnt_rotator_setup() {
|
387 |
+
|
388 |
+
// Loop through the tick items
|
389 |
+
$ticker.find('.mtphr-dnt-tick').each( function(index) {
|
390 |
+
|
391 |
+
// Add the tick to the array
|
392 |
+
ticks.push($(this));
|
393 |
+
|
394 |
+
});
|
395 |
+
|
396 |
+
// Resize the ticks
|
397 |
+
mtphr_dnt_rotator_resize_ticks();
|
398 |
+
|
399 |
+
// Find the rotation type and create the dynamic rotation init function
|
400 |
+
var rotate_init_name = 'mtphr_dnt_rotator_'+settings.rotate_type+'_init';
|
401 |
+
var mtphr_dnt_rotator_type_init = eval('('+rotate_init_name+')');
|
402 |
+
mtphr_dnt_rotator_type_init( $ticker, ticks, parseInt(settings.rotate_speed*100), settings.rotate_ease );
|
403 |
+
mtphr_dnt_rotator_update_links( 0 );
|
404 |
+
|
405 |
+
// Start the rotator rotate
|
406 |
+
if( settings.auto_rotate ) {
|
407 |
+
mtphr_dnt_rotator_delay();
|
408 |
+
}
|
409 |
+
|
410 |
+
// Clear the loop on mouse hover
|
411 |
+
$ticker.hover(
|
412 |
+
function () {
|
413 |
+
if( settings.auto_rotate && settings.rotate_pause ) {
|
414 |
+
clearInterval( ticker_delay );
|
415 |
+
}
|
416 |
+
},
|
417 |
+
function () {
|
418 |
+
if( settings.auto_rotate && settings.rotate_pause ) {
|
419 |
+
mtphr_dnt_rotator_delay();
|
420 |
+
}
|
421 |
+
}
|
422 |
+
);
|
423 |
+
}
|
424 |
+
|
425 |
+
/**
|
426 |
+
* Create the ticker rotator loop
|
427 |
+
*
|
428 |
+
* @since 1.0.0
|
429 |
+
*/
|
430 |
+
function mtphr_dnt_rotator_delay() {
|
431 |
+
|
432 |
+
// Start the ticker timer
|
433 |
+
ticker_delay = setInterval( function() {
|
434 |
+
|
435 |
+
// Find the new tick
|
436 |
+
var new_tick = parseInt(vars.current_tick + 1);
|
437 |
+
if( new_tick == vars.tick_count ) {
|
438 |
+
new_tick = 0;
|
439 |
+
}
|
440 |
+
|
441 |
+
mtphr_dnt_rotator_update( new_tick );
|
442 |
+
|
443 |
+
}, parseInt(settings.rotate_delay*1000));
|
444 |
+
}
|
445 |
+
|
446 |
+
/**
|
447 |
+
* Create the rotator update call
|
448 |
+
*
|
449 |
+
* @since 1.0.0
|
450 |
+
*/
|
451 |
+
function mtphr_dnt_rotator_update( new_tick ) {
|
452 |
+
|
453 |
+
// Clear the interval
|
454 |
+
if( settings.auto_rotate ) {
|
455 |
+
clearInterval( ticker_delay );
|
456 |
+
}
|
457 |
+
|
458 |
+
// Trigger the before change callback
|
459 |
+
settings.before_change.call( this, $ticker );
|
460 |
+
|
461 |
+
// Set the running variable
|
462 |
+
vars.running = 1;
|
463 |
+
|
464 |
+
// Rotate the current tick out
|
465 |
+
mtphr_dnt_rotator_out( new_tick );
|
466 |
+
|
467 |
+
// Rotate the new tick in
|
468 |
+
mtphr_dnt_rotator_in( new_tick );
|
469 |
+
|
470 |
+
// Set the current tick
|
471 |
+
vars.current_tick = new_tick;
|
472 |
+
|
473 |
+
// Trigger the after change callback
|
474 |
+
after_change_timeout = setTimeout( function() {
|
475 |
+
|
476 |
+
settings.after_change.call( this, $ticker );
|
477 |
+
|
478 |
+
// Reset the rotator type & variables
|
479 |
+
rotate_adjustment = settings.rotate_type;
|
480 |
+
vars.reverse = 0;
|
481 |
+
vars.running = 0;
|
482 |
+
|
483 |
+
// Restart the interval
|
484 |
+
if( settings.auto_rotate ) {
|
485 |
+
mtphr_dnt_rotator_delay();
|
486 |
+
}
|
487 |
+
|
488 |
+
}, parseInt(settings.rotate_speed*100) );
|
489 |
+
}
|
490 |
+
|
491 |
+
/**
|
492 |
+
* Update the control links
|
493 |
+
*
|
494 |
+
* @since 1.0.0
|
495 |
+
*/
|
496 |
+
function mtphr_dnt_rotator_update_links( new_tick ) {
|
497 |
+
|
498 |
+
if( $nav_controls ) {
|
499 |
+
$nav_controls.children('a').removeClass('active');
|
500 |
+
$nav_controls.children('a[href="'+new_tick+'"]').addClass('active');
|
501 |
+
}
|
502 |
+
}
|
503 |
+
|
504 |
+
/**
|
505 |
+
* Create the rotator in function calls
|
506 |
+
*
|
507 |
+
* @since 1.0.0
|
508 |
+
*/
|
509 |
+
function mtphr_dnt_rotator_in( new_tick ) {
|
510 |
+
|
511 |
+
// Update the links
|
512 |
+
mtphr_dnt_rotator_update_links( new_tick );
|
513 |
+
|
514 |
+
// Find the rotation type and create the dynamic rotation in function
|
515 |
+
var rotate_in_name = 'mtphr_dnt_rotator_'+rotate_adjustment+'_in';
|
516 |
+
var mtphr_dnt_rotator_type_in = eval('('+rotate_in_name+')');
|
517 |
+
mtphr_dnt_rotator_type_in( $ticker, $(ticks[new_tick]), $(ticks[vars.current_tick]), parseInt(settings.rotate_speed*100), settings.rotate_ease );
|
518 |
+
}
|
519 |
+
|
520 |
+
/**
|
521 |
+
* Create the rotator out function calls
|
522 |
+
*
|
523 |
+
* @since 1.0.0
|
524 |
+
*/
|
525 |
+
function mtphr_dnt_rotator_out( new_tick ) {
|
526 |
+
|
527 |
+
// Find the rotation type and create the dynamic rotation out function
|
528 |
+
var rotate_out_name = 'mtphr_dnt_rotator_'+rotate_adjustment+'_out';
|
529 |
+
var mtphr_dnt_rotator_type_out = eval('('+rotate_out_name+')');
|
530 |
+
mtphr_dnt_rotator_type_out( $ticker, $(ticks[vars.current_tick]), $(ticks[new_tick]), parseInt(settings.rotate_speed*100), settings.rotate_ease );
|
531 |
+
}
|
532 |
+
|
533 |
+
/**
|
534 |
+
* Resize the rotator ticks
|
535 |
+
*
|
536 |
+
* @since 1.0.0
|
537 |
+
*/
|
538 |
+
function mtphr_dnt_rotator_resize_ticks() {
|
539 |
+
|
540 |
+
for( var i=0; i<vars.tick_count; i++ ) {
|
541 |
+
|
542 |
+
// Set the width of the tick
|
543 |
+
$(ticks[i]).width( ticker_width+'px' );
|
544 |
+
}
|
545 |
+
}
|
546 |
+
|
547 |
+
|
548 |
+
|
549 |
+
|
550 |
+
/**
|
551 |
+
* Navigation clicks
|
552 |
+
*
|
553 |
+
* @since 1.0.0
|
554 |
+
*/
|
555 |
+
if( $nav_prev && settings.type == 'rotate' ) {
|
556 |
+
|
557 |
+
$nav_prev.bind('click', function( e ) {
|
558 |
+
e.preventDefault();
|
559 |
+
|
560 |
+
if(vars.running) return false;
|
561 |
+
|
562 |
+
// Find the new tick
|
563 |
+
var new_tick = parseInt(vars.current_tick-1);
|
564 |
+
if( new_tick < 0 ) {
|
565 |
+
new_tick = vars.tick_count-1;
|
566 |
+
}
|
567 |
+
if( settings.nav_reverse ) {
|
568 |
+
if( settings.rotate_type == 'slide_left' ) {
|
569 |
+
rotate_adjustment = 'slide_right';
|
570 |
+
} else if( settings.rotate_type == 'slide_right' ) {
|
571 |
+
rotate_adjustment = 'slide_left';
|
572 |
+
} else if( settings.rotate_type == 'slide_down' ) {
|
573 |
+
rotate_adjustment = 'slide_up';
|
574 |
+
} else if( settings.rotate_type == 'slide_up' ) {
|
575 |
+
rotate_adjustment = 'slide_down';
|
576 |
+
}
|
577 |
+
vars.reverse = 1;
|
578 |
+
}
|
579 |
+
mtphr_dnt_rotator_update( new_tick );
|
580 |
+
});
|
581 |
+
|
582 |
+
$nav_next.bind('click', function(e) {
|
583 |
+
e.preventDefault();
|
584 |
+
|
585 |
+
if(vars.running) return false;
|
586 |
+
|
587 |
+
// Find the new tick
|
588 |
+
var new_tick = parseInt(vars.current_tick + 1);
|
589 |
+
if( new_tick == vars.tick_count ) {
|
590 |
+
new_tick = 0;
|
591 |
+
}
|
592 |
+
mtphr_dnt_rotator_update( new_tick );
|
593 |
+
});
|
594 |
+
}
|
595 |
+
|
596 |
+
|
597 |
+
|
598 |
+
|
599 |
+
/**
|
600 |
+
* Nav controls
|
601 |
+
*
|
602 |
+
* @since 1.0.2
|
603 |
+
*/
|
604 |
+
if( $nav_controls && settings.type == 'rotate' ) {
|
605 |
+
|
606 |
+
$nav_controls.children('a').bind('click', function( e ) {
|
607 |
+
e.preventDefault();
|
608 |
+
|
609 |
+
// Find the new tick
|
610 |
+
var new_tick = parseInt( $(this).attr('href') );
|
611 |
+
|
612 |
+
if(vars.running) return false;
|
613 |
+
if(new_tick == vars.current_tick) return false;
|
614 |
+
|
615 |
+
var reverse = ( new_tick < vars.current_tick ) ? 1 : 0;
|
616 |
+
|
617 |
+
if( settings.nav_reverse && reverse ) {
|
618 |
+
if( settings.rotate_type == 'slide_left' ) {
|
619 |
+
rotate_adjustment = 'slide_right';
|
620 |
+
} else if( settings.rotate_type == 'slide_right' ) {
|
621 |
+
rotate_adjustment = 'slide_left';
|
622 |
+
} else if( settings.rotate_type == 'slide_down' ) {
|
623 |
+
rotate_adjustment = 'slide_up';
|
624 |
+
} else if( settings.rotate_type == 'slide_up' ) {
|
625 |
+
rotate_adjustment = 'slide_down';
|
626 |
+
}
|
627 |
+
vars.reverse = 1;
|
628 |
+
}
|
629 |
+
mtphr_dnt_rotator_update( new_tick );
|
630 |
+
});
|
631 |
+
}
|
632 |
+
|
633 |
+
|
634 |
+
|
635 |
+
|
636 |
+
/**
|
637 |
+
* Mobile touch support
|
638 |
+
*
|
639 |
+
* @since 1.0.0
|
640 |
+
*/
|
641 |
+
if( settings.type == 'rotate' ) {
|
642 |
+
|
643 |
+
/*
|
644 |
+
$ticker.bind( 'touchstart', function(e) {
|
645 |
+
|
646 |
+
e.preventDefault();
|
647 |
+
|
648 |
+
// Save the target
|
649 |
+
touch_link = $(e.target).attr('href');
|
650 |
+
touch_target = $(e.target).attr('target');;
|
651 |
+
|
652 |
+
var touch = e.originalEvent.touches[0] || e.originalEvent.changedTouches[0];
|
653 |
+
touch_down_x = touch.pageX;
|
654 |
+
touch_down_y = touch.pageY;
|
655 |
+
});
|
656 |
+
|
657 |
+
$ticker.bind( 'touchend', function(e) {
|
658 |
+
|
659 |
+
if(vars.running) return false;
|
660 |
+
|
661 |
+
var touch = e.originalEvent.touches[0] || e.originalEvent.changedTouches[0];
|
662 |
+
touch_up_x = touch.pageX;
|
663 |
+
touch_up_y = touch.pageY;
|
664 |
+
|
665 |
+
if( Math.abs(touch_down_x-touch_up_x) > 100 ) {
|
666 |
+
if ( touch_down_x-touch_up_x > 0 ) {
|
667 |
+
|
668 |
+
// Find the new tick
|
669 |
+
var new_tick = parseInt(vars.current_tick + 1);
|
670 |
+
if( new_tick == vars.tick_count ) {
|
671 |
+
new_tick = 0;
|
672 |
+
}
|
673 |
+
mtphr_dnt_rotator_update( new_tick );
|
674 |
+
|
675 |
+
} else {
|
676 |
+
|
677 |
+
// Find the new tick
|
678 |
+
var new_tick = parseInt(vars.current_tick-1);
|
679 |
+
if( new_tick < 0 ) {
|
680 |
+
new_tick = vars.tick_count-1;
|
681 |
+
}
|
682 |
+
if( settings.nav_reverse ) {
|
683 |
+
if( settings.rotate_type == 'slide_left' ) {
|
684 |
+
rotate_adjustment = 'slide_right';
|
685 |
+
} else if( settings.rotate_type == 'slide_right' ) {
|
686 |
+
rotate_adjustment = 'slide_left';
|
687 |
+
} else if( settings.rotate_type == 'slide_down' ) {
|
688 |
+
rotate_adjustment = 'slide_up';
|
689 |
+
} else if( settings.rotate_type == 'slide_up' ) {
|
690 |
+
rotate_adjustment = 'slide_down';
|
691 |
+
}
|
692 |
+
vars.reverse = 1;
|
693 |
+
}
|
694 |
+
mtphr_dnt_rotator_update( new_tick );
|
695 |
+
}
|
696 |
+
} else {
|
697 |
+
|
698 |
+
if( touch_link != '' ) {
|
699 |
+
if( touch_target == '_blank' ) {
|
700 |
+
window.open( touch_link );
|
701 |
+
} else {
|
702 |
+
window.location( touch_link );
|
703 |
+
}
|
704 |
+
}
|
705 |
+
|
706 |
+
touch_link = '';
|
707 |
+
touch_target = '';
|
708 |
+
}
|
709 |
+
});
|
710 |
+
*/
|
711 |
+
}
|
712 |
+
|
713 |
+
|
714 |
+
|
715 |
+
|
716 |
+
/**
|
717 |
+
* Resize listener
|
718 |
+
* Reset the ticker width
|
719 |
+
*
|
720 |
+
* @since 1.0.0
|
721 |
+
*/
|
722 |
+
$(window).resize( function() {
|
723 |
+
ticker_width = $ticker.width();
|
724 |
+
|
725 |
+
if( settings.type == 'scroll' ) {
|
726 |
+
mtphr_dnt_scroll_resize_ticks();
|
727 |
+
} else if( settings.type == 'rotate' ) {
|
728 |
+
mtphr_dnt_rotator_resize_ticks();
|
729 |
+
}
|
730 |
+
});
|
731 |
+
|
732 |
+
|
733 |
+
|
734 |
+
|
735 |
+
// Trigger the afterLoad callback
|
736 |
+
settings.after_load.call(this, $ticker);
|
737 |
+
|
738 |
+
});
|
739 |
+
}
|
740 |
+
};
|
741 |
+
|
742 |
+
|
743 |
+
|
744 |
+
|
745 |
+
|
746 |
+
/**
|
747 |
+
* Setup the class
|
748 |
+
*
|
749 |
+
* @since 1.0.0
|
750 |
+
*/
|
751 |
+
$.fn.ditty_news_ticker = function( method ) {
|
752 |
+
|
753 |
+
if ( methods[method] ) {
|
754 |
+
return methods[method].apply( this, Array.prototype.slice.call(arguments, 1) );
|
755 |
+
} else if ( typeof method === 'object' || !method ) {
|
756 |
+
return methods.init.apply( this, arguments );
|
757 |
+
} else {
|
758 |
+
$.error( 'Method ' + method + ' does not exist in ditty_news_ticker' );
|
759 |
+
}
|
760 |
+
};
|
761 |
+
|
762 |
+
})( jQuery );
|
assets/js/jquery.easing.1.3.js
ADDED
@@ -0,0 +1,205 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*
|
2 |
+
* jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
|
3 |
+
*
|
4 |
+
* Uses the built in easing capabilities added In jQuery 1.1
|
5 |
+
* to offer multiple easing options
|
6 |
+
*
|
7 |
+
* TERMS OF USE - jQuery Easing
|
8 |
+
*
|
9 |
+
* Open source under the BSD License.
|
10 |
+
*
|
11 |
+
* Copyright � 2008 George McGinley Smith
|
12 |
+
* All rights reserved.
|
13 |
+
*
|
14 |
+
* Redistribution and use in source and binary forms, with or without modification,
|
15 |
+
* are permitted provided that the following conditions are met:
|
16 |
+
*
|
17 |
+
* Redistributions of source code must retain the above copyright notice, this list of
|
18 |
+
* conditions and the following disclaimer.
|
19 |
+
* Redistributions in binary form must reproduce the above copyright notice, this list
|
20 |
+
* of conditions and the following disclaimer in the documentation and/or other materials
|
21 |
+
* provided with the distribution.
|
22 |
+
*
|
23 |
+
* Neither the name of the author nor the names of contributors may be used to endorse
|
24 |
+
* or promote products derived from this software without specific prior written permission.
|
25 |
+
*
|
26 |
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
27 |
+
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
28 |
+
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
29 |
+
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
30 |
+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
31 |
+
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
32 |
+
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
33 |
+
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
34 |
+
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
35 |
+
*
|
36 |
+
*/
|
37 |
+
|
38 |
+
// t: current time, b: begInnIng value, c: change In value, d: duration
|
39 |
+
jQuery.easing['jswing'] = jQuery.easing['swing'];
|
40 |
+
|
41 |
+
jQuery.extend( jQuery.easing,
|
42 |
+
{
|
43 |
+
def: 'easeOutQuad',
|
44 |
+
swing: function (x, t, b, c, d) {
|
45 |
+
//alert(jQuery.easing.default);
|
46 |
+
return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
|
47 |
+
},
|
48 |
+
easeInQuad: function (x, t, b, c, d) {
|
49 |
+
return c*(t/=d)*t + b;
|
50 |
+
},
|
51 |
+
easeOutQuad: function (x, t, b, c, d) {
|
52 |
+
return -c *(t/=d)*(t-2) + b;
|
53 |
+
},
|
54 |
+
easeInOutQuad: function (x, t, b, c, d) {
|
55 |
+
if ((t/=d/2) < 1) return c/2*t*t + b;
|
56 |
+
return -c/2 * ((--t)*(t-2) - 1) + b;
|
57 |
+
},
|
58 |
+
easeInCubic: function (x, t, b, c, d) {
|
59 |
+
return c*(t/=d)*t*t + b;
|
60 |
+
},
|
61 |
+
easeOutCubic: function (x, t, b, c, d) {
|
62 |
+
return c*((t=t/d-1)*t*t + 1) + b;
|
63 |
+
},
|
64 |
+
easeInOutCubic: function (x, t, b, c, d) {
|
65 |
+
if ((t/=d/2) < 1) return c/2*t*t*t + b;
|
66 |
+
return c/2*((t-=2)*t*t + 2) + b;
|
67 |
+
},
|
68 |
+
easeInQuart: function (x, t, b, c, d) {
|
69 |
+
return c*(t/=d)*t*t*t + b;
|
70 |
+
},
|
71 |
+
easeOutQuart: function (x, t, b, c, d) {
|
72 |
+
return -c * ((t=t/d-1)*t*t*t - 1) + b;
|
73 |
+
},
|
74 |
+
easeInOutQuart: function (x, t, b, c, d) {
|
75 |
+
if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
|
76 |
+
return -c/2 * ((t-=2)*t*t*t - 2) + b;
|
77 |
+
},
|
78 |
+
easeInQuint: function (x, t, b, c, d) {
|
79 |
+
return c*(t/=d)*t*t*t*t + b;
|
80 |
+
},
|
81 |
+
easeOutQuint: function (x, t, b, c, d) {
|
82 |
+
return c*((t=t/d-1)*t*t*t*t + 1) + b;
|
83 |
+
},
|
84 |
+
easeInOutQuint: function (x, t, b, c, d) {
|
85 |
+
if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
|
86 |
+
return c/2*((t-=2)*t*t*t*t + 2) + b;
|
87 |
+
},
|
88 |
+
easeInSine: function (x, t, b, c, d) {
|
89 |
+
return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
|
90 |
+
},
|
91 |
+
easeOutSine: function (x, t, b, c, d) {
|
92 |
+
return c * Math.sin(t/d * (Math.PI/2)) + b;
|
93 |
+
},
|
94 |
+
easeInOutSine: function (x, t, b, c, d) {
|
95 |
+
return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
|
96 |
+
},
|
97 |
+
easeInExpo: function (x, t, b, c, d) {
|
98 |
+
return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
|
99 |
+
},
|
100 |
+
easeOutExpo: function (x, t, b, c, d) {
|
101 |
+
return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
|
102 |
+
},
|
103 |
+
easeInOutExpo: function (x, t, b, c, d) {
|
104 |
+
if (t==0) return b;
|
105 |
+
if (t==d) return b+c;
|
106 |
+
if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
|
107 |
+
return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
|
108 |
+
},
|
109 |
+
easeInCirc: function (x, t, b, c, d) {
|
110 |
+
return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
|
111 |
+
},
|
112 |
+
easeOutCirc: function (x, t, b, c, d) {
|
113 |
+
return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
|
114 |
+
},
|
115 |
+
easeInOutCirc: function (x, t, b, c, d) {
|
116 |
+
if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
|
117 |
+
return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
|
118 |
+
},
|
119 |
+
easeInElastic: function (x, t, b, c, d) {
|
120 |
+
var s=1.70158;var p=0;var a=c;
|
121 |
+
if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
|
122 |
+
if (a < Math.abs(c)) { a=c; var s=p/4; }
|
123 |
+
else var s = p/(2*Math.PI) * Math.asin (c/a);
|
124 |
+
return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
|
125 |
+
},
|
126 |
+
easeOutElastic: function (x, t, b, c, d) {
|
127 |
+
var s=1.70158;var p=0;var a=c;
|
128 |
+
if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
|
129 |
+
if (a < Math.abs(c)) { a=c; var s=p/4; }
|
130 |
+
else var s = p/(2*Math.PI) * Math.asin (c/a);
|
131 |
+
return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
|
132 |
+
},
|
133 |
+
easeInOutElastic: function (x, t, b, c, d) {
|
134 |
+
var s=1.70158;var p=0;var a=c;
|
135 |
+
if (t==0) return b; if ((t/=d/2)==2) return b+c; if (!p) p=d*(.3*1.5);
|
136 |
+
if (a < Math.abs(c)) { a=c; var s=p/4; }
|
137 |
+
else var s = p/(2*Math.PI) * Math.asin (c/a);
|
138 |
+
if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
|
139 |
+
return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
|
140 |
+
},
|
141 |
+
easeInBack: function (x, t, b, c, d, s) {
|
142 |
+
if (s == undefined) s = 1.70158;
|
143 |
+
return c*(t/=d)*t*((s+1)*t - s) + b;
|
144 |
+
},
|
145 |
+
easeOutBack: function (x, t, b, c, d, s) {
|
146 |
+
if (s == undefined) s = 1.70158;
|
147 |
+
return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
|
148 |
+
},
|
149 |
+
easeInOutBack: function (x, t, b, c, d, s) {
|
150 |
+
if (s == undefined) s = 1.70158;
|
151 |
+
if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
|
152 |
+
return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
|
153 |
+
},
|
154 |
+
easeInBounce: function (x, t, b, c, d) {
|
155 |
+
return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b;
|
156 |
+
},
|
157 |
+
easeOutBounce: function (x, t, b, c, d) {
|
158 |
+
if ((t/=d) < (1/2.75)) {
|
159 |
+
return c*(7.5625*t*t) + b;
|
160 |
+
} else if (t < (2/2.75)) {
|
161 |
+
return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
|
162 |
+
} else if (t < (2.5/2.75)) {
|
163 |
+
return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
|
164 |
+
} else {
|
165 |
+
return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
|
166 |
+
}
|
167 |
+
},
|
168 |
+
easeInOutBounce: function (x, t, b, c, d) {
|
169 |
+
if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
|
170 |
+
return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
|
171 |
+
}
|
172 |
+
});
|
173 |
+
|
174 |
+
/*
|
175 |
+
*
|
176 |
+
* TERMS OF USE - EASING EQUATIONS
|
177 |
+
*
|
178 |
+
* Open source under the BSD License.
|
179 |
+
*
|
180 |
+
* Copyright � 2001 Robert Penner
|
181 |
+
* All rights reserved.
|
182 |
+
*
|
183 |
+
* Redistribution and use in source and binary forms, with or without modification,
|
184 |
+
* are permitted provided that the following conditions are met:
|
185 |
+
*
|
186 |
+
* Redistributions of source code must retain the above copyright notice, this list of
|
187 |
+
* conditions and the following disclaimer.
|
188 |
+
* Redistributions in binary form must reproduce the above copyright notice, this list
|
189 |
+
* of conditions and the following disclaimer in the documentation and/or other materials
|
190 |
+
* provided with the distribution.
|
191 |
+
*
|
192 |
+
* Neither the name of the author nor the names of contributors may be used to endorse
|
193 |
+
* or promote products derived from this software without specific prior written permission.
|
194 |
+
*
|
195 |
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
196 |
+
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
197 |
+
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
198 |
+
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
199 |
+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
200 |
+
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
201 |
+
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
202 |
+
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
203 |
+
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
204 |
+
*
|
205 |
+
*/
|
ditty-news-ticker.php
ADDED
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Plugin Name: Ditty News Ticker
|
4 |
+
Plugin URI: http://dittynewsticker.com/
|
5 |
+
Description: Ditty News Ticker is a multi-functional data display plugin
|
6 |
+
Version: 1.0.2
|
7 |
+
Author: Metaphor Creations
|
8 |
+
Author URI: http://www.metaphorcreations.com
|
9 |
+
License: GPL2
|
10 |
+
*/
|
11 |
+
|
12 |
+
/*
|
13 |
+
Copyright 2012 Metaphor Creations (email : joe@metaphorcreations.com)
|
14 |
+
|
15 |
+
This program is free software; you can redistribute it and/or modify
|
16 |
+
it under the terms of the GNU General Public License, version 2, as
|
17 |
+
published by the Free Software Foundation.
|
18 |
+
|
19 |
+
This program is distributed in the hope that it will be useful,
|
20 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
21 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
22 |
+
GNU General Public License for more details.
|
23 |
+
|
24 |
+
You should have received a copy of the GNU General Public License
|
25 |
+
along with this program; if not, write to the Free Software
|
26 |
+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
27 |
+
*/
|
28 |
+
|
29 |
+
/*
|
30 |
+
Fugue Icons
|
31 |
+
|
32 |
+
Copyright (C) 2011 Yusuke Kamiyamane. All rights reserved.
|
33 |
+
The icons are licensed under a Creative Commons Attribution
|
34 |
+
3.0 license. <http://creativecommons.org/licenses/by/3.0/>
|
35 |
+
|
36 |
+
<http://p.yusukekamiyamane.com/>
|
37 |
+
*/
|
38 |
+
|
39 |
+
|
40 |
+
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Define constants
|
44 |
+
*
|
45 |
+
* @since 1.0.0
|
46 |
+
*/
|
47 |
+
if ( WP_DEBUG ) {
|
48 |
+
define ( 'MTPHR_DNT_VERSION', '1.0.2-'.time() );
|
49 |
+
} else {
|
50 |
+
define ( 'MTPHR_DNT_VERSION', '1.0.2' );
|
51 |
+
}
|
52 |
+
define ( 'MTPHR_DNT_DIR', plugin_dir_path(__FILE__) );
|
53 |
+
define ( 'MTPHR_DNT_URL', plugins_url().'/ditty-news-ticker' );
|
54 |
+
|
55 |
+
|
56 |
+
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Include files
|
60 |
+
*
|
61 |
+
* @since 1.0.0
|
62 |
+
*/
|
63 |
+
|
64 |
+
if( is_admin() ) {
|
65 |
+
|
66 |
+
// Load admin code
|
67 |
+
require_once( MTPHR_DNT_DIR.'includes/metaboxer/metaboxer.php' );
|
68 |
+
require_once( MTPHR_DNT_DIR.'includes/metaboxer/metaboxer-class.php' );
|
69 |
+
require_once( MTPHR_DNT_DIR.'includes/meta-boxes.php' );
|
70 |
+
require_once( MTPHR_DNT_DIR.'includes/settings.php' );
|
71 |
+
//require_once( MTPHR_DNT_DIR.'includes/help.php' );
|
72 |
+
require_once( MTPHR_DNT_DIR.'includes/edit-columns.php' );
|
73 |
+
}
|
74 |
+
|
75 |
+
// Load the general functions
|
76 |
+
require_once( MTPHR_DNT_DIR.'includes/scripts.php' );
|
77 |
+
require_once( MTPHR_DNT_DIR.'includes/post-types.php' );
|
78 |
+
//require_once( MTPHR_DNT_DIR.'includes/taxonomies.php' );
|
79 |
+
require_once( MTPHR_DNT_DIR.'includes/functions.php' );
|
80 |
+
require_once( MTPHR_DNT_DIR.'includes/shortcodes.php' );
|
81 |
+
require_once( MTPHR_DNT_DIR.'includes/widget.php' );
|
82 |
+
|
83 |
+
|
84 |
+
|
includes/edit-columns.php
ADDED
@@ -0,0 +1,163 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Custom edit columns
|
4 |
+
*
|
5 |
+
* @package Ditty News Ticker
|
6 |
+
*/
|
7 |
+
|
8 |
+
|
9 |
+
|
10 |
+
|
11 |
+
add_filter( 'manage_ditty_news_ticker_posts_columns', 'mtphr_dnt_set_columns' );
|
12 |
+
/**
|
13 |
+
* Set custom edit screen columns
|
14 |
+
*
|
15 |
+
* @since 1.0
|
16 |
+
*/
|
17 |
+
function mtphr_dnt_set_columns( $columns ){
|
18 |
+
|
19 |
+
$new_columns = array();
|
20 |
+
$i = 0;
|
21 |
+
foreach( $columns as $key => $value ) {
|
22 |
+
if( $i == 2 ) {
|
23 |
+
$new_columns['dnt_type'] = __( 'Type', 'mtphr' );
|
24 |
+
$new_columns['dnt_mode'] = __( 'Mode', 'mtphr' );
|
25 |
+
$new_columns['dnt_shortcode'] = __( 'Shortcode', 'mtphr' );
|
26 |
+
$new_columns['dnt_function'] = __( 'Direct Function', 'mtphr' );
|
27 |
+
}
|
28 |
+
$new_columns[$key] = $value;
|
29 |
+
$i++;
|
30 |
+
}
|
31 |
+
return $new_columns;
|
32 |
+
}
|
33 |
+
|
34 |
+
|
35 |
+
|
36 |
+
|
37 |
+
add_action( 'manage_ditty_news_ticker_posts_custom_column', 'mtphr_dnt_display_columns', 10, 2 );
|
38 |
+
/**
|
39 |
+
* Display the custom edit screen columns
|
40 |
+
*
|
41 |
+
* @since 1.0
|
42 |
+
*/
|
43 |
+
function mtphr_dnt_display_columns( $column, $post_id ){
|
44 |
+
|
45 |
+
global $post;
|
46 |
+
|
47 |
+
switch ( $column ) {
|
48 |
+
|
49 |
+
case 'dnt_type':
|
50 |
+
|
51 |
+
// Get the current type
|
52 |
+
$meta = get_post_meta( $post_id, '_mtphr_dnt_type', true );
|
53 |
+
$label = $meta;
|
54 |
+
$types = mtphr_dnt_types_array();
|
55 |
+
foreach( $types as $i => $type ) {
|
56 |
+
if( $meta == $i ) {
|
57 |
+
$label = $type['button'];
|
58 |
+
}
|
59 |
+
}
|
60 |
+
|
61 |
+
echo "<a href='edit.php?post_type={$post->post_type}&dnt_type={$meta}'>".$label."</a>";
|
62 |
+
break;
|
63 |
+
|
64 |
+
case 'dnt_mode':
|
65 |
+
|
66 |
+
// Get the current mode
|
67 |
+
$meta = get_post_meta( $post_id, '_mtphr_dnt_mode', true );
|
68 |
+
$label = $meta;
|
69 |
+
$modes = mtphr_dnt_modes_array();
|
70 |
+
foreach( $modes as $i => $mode ) {
|
71 |
+
if( $meta == $i ) {
|
72 |
+
$label = $mode['button'];
|
73 |
+
}
|
74 |
+
}
|
75 |
+
|
76 |
+
echo "<a href='edit.php?post_type={$post->post_type}&dnt_mode={$meta}'>".$label."</a>";
|
77 |
+
break;
|
78 |
+
|
79 |
+
case 'dnt_shortcode':
|
80 |
+
echo '<pre><p>[ditty_news_ticker id="'.$post_id.'"]</p></pre>';
|
81 |
+
break;
|
82 |
+
|
83 |
+
case 'dnt_function':
|
84 |
+
echo '<pre>ditty_news_ticker('.$post_id.');</p></pre>';
|
85 |
+
break;
|
86 |
+
}
|
87 |
+
}
|
88 |
+
|
89 |
+
|
90 |
+
|
91 |
+
|
92 |
+
add_filter( 'manage_edit-ditty_news_ticker_sortable_columns', 'mtphr_dnt_sortable_columns' );
|
93 |
+
/**
|
94 |
+
* Add sortable columns
|
95 |
+
*
|
96 |
+
* @since 1.0.0
|
97 |
+
*/
|
98 |
+
function mtphr_dnt_sortable_columns( $columns ) {
|
99 |
+
|
100 |
+
$columns['dnt_type'] = 'dnt_type';
|
101 |
+
$columns['dnt_mode'] = 'dnt_mode';
|
102 |
+
|
103 |
+
return $columns;
|
104 |
+
}
|
105 |
+
|
106 |
+
|
107 |
+
|
108 |
+
|
109 |
+
add_filter( 'request', 'mtphr_dnt_column_order_request' );
|
110 |
+
/**
|
111 |
+
* Set the custom column order
|
112 |
+
*
|
113 |
+
* @since 1.0.0
|
114 |
+
*/
|
115 |
+
function mtphr_dnt_column_order_request( $vars ) {
|
116 |
+
|
117 |
+
if ( isset( $vars['orderby'] ) && 'dnt_type' == $vars['orderby'] ) {
|
118 |
+
$vars = array_merge( $vars, array(
|
119 |
+
'meta_key' => '_mtphr_dnt_type',
|
120 |
+
'orderby' => 'meta_value'
|
121 |
+
));
|
122 |
+
}
|
123 |
+
|
124 |
+
if ( isset( $vars['orderby'] ) && 'dnt_mode' == $vars['orderby'] ) {
|
125 |
+
$vars = array_merge( $vars, array(
|
126 |
+
'meta_key' => '_mtphr_dnt_mode',
|
127 |
+
'orderby' => 'meta_value'
|
128 |
+
));
|
129 |
+
}
|
130 |
+
|
131 |
+
return $vars;
|
132 |
+
}
|
133 |
+
|
134 |
+
|
135 |
+
|
136 |
+
|
137 |
+
add_filter( 'parse_query','mtphr_dnt_parse_query' );
|
138 |
+
/**
|
139 |
+
* Filter the list of tickers
|
140 |
+
*
|
141 |
+
* @since 1.0.0
|
142 |
+
*/
|
143 |
+
function mtphr_dnt_parse_query( $query ) {
|
144 |
+
|
145 |
+
global $pagenow;
|
146 |
+
$qv = &$query->query_vars;
|
147 |
+
|
148 |
+
if ( $pagenow=='edit.php' && $qv['post_type']=='ditty_news_ticker' ) {
|
149 |
+
|
150 |
+
if( isset($_GET['dnt_type']) ) {
|
151 |
+
$qv['meta_key'] = '_mtphr_dnt_type';
|
152 |
+
$qv['meta_value'] = $_GET['dnt_type'];
|
153 |
+
}
|
154 |
+
|
155 |
+
if( isset($_GET['dnt_mode']) ) {
|
156 |
+
$qv['meta_key'] = '_mtphr_dnt_mode';
|
157 |
+
$qv['meta_value'] = $_GET['dnt_mode'];
|
158 |
+
}
|
159 |
+
}
|
160 |
+
}
|
161 |
+
|
162 |
+
|
163 |
+
|
includes/functions.php
ADDED
@@ -0,0 +1,366 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* General functions
|
4 |
+
*
|
5 |
+
* @package Ditty News Ticker
|
6 |
+
*/
|
7 |
+
|
8 |
+
|
9 |
+
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Display the ticker
|
13 |
+
*
|
14 |
+
* @since 1.0.0
|
15 |
+
*/
|
16 |
+
function ditty_news_ticker( $id='', $class='', $atts=false ) {
|
17 |
+
|
18 |
+
// Display the ticker
|
19 |
+
echo get_mtphr_dnt_ticker( $id, $class, $atts );
|
20 |
+
}
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Return the ticker
|
24 |
+
*
|
25 |
+
* @since 1.0.2
|
26 |
+
*/
|
27 |
+
function get_mtphr_dnt_ticker( $id='', $class='', $atts=false ) {
|
28 |
+
|
29 |
+
// Get the post
|
30 |
+
$ticker = get_post( $id );
|
31 |
+
if( $ticker ) {
|
32 |
+
|
33 |
+
// Save the original $wp_query
|
34 |
+
global $wp_query;
|
35 |
+
$original_query = $wp_query;
|
36 |
+
$wp_query = null;
|
37 |
+
$wp_query = new WP_Query();
|
38 |
+
|
39 |
+
// Get all the custom data
|
40 |
+
$custom_fields = get_post_custom( $id );
|
41 |
+
$meta_data = array();
|
42 |
+
foreach( $custom_fields as $key => $value ) {
|
43 |
+
$meta_data[$key] = maybe_unserialize( $value[0] );
|
44 |
+
}
|
45 |
+
|
46 |
+
// Override meta data with supplied attributes
|
47 |
+
if( is_array($atts) ) {
|
48 |
+
foreach( $atts as $key => $value ) {
|
49 |
+
$meta_data["_mtphr_dnt_{$key}"] = $value;
|
50 |
+
}
|
51 |
+
}
|
52 |
+
|
53 |
+
// Extract the metadata array into variables
|
54 |
+
extract( $meta_data );
|
55 |
+
|
56 |
+
// Create an empty array to save ticks
|
57 |
+
$dnt_ticks = array();
|
58 |
+
|
59 |
+
// Get the ticks
|
60 |
+
if( is_array($_mtphr_dnt_ticks) ) {
|
61 |
+
foreach( $_mtphr_dnt_ticks as $i => $tick ) {
|
62 |
+
|
63 |
+
if( $text = wp_kses_post($tick['tick']) ) {
|
64 |
+
|
65 |
+
// Get the contents
|
66 |
+
if( $link = esc_url($tick['link']) ) {
|
67 |
+
$contents = '<a href="'.$link.'" target="'.$tick['target'].'">'.$text.'</a>';
|
68 |
+
} else {
|
69 |
+
$contents = $text;
|
70 |
+
}
|
71 |
+
$contents = apply_filters('mtphr_dnt_tick', $contents, $text, $link );
|
72 |
+
|
73 |
+
// Save the output to the tick array
|
74 |
+
$dnt_ticks[] = $contents;
|
75 |
+
}
|
76 |
+
}
|
77 |
+
}
|
78 |
+
|
79 |
+
// Filter the ticks
|
80 |
+
$dnt_ticks = apply_filters( 'mtphr_dnt_tick_array', $dnt_ticks, $id, $meta_data );
|
81 |
+
|
82 |
+
ob_start();
|
83 |
+
|
84 |
+
// Create the opening div
|
85 |
+
$tick_id = 'mtphr-dnt-'.$id;
|
86 |
+
// Add a unique id
|
87 |
+
if( isset($_mtphr_dnt_unique_id) ) {
|
88 |
+
if( $_mtphr_dnt_unique_id != '' ) {
|
89 |
+
$tick_id = 'mtphr-dnt-'.$id.'-'.sanitize_html_class( $_mtphr_dnt_unique_id );
|
90 |
+
}
|
91 |
+
}
|
92 |
+
echo '<div id="'.$tick_id.'" '.mtphr_dnt_ticker_class( $id, $class, $meta_data ).'>';
|
93 |
+
echo '<div class="mtphr-dnt-wrapper">';
|
94 |
+
|
95 |
+
// Display the title
|
96 |
+
if( isset($_mtphr_dnt_title) ) {
|
97 |
+
if( $_mtphr_dnt_title ) {
|
98 |
+
|
99 |
+
$inline_title = '';
|
100 |
+
if( isset($_mtphr_dnt_inline_title) ) {
|
101 |
+
if( $_mtphr_dnt_inline_title ) {
|
102 |
+
$inline_title = ' mtphr-dnt-inline-title';
|
103 |
+
}
|
104 |
+
}
|
105 |
+
|
106 |
+
do_action( 'mtphr_dnt_title_before', $id, $meta_data );
|
107 |
+
echo '<h3 class="mtphr-dnt-title'.$inline_title.'">'.apply_filters( 'mtphr_dnt_ticker_title', $ticker->post_title ).'</h3>';
|
108 |
+
do_action( 'mtphr_dnt_title_after', $id, $meta_data );
|
109 |
+
}
|
110 |
+
}
|
111 |
+
|
112 |
+
// Create and save element styles
|
113 |
+
$margin='';$padding='';$width='';$height='';$spacing='';
|
114 |
+
|
115 |
+
if( $_mtphr_dnt_mode == 'scroll' ) {
|
116 |
+
$padding = ( intval($_mtphr_dnt_scroll_padding) != 0 ) ? 'padding-top:'.intval($_mtphr_dnt_scroll_padding).'px;padding-bottom:'.intval($_mtphr_dnt_scroll_padding).'px;' : '';
|
117 |
+
$margin = ( intval($_mtphr_dnt_scroll_margin) != 0 ) ? 'margin-top:'.intval($_mtphr_dnt_scroll_margin).'px;margin-bottom:'.intval($_mtphr_dnt_scroll_margin).'px;' : '';
|
118 |
+
$width = ( intval($_mtphr_dnt_scroll_width) != 0 ) ? 'white-space:normal;width:'.intval($_mtphr_dnt_scroll_width).'px;' : '';
|
119 |
+
$height = ( intval($_mtphr_dnt_scroll_height) != 0 ) ? 'height:'.intval($_mtphr_dnt_scroll_height).'px;' : '';
|
120 |
+
} elseif( $_mtphr_dnt_mode == 'rotate' ) {
|
121 |
+
$padding = ( intval($_mtphr_dnt_rotate_padding) != 0 ) ? 'padding-top:'.intval($_mtphr_dnt_rotate_padding).'px;padding-bottom:'.intval($_mtphr_dnt_rotate_padding).'px;' : '';
|
122 |
+
$margin = ( intval($_mtphr_dnt_rotate_margin) != 0 ) ? 'margin-top:'.intval($_mtphr_dnt_rotate_margin).'px;margin-bottom:'.intval($_mtphr_dnt_rotate_margin).'px;' : '';
|
123 |
+
$height = ( intval($_mtphr_dnt_rotate_height) != 0 ) ? 'height:'.intval($_mtphr_dnt_rotate_height).'px;' : '';
|
124 |
+
} elseif( $_mtphr_dnt_mode == 'list' ) {
|
125 |
+
$padding = ( intval($_mtphr_dnt_list_padding) != 0 ) ? 'padding-top:'.intval($_mtphr_dnt_list_padding).'px;padding-bottom:'.intval($_mtphr_dnt_list_padding).'px;' : '';
|
126 |
+
$margin = ( intval($_mtphr_dnt_list_margin) != 0 ) ? 'margin-top:'.intval($_mtphr_dnt_list_margin).'px;margin-bottom:'.intval($_mtphr_dnt_list_margin).'px;' : '';
|
127 |
+
}
|
128 |
+
|
129 |
+
// Filter the variables
|
130 |
+
$padding = apply_filters( 'mtphr_dnt_tick_container_padding', $padding );
|
131 |
+
$margin = apply_filters( 'mtphr_dnt_tick_container_margin', $margin );
|
132 |
+
$width = apply_filters( 'mtphr_dnt_tick_width', $width );
|
133 |
+
$height = apply_filters( 'mtphr_dnt_tick_height', $height );
|
134 |
+
|
135 |
+
// Create the container style
|
136 |
+
$container_style = ( $padding != '' || $margin != '' ) ? ' style="'.$padding.$margin.'"' : '';
|
137 |
+
|
138 |
+
// Open the ticker container
|
139 |
+
do_action( 'mtphr_dnt_before', $id, $meta_data );
|
140 |
+
echo '<div class="mtphr-dnt-tick-container"'.$container_style.'>';
|
141 |
+
do_action( 'mtphr_dnt_top', $id, $meta_data );
|
142 |
+
|
143 |
+
// Print out the ticks
|
144 |
+
if( is_array($dnt_ticks) ) {
|
145 |
+
$total = count($dnt_ticks);
|
146 |
+
foreach( $dnt_ticks as $i => $tick ) {
|
147 |
+
|
148 |
+
// Set the list spacing depending on the tick position
|
149 |
+
if( $_mtphr_dnt_mode == 'list' ) {
|
150 |
+
$spacing = ( $i != intval($total-1) ) ? 'margin-bottom:'.intval($_mtphr_dnt_list_tick_spacing).'px;' : '';
|
151 |
+
}
|
152 |
+
$spacing = apply_filters( 'mtphr_dnt_list_tick_spacing', $spacing, $i, $total );
|
153 |
+
$tick_style = ( $width != '' || $height != '' || $spacing != '' ) ? ' style="'.$width.$height.$spacing.'"' : '';
|
154 |
+
|
155 |
+
do_action( 'mtphr_dnt_tick_before', $id, $meta_data, $total, $i );
|
156 |
+
echo '<div'.$tick_style.' '.mtphr_dnt_tick_class('clearfix').'>';
|
157 |
+
do_action( 'mtphr_dnt_tick_top', $id, $meta_data );
|
158 |
+
|
159 |
+
echo $tick;
|
160 |
+
|
161 |
+
do_action( 'mtphr_dnt_tick_bottom', $id, $meta_data );
|
162 |
+
echo '</div>';
|
163 |
+
do_action( 'mtphr_dnt_tick_after', $id, $meta_data, $total, $i );
|
164 |
+
}
|
165 |
+
|
166 |
+
// Add the directional nav
|
167 |
+
if( $_mtphr_dnt_mode == 'rotate' ) {
|
168 |
+
if( isset($_mtphr_dnt_rotate_directional_nav) ) {
|
169 |
+
if( $_mtphr_dnt_rotate_directional_nav ) {
|
170 |
+
|
171 |
+
$hide = '';
|
172 |
+
if( isset($_mtphr_dnt_rotate_directional_nav_hide) ) {
|
173 |
+
$hide = $_mtphr_dnt_rotate_directional_nav_hide ? ' mtphr-dnt-nav-hide' : '';
|
174 |
+
}
|
175 |
+
echo '<a class="mtphr-dnt-nav mtphr-dnt-nav-prev'.$hide.'" href="#">'.apply_filters( 'mtphr_dnt_direction_nav_prev', '' ).'</a>';
|
176 |
+
echo '<a class="mtphr-dnt-nav mtphr-dnt-nav-next'.$hide.'" href="#">'.apply_filters( 'mtphr_dnt_direction_nav_next', '' ).'</a>';
|
177 |
+
}
|
178 |
+
}
|
179 |
+
}
|
180 |
+
}
|
181 |
+
|
182 |
+
// Close the ticker container
|
183 |
+
do_action( 'mtphr_dnt_bottom', $id, $meta_data );
|
184 |
+
echo '</div>';
|
185 |
+
do_action( 'mtphr_dnt_after', $id, $meta_data );
|
186 |
+
|
187 |
+
// Add the control nav
|
188 |
+
if( is_array($dnt_ticks) && $_mtphr_dnt_mode == 'rotate' ) {
|
189 |
+
if( isset($_mtphr_dnt_rotate_control_nav) ) {
|
190 |
+
if( $_mtphr_dnt_rotate_control_nav ) {
|
191 |
+
|
192 |
+
echo '<div class="mtphr-dnt-control-links">';
|
193 |
+
foreach( $dnt_ticks as $i => $tick ) {
|
194 |
+
echo '<a class="mtphr-dnt-control mtphr-dnt-control-'.$_mtphr_dnt_rotate_control_nav_type.'" href="'.$i.'">'.apply_filters( 'mtphr_dnt_control_nav', intval($i+1) ).'</a>';
|
195 |
+
}
|
196 |
+
echo '</div>';
|
197 |
+
}
|
198 |
+
}
|
199 |
+
}
|
200 |
+
|
201 |
+
// Close the ticker
|
202 |
+
echo '</div></div>';
|
203 |
+
|
204 |
+
// Restore the original $wp_query
|
205 |
+
$wp_query = null;
|
206 |
+
$wp_query = $original_query;
|
207 |
+
wp_reset_postdata();
|
208 |
+
}
|
209 |
+
|
210 |
+
// Return the output
|
211 |
+
return ob_get_clean();
|
212 |
+
}
|
213 |
+
|
214 |
+
|
215 |
+
|
216 |
+
|
217 |
+
|
218 |
+
|
219 |
+
/**
|
220 |
+
* Return the ticker class
|
221 |
+
*
|
222 |
+
* @since 1.0.0
|
223 |
+
*/
|
224 |
+
function mtphr_dnt_ticker_class( $id='', $class='', $meta_data ) {
|
225 |
+
|
226 |
+
// Separates classes with a single space, collates classes for ditty ticker element
|
227 |
+
return 'class="'.join( ' ', get_mtphr_dnt_ticker_class($id,$class,$meta_data) ).'"';
|
228 |
+
}
|
229 |
+
|
230 |
+
function get_mtphr_dnt_ticker_class( $id='', $class='', $meta_data ) {
|
231 |
+
|
232 |
+
// Extract the metadata array into variables
|
233 |
+
extract( $meta_data );
|
234 |
+
|
235 |
+
$classes = array();
|
236 |
+
|
237 |
+
$classes[] = 'mtphr-dnt';
|
238 |
+
$classes[] = 'mtphr-dnt-'.$id;
|
239 |
+
$classes[] = 'mtphr-dnt-'.$_mtphr_dnt_type;
|
240 |
+
$classes[] = 'mtphr-dnt-'.$_mtphr_dnt_mode;
|
241 |
+
|
242 |
+
// Set the styles class
|
243 |
+
if( isset($_mtphr_dnt_styled) ) {
|
244 |
+
if( $_mtphr_dnt_styled ) {
|
245 |
+
$classes[] = 'mtphr-dnt-styled';
|
246 |
+
}
|
247 |
+
}
|
248 |
+
|
249 |
+
if ( !empty( $class ) ) {
|
250 |
+
if ( !is_array( $class ) ) {
|
251 |
+
$class = preg_split( '#\s+#', $class );
|
252 |
+
}
|
253 |
+
$classes = array_merge( $classes, $class );
|
254 |
+
} else {
|
255 |
+
// Ensure that we always coerce class to being an array.
|
256 |
+
$class = array();
|
257 |
+
}
|
258 |
+
|
259 |
+
$classes = array_map( 'esc_attr', $classes );
|
260 |
+
|
261 |
+
return apply_filters( 'mtphr_dnt_ticker_class', $classes, $class );
|
262 |
+
}
|
263 |
+
|
264 |
+
|
265 |
+
|
266 |
+
|
267 |
+
/**
|
268 |
+
* Return the tick class
|
269 |
+
*
|
270 |
+
* @since 1.0.0
|
271 |
+
*/
|
272 |
+
function mtphr_dnt_tick_class( $class='' ) {
|
273 |
+
|
274 |
+
// Separates classes with a single space, collates classes for ditty ticker element
|
275 |
+
return 'class="'.join( ' ', get_mtphr_dnt_tick_class($class) ).'"';
|
276 |
+
}
|
277 |
+
|
278 |
+
function get_mtphr_dnt_tick_class( $class='' ) {
|
279 |
+
|
280 |
+
$classes = array();
|
281 |
+
|
282 |
+
$classes[] = 'mtphr-dnt-tick';
|
283 |
+
|
284 |
+
if ( !empty( $class ) ) {
|
285 |
+
if ( !is_array( $class ) ) {
|
286 |
+
$class = preg_split( '#\s+#', $class );
|
287 |
+
}
|
288 |
+
$classes = array_merge( $classes, $class );
|
289 |
+
} else {
|
290 |
+
// Ensure that we always coerce class to being an array.
|
291 |
+
$class = array();
|
292 |
+
}
|
293 |
+
|
294 |
+
$classes = array_map( 'esc_attr', $classes );
|
295 |
+
|
296 |
+
return apply_filters( 'mtphr_dnt_tick_class', $classes, $class );
|
297 |
+
}
|
298 |
+
|
299 |
+
|
300 |
+
|
301 |
+
|
302 |
+
/**
|
303 |
+
* Minify scripts for output
|
304 |
+
*
|
305 |
+
* @since 1.0.0
|
306 |
+
*/
|
307 |
+
function mtphr_dnt_compress_script( $str ) {
|
308 |
+
|
309 |
+
$lines = explode( "\n", $str );
|
310 |
+
$output = '';
|
311 |
+
foreach( $lines as $line ) {
|
312 |
+
if( substr(trim($line), 0, 3) != '// ' ) {
|
313 |
+
$output .= trim( $line );
|
314 |
+
}
|
315 |
+
}
|
316 |
+
|
317 |
+
return $output;
|
318 |
+
}
|
319 |
+
|
320 |
+
|
321 |
+
|
322 |
+
|
323 |
+
/**
|
324 |
+
* Return an array of the current DNT types
|
325 |
+
*
|
326 |
+
* @since 1.0.0
|
327 |
+
*/
|
328 |
+
function mtphr_dnt_types_array() {
|
329 |
+
|
330 |
+
/* Create the types array. */
|
331 |
+
$dnt_types_array = array();
|
332 |
+
$dnt_types_array['default'] = array(
|
333 |
+
'button' => __('Default', 'ditty-news-ticker'),
|
334 |
+
'metaboxes' => array( 'mtphr_dnt_type_default' )
|
335 |
+
);
|
336 |
+
|
337 |
+
return apply_filters('mtphr_dnt_types', $dnt_types_array);
|
338 |
+
}
|
339 |
+
|
340 |
+
|
341 |
+
|
342 |
+
|
343 |
+
/**
|
344 |
+
* Return an array of the current DNT modes
|
345 |
+
*
|
346 |
+
* @since 1.0.0
|
347 |
+
*/
|
348 |
+
function mtphr_dnt_modes_array() {
|
349 |
+
|
350 |
+
/* Create the modes array. */
|
351 |
+
$dnt_modes_array = array();
|
352 |
+
$dnt_modes_array['scroll'] = array(
|
353 |
+
'button' => __('Scroll', 'ditty-news-ticker'),
|
354 |
+
'metaboxes' => array( 'mtphr_dnt_mode_scroll' )
|
355 |
+
);
|
356 |
+
$dnt_modes_array['rotate'] = array(
|
357 |
+
'button' => __('Rotate', 'ditty-news-ticker'),
|
358 |
+
'metaboxes' => array( 'mtphr_dnt_mode_rotate' )
|
359 |
+
);
|
360 |
+
$dnt_modes_array['list'] = array(
|
361 |
+
'button' => __('List', 'ditty-news-ticker'),
|
362 |
+
'metaboxes' => array( 'mtphr_dnt_mode_list' )
|
363 |
+
);
|
364 |
+
|
365 |
+
return apply_filters('mtphr_dnt_modes', $dnt_modes_array);
|
366 |
+
}
|
includes/help.php
ADDED
@@ -0,0 +1,162 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Add help tabs
|
4 |
+
*
|
5 |
+
* @package Ditty News Ticker
|
6 |
+
*/
|
7 |
+
|
8 |
+
|
9 |
+
|
10 |
+
|
11 |
+
add_action('admin_head-edit.php', 'mtphr_dnt_edit_help_tab');
|
12 |
+
/**
|
13 |
+
* Edit page help tab
|
14 |
+
*
|
15 |
+
* @since 1.0.0
|
16 |
+
*/
|
17 |
+
function mtphr_dnt_edit_help_tab() {
|
18 |
+
|
19 |
+
global $typenow;
|
20 |
+
|
21 |
+
if ( $typenow == 'ditty_news_ticker' ) {
|
22 |
+
|
23 |
+
// Get the current screen
|
24 |
+
$screen = get_current_screen();
|
25 |
+
|
26 |
+
// Add a general help tab
|
27 |
+
mtphr_dnt_general_help_tab( $screen );
|
28 |
+
|
29 |
+
// Add info to the help sidebar
|
30 |
+
$screen->set_help_sidebar( mtphr_dnt_help_sidebar() );
|
31 |
+
}
|
32 |
+
}
|
33 |
+
|
34 |
+
|
35 |
+
|
36 |
+
|
37 |
+
add_action('admin_head-post-new.php', 'mtphr_dnt_post_help_tab');
|
38 |
+
add_action('admin_head-post.php', 'mtphr_dnt_post_help_tab');
|
39 |
+
/**
|
40 |
+
* Post page help tab
|
41 |
+
*
|
42 |
+
* @since 1.0.0
|
43 |
+
*/
|
44 |
+
function mtphr_dnt_post_help_tab() {
|
45 |
+
|
46 |
+
global $typenow;
|
47 |
+
|
48 |
+
if ( $typenow == 'ditty_news_ticker' ) {
|
49 |
+
|
50 |
+
// Get the current screen
|
51 |
+
$screen = get_current_screen();
|
52 |
+
|
53 |
+
// Add a general help tab
|
54 |
+
mtphr_dnt_general_help_tab( $screen );
|
55 |
+
|
56 |
+
// Add a general help tab
|
57 |
+
$screen->add_help_tab( array(
|
58 |
+
'id' => 'mtphr-dnt-scroll-mode-help', //unique id for the tab
|
59 |
+
'title' => __('Scroll Mode', 'ditty-news-ticker'), //unique visible title for the tab
|
60 |
+
'callback' => 'mtphr_dnt_scroll_mode_help_callback' //optional function to callback
|
61 |
+
));
|
62 |
+
|
63 |
+
// Add a general help tab
|
64 |
+
$screen->add_help_tab( array(
|
65 |
+
'id' => 'mtphr-dnt-rotate-mode-help', //unique id for the tab
|
66 |
+
'title' => __('Rotate Mode', 'ditty-news-ticker'), //unique visible title for the tab
|
67 |
+
'callback' => 'mtphr_dnt_rotate_mode_help_callback' //optional function to callback
|
68 |
+
));
|
69 |
+
|
70 |
+
// Add a general help tab
|
71 |
+
$screen->add_help_tab( array(
|
72 |
+
'id' => 'mtphr-dnt-list-mode-help', //unique id for the tab
|
73 |
+
'title' => __('List Mode', 'ditty-news-ticker'), //unique visible title for the tab
|
74 |
+
'callback' => 'mtphr_dnt_list_mode_help_callback' //optional function to callback
|
75 |
+
));
|
76 |
+
|
77 |
+
// Add info to the help sidebar
|
78 |
+
$screen->set_help_sidebar( mtphr_dnt_help_sidebar() );
|
79 |
+
}
|
80 |
+
}
|
81 |
+
|
82 |
+
|
83 |
+
|
84 |
+
|
85 |
+
/**
|
86 |
+
* Create the general help tab
|
87 |
+
*
|
88 |
+
* @since 1.0.0
|
89 |
+
*/
|
90 |
+
function mtphr_dnt_general_help_tab( $screen ) {
|
91 |
+
|
92 |
+
// Add a general help tab
|
93 |
+
$screen->add_help_tab( array(
|
94 |
+
'id' => 'mtphr-dnt-general-help', //unique id for the tab
|
95 |
+
'title' => __('Ditty News Ticker', 'ditty-news-ticker'), //unique visible title for the tab
|
96 |
+
'callback' => 'mtphr_dnt_general_help_callback' //optional function to callback
|
97 |
+
));
|
98 |
+
}
|
99 |
+
|
100 |
+
|
101 |
+
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Help tab sidebar
|
105 |
+
*
|
106 |
+
* @since 1.0.0
|
107 |
+
*/
|
108 |
+
function mtphr_dnt_help_sidebar() {
|
109 |
+
|
110 |
+
$sidebar = '<p><strong>'.__('For more information:').'</strong></p>';
|
111 |
+
$sidebar .= '<p>'.__('Visit the <a href="http://www.metaphorcreations.com" target="_blank">documentation</a> on the Ditty News Ticker website').'</p>';
|
112 |
+
$sidebar .= '<p>'.__('<strong><a href="http://www.metaphorcreations.com" target="_blnak">View DNT extensions').'</strong></a>';
|
113 |
+
|
114 |
+
return $sidebar;
|
115 |
+
}
|
116 |
+
|
117 |
+
|
118 |
+
|
119 |
+
|
120 |
+
/**
|
121 |
+
* General help tab content
|
122 |
+
*
|
123 |
+
* @since 1.0.0
|
124 |
+
*/
|
125 |
+
function mtphr_dnt_general_help_callback() {
|
126 |
+
echo '<p>'.__('Add general information about Ditty News Ticker.', 'ditty-news-ticker').'</p>';
|
127 |
+
}
|
128 |
+
|
129 |
+
/**
|
130 |
+
* Scroll mode help tab content
|
131 |
+
*
|
132 |
+
* @since 1.0.0
|
133 |
+
*/
|
134 |
+
function mtphr_dnt_scroll_mode_help_callback() {
|
135 |
+
echo '<p>'.__('Add scroll mode info.', 'ditty-news-ticker').'</p>';
|
136 |
+
}
|
137 |
+
|
138 |
+
/**
|
139 |
+
* Rotate mode help tab content
|
140 |
+
*
|
141 |
+
* @since 1.0.0
|
142 |
+
*/
|
143 |
+
function mtphr_dnt_rotate_mode_help_callback() {
|
144 |
+
echo '<p>'.__('Add rotate mode info.', 'ditty-news-ticker').'</p>';
|
145 |
+
}
|
146 |
+
|
147 |
+
/**
|
148 |
+
* List mode help tab content
|
149 |
+
*
|
150 |
+
* @since 1.0.0
|
151 |
+
*/
|
152 |
+
function mtphr_dnt_list_mode_help_callback() {
|
153 |
+
echo '<p>'.__('Add list mode info.', 'ditty-news-ticker').'</p>';
|
154 |
+
}
|
155 |
+
|
156 |
+
|
157 |
+
|
158 |
+
|
159 |
+
|
160 |
+
|
161 |
+
|
162 |
+
|
includes/meta-boxes.php
ADDED
@@ -0,0 +1,536 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Create the meta boxes
|
4 |
+
*
|
5 |
+
* @package Ditty News Ticker
|
6 |
+
*/
|
7 |
+
|
8 |
+
|
9 |
+
|
10 |
+
|
11 |
+
add_action( 'admin_init', 'mtphr_dnt_metabox_types', 9 );
|
12 |
+
/**
|
13 |
+
* Create the types metabox.
|
14 |
+
*
|
15 |
+
* @since 1.0.0
|
16 |
+
*/
|
17 |
+
function mtphr_dnt_metabox_types() {
|
18 |
+
|
19 |
+
/* Create the types metabox. */
|
20 |
+
$dnt_types = array(
|
21 |
+
'id' => 'mtphr_dnt_types',
|
22 |
+
'title' => __('Ticker Type', 'ditty-news-ticker'),
|
23 |
+
'page' => array( 'ditty_news_ticker' ),
|
24 |
+
'context' => 'normal',
|
25 |
+
'priority' => 'high',
|
26 |
+
'fields' => array(
|
27 |
+
array(
|
28 |
+
'id' => '_mtphr_dnt_type',
|
29 |
+
'type' => 'metabox_toggle',
|
30 |
+
'options' => mtphr_dnt_types_array(),
|
31 |
+
'default' => 'default',
|
32 |
+
'append' => array(
|
33 |
+
'_mtphr_dnt_type_link' => array(
|
34 |
+
'type' => 'html',
|
35 |
+
'default' => '<a href="http://dittynewsticker.com/extensions/" target="_blank"><strong>'.__('View all types', 'ditty-news-ticker').'</strong></a>'
|
36 |
+
)
|
37 |
+
)
|
38 |
+
)
|
39 |
+
)
|
40 |
+
);
|
41 |
+
new MTPHR_DNT_MetaBoxer( $dnt_types );
|
42 |
+
}
|
43 |
+
|
44 |
+
|
45 |
+
|
46 |
+
|
47 |
+
add_action( 'admin_init', 'mtphr_dnt_metabox_type_default' );
|
48 |
+
/**
|
49 |
+
* Create the default type metabox.
|
50 |
+
*
|
51 |
+
* @since 1.0.0
|
52 |
+
*/
|
53 |
+
function mtphr_dnt_metabox_type_default() {
|
54 |
+
|
55 |
+
// Create an array to store the default item structure
|
56 |
+
$tick_structure = array(
|
57 |
+
'tick' => array(
|
58 |
+
'header' => __('Ticker text', 'ditty-news-ticker'),
|
59 |
+
'width' => '60%',
|
60 |
+
'type' => 'textarea',
|
61 |
+
'rows' => 2
|
62 |
+
),
|
63 |
+
'link' => array(
|
64 |
+
'header' => __('Link', 'ditty-news-ticker'),
|
65 |
+
'type' => 'text'
|
66 |
+
),
|
67 |
+
'target' => array(
|
68 |
+
'header' => __('Target', 'ditty-news-ticker'),
|
69 |
+
'type' => 'select',
|
70 |
+
'options' => array( '_self', '_blank' )
|
71 |
+
)
|
72 |
+
);
|
73 |
+
|
74 |
+
// Create an array to store the fields
|
75 |
+
$default_fields = array();
|
76 |
+
|
77 |
+
// Add the items field
|
78 |
+
$default_fields['ticks'] = array(
|
79 |
+
'id' => '_mtphr_dnt_ticks',
|
80 |
+
'type' => 'list',
|
81 |
+
'structure' => apply_filters('mtphr_dnt_default_tick_structure', $tick_structure)
|
82 |
+
);
|
83 |
+
|
84 |
+
// Create the metabox
|
85 |
+
$dnt_default_data = array(
|
86 |
+
'id' => 'mtphr_dnt_type_default',
|
87 |
+
'title' => __('Default Ticker Items', 'ditty-news-ticker'),
|
88 |
+
'page' => array( 'ditty_news_ticker' ),
|
89 |
+
'context' => 'normal',
|
90 |
+
'priority' => 'high',
|
91 |
+
'fields' => apply_filters('mtphr_dnt_type_fields_default', $default_fields)
|
92 |
+
);
|
93 |
+
new MTPHR_DNT_MetaBoxer( $dnt_default_data );
|
94 |
+
}
|
95 |
+
|
96 |
+
|
97 |
+
|
98 |
+
|
99 |
+
add_action( 'admin_init', 'mtphr_dnt_metabox_modes', 11 );
|
100 |
+
/**
|
101 |
+
* Create the modes metabox.
|
102 |
+
*
|
103 |
+
* @since 1.0.0
|
104 |
+
*/
|
105 |
+
function mtphr_dnt_metabox_modes() {
|
106 |
+
|
107 |
+
// Create an array to store the fields
|
108 |
+
$modes_fields = array();
|
109 |
+
|
110 |
+
// Add the modes fields
|
111 |
+
$modes_fields['modes'] = array(
|
112 |
+
'id' => '_mtphr_dnt_mode',
|
113 |
+
'type' => 'metabox_toggle',
|
114 |
+
'options' => mtphr_dnt_modes_array(),
|
115 |
+
'default' => 'scroll',
|
116 |
+
'append' => array(
|
117 |
+
'_mtphr_dnt_mode_link' => array(
|
118 |
+
'type' => 'html',
|
119 |
+
'default' => '<a href="http://dittynewsticker.com/extensions/" target="_blank"><strong>'.__('View all modes', 'ditty-news-ticker').'</strong></a>'
|
120 |
+
)
|
121 |
+
)
|
122 |
+
);
|
123 |
+
|
124 |
+
/* Create the modes metabox. */
|
125 |
+
$dnt_modes = array(
|
126 |
+
'id' => 'mtphr_dnt_modes',
|
127 |
+
'title' => __('Ticker Mode', 'ditty-news-ticker'),
|
128 |
+
'page' => array( 'ditty_news_ticker' ),
|
129 |
+
'context' => 'normal',
|
130 |
+
'priority' => 'high',
|
131 |
+
'fields' => $modes_fields
|
132 |
+
);
|
133 |
+
new MTPHR_DNT_MetaBoxer( $dnt_modes );
|
134 |
+
}
|
135 |
+
|
136 |
+
|
137 |
+
|
138 |
+
|
139 |
+
add_action( 'admin_init', 'mtphr_dnt_mode_metabox_scroll', 12 );
|
140 |
+
/**
|
141 |
+
* Create the scroll mode metabox.
|
142 |
+
*
|
143 |
+
* @since 1.0.0
|
144 |
+
*/
|
145 |
+
function mtphr_dnt_mode_metabox_scroll() {
|
146 |
+
|
147 |
+
// Create an array to store the fields
|
148 |
+
$scroll_fields = array();
|
149 |
+
|
150 |
+
// Add the dimensions field
|
151 |
+
$scroll_fields['direction'] = array(
|
152 |
+
'id' => '_mtphr_dnt_scroll_direction',
|
153 |
+
'type' => 'radio',
|
154 |
+
'name' => __('Scroll direction', 'ditty-news-ticker'),
|
155 |
+
'options' => array(
|
156 |
+
'left' => __('Left', 'ditty-news-ticker'),
|
157 |
+
'right' => __('Right', 'ditty-news-ticker'),
|
158 |
+
'up' => __('Up', 'ditty-news-ticker'),
|
159 |
+
'down' => __('Down', 'ditty-news-ticker')
|
160 |
+
),
|
161 |
+
'default' => 'left',
|
162 |
+
'description' => __('Set the scroll direction of the ticker.', 'ditty-news-ticker'),
|
163 |
+
'display' => 'inline'
|
164 |
+
);
|
165 |
+
|
166 |
+
// Add the dimensions field
|
167 |
+
$scroll_fields['dimensions'] = array(
|
168 |
+
'id' => '_mtphr_dnt_scroll_width',
|
169 |
+
'type' => 'number',
|
170 |
+
'name' => __('Tick dimensions', 'ditty-news-ticker'),
|
171 |
+
'default' => 0,
|
172 |
+
'before' => __('Width', 'ditty-news-ticker'),
|
173 |
+
'description' => __('Override the auto dimensions with specific values.', 'ditty-news-ticker'),
|
174 |
+
'append' => array(
|
175 |
+
'_mtphr_dnt_scroll_height' => array(
|
176 |
+
'type' => 'number',
|
177 |
+
'default' => 0,
|
178 |
+
'before' => __('Height', 'ditty-news-ticker'),
|
179 |
+
)
|
180 |
+
)
|
181 |
+
);
|
182 |
+
|
183 |
+
// Add the spacing field
|
184 |
+
$scroll_fields['scroller_padding'] = array(
|
185 |
+
'id' => '_mtphr_dnt_scroll_padding',
|
186 |
+
'type' => 'number',
|
187 |
+
'name' => __('Scroller padding', 'ditty-news-ticker'),
|
188 |
+
'default' => 0,
|
189 |
+
'before' => __('Vertical padding', 'ditty-news-ticker'),
|
190 |
+
'description' => __('Set the vertical spacing of the scrolling data.', 'ditty-news-ticker'),
|
191 |
+
'append' => array(
|
192 |
+
'_mtphr_dnt_scroll_margin' => array(
|
193 |
+
'type' => 'number',
|
194 |
+
'default' => 0,
|
195 |
+
'before' => __('Vertical margin', 'ditty-news-ticker')
|
196 |
+
)
|
197 |
+
)
|
198 |
+
);
|
199 |
+
|
200 |
+
// Add the slide speed field
|
201 |
+
$scroll_fields['scroll_speed'] = array(
|
202 |
+
'id' => '_mtphr_dnt_scroll_speed',
|
203 |
+
'type' => 'number',
|
204 |
+
'name' => __('Scroll speed', 'ditty-news-ticker'),
|
205 |
+
'default' => 10,
|
206 |
+
'description' => __('Set the speed of the scrolling data.', 'ditty-news-ticker'),
|
207 |
+
'append' => array(
|
208 |
+
'_mtphr_dnt_scroll_pause' => array(
|
209 |
+
'type' => 'checkbox',
|
210 |
+
'label' => __('Pause on mouse over', 'ditty-news-ticker'),
|
211 |
+
)
|
212 |
+
)
|
213 |
+
);
|
214 |
+
|
215 |
+
// Add the slide spacing field
|
216 |
+
$scroll_fields['tick_spacing'] = array(
|
217 |
+
'id' => '_mtphr_dnt_scroll_tick_spacing',
|
218 |
+
'type' => 'number',
|
219 |
+
'name' => __('Tick spacing', 'ditty-news-ticker'),
|
220 |
+
'default' => 40,
|
221 |
+
'after' => __('Pixels', 'ditty-news-ticker'),
|
222 |
+
'description' => __('Set the spacing between scrolling data.', 'ditty-news-ticker')
|
223 |
+
);
|
224 |
+
|
225 |
+
// Create the metabox
|
226 |
+
$dnt_scroll_settings = array(
|
227 |
+
'id' => 'mtphr_dnt_mode_scroll',
|
228 |
+
'title' => __('Scroll Settings', 'ditty-news-ticker'),
|
229 |
+
'page' => array( 'ditty_news_ticker' ),
|
230 |
+
'context' => 'normal',
|
231 |
+
'priority' => 'high',
|
232 |
+
'fields' => apply_filters('mtphr_dnt_mode_fields_scroll', $scroll_fields)
|
233 |
+
);
|
234 |
+
new MTPHR_DNT_MetaBoxer( $dnt_scroll_settings );
|
235 |
+
}
|
236 |
+
|
237 |
+
|
238 |
+
|
239 |
+
|
240 |
+
add_action( 'admin_init', 'mtphr_dnt_mode_metabox_rotate', 12 );
|
241 |
+
/**
|
242 |
+
* Create the rotate metabox.
|
243 |
+
*
|
244 |
+
* @since 1.0.0
|
245 |
+
*/
|
246 |
+
function mtphr_dnt_mode_metabox_rotate() {
|
247 |
+
|
248 |
+
// Create an array to store the fields
|
249 |
+
$rotate_fields = array();
|
250 |
+
|
251 |
+
// Add the dimensions field
|
252 |
+
$rotate_fields['type'] = array(
|
253 |
+
'id' => '_mtphr_dnt_rotate_type',
|
254 |
+
'type' => 'radio',
|
255 |
+
'name' => __('Rotation type', 'ditty-news-ticker'),
|
256 |
+
'options' => array(
|
257 |
+
'fade' => __('Fade', 'ditty-news-ticker'),
|
258 |
+
'slide_left' => __('Slide left', 'ditty-news-ticker'),
|
259 |
+
'slide_right' => __('Slide right', 'ditty-news-ticker'),
|
260 |
+
'slide_up' => __('Slide up', 'ditty-news-ticker'),
|
261 |
+
'slide_down' => __('Slide down', 'ditty-news-ticker')
|
262 |
+
),
|
263 |
+
'default' => 'fade',
|
264 |
+
'description' => __('Set the type of rotation for the ticker.', 'ditty-news-ticker'),
|
265 |
+
'display' => 'inline',
|
266 |
+
'append' => array(
|
267 |
+
'_mtphr_dnt_rotate_directional_nav_reverse' => array(
|
268 |
+
'type' => 'checkbox',
|
269 |
+
'label' => __('Dynamic slide direction', 'ditty-news-ticker')
|
270 |
+
)
|
271 |
+
)
|
272 |
+
);
|
273 |
+
|
274 |
+
// Add the dimensions field
|
275 |
+
$rotate_fields['dimensions'] = array(
|
276 |
+
'id' => '_mtphr_dnt_rotate_height',
|
277 |
+
'type' => 'number',
|
278 |
+
'name' => __('Tick dimensions', 'ditty-news-ticker'),
|
279 |
+
'default' => 0,
|
280 |
+
'before' => __('Height', 'ditty-news-ticker'),
|
281 |
+
'description' => __('Override the auto dimensions with specific values.', 'ditty-news-ticker')
|
282 |
+
);
|
283 |
+
|
284 |
+
// Add the spacing field
|
285 |
+
$rotate_fields['rotate_padding'] = array(
|
286 |
+
'id' => '_mtphr_dnt_rotate_padding',
|
287 |
+
'type' => 'number',
|
288 |
+
'name' => __('Rotator padding', 'ditty-news-ticker'),
|
289 |
+
'default' => 0,
|
290 |
+
'before' => __('Vertical padding', 'ditty-news-ticker'),
|
291 |
+
'description' => __('Set the vertical spacing of the rotating data.', 'ditty-news-ticker'),
|
292 |
+
'append' => array(
|
293 |
+
'_mtphr_dnt_rotate_margin' => array(
|
294 |
+
'type' => 'number',
|
295 |
+
'default' => 0,
|
296 |
+
'before' => __('Vertical margin', 'ditty-news-ticker')
|
297 |
+
)
|
298 |
+
)
|
299 |
+
);
|
300 |
+
|
301 |
+
// Add the rotate delay field
|
302 |
+
$rotate_fields['rotate_delay'] = array(
|
303 |
+
'id' => '_mtphr_dnt_auto_rotate',
|
304 |
+
'type' => 'checkbox',
|
305 |
+
'name' => __('Auto rotate', 'ditty-news-ticker'),
|
306 |
+
'label' => __('Enable', 'ditty-news-ticker'),
|
307 |
+
'description' => __('Set the delay between rotations.', 'ditty-news-ticker'),
|
308 |
+
'append' => array(
|
309 |
+
'_mtphr_dnt_rotate_delay' => array(
|
310 |
+
'type' => 'number',
|
311 |
+
'default' => 7,
|
312 |
+
'after' => __('Seconds delay', 'ditty-news-ticker')
|
313 |
+
),
|
314 |
+
'_mtphr_dnt_rotate_pause' => array(
|
315 |
+
'type' => 'checkbox',
|
316 |
+
'label' => __('Pause on mouse over', 'ditty-news-ticker')
|
317 |
+
)
|
318 |
+
)
|
319 |
+
);
|
320 |
+
|
321 |
+
// Add the rotate speed field
|
322 |
+
$rotate_fields['rotate_speed'] = array(
|
323 |
+
'id' => '_mtphr_dnt_rotate_speed',
|
324 |
+
'type' => 'number',
|
325 |
+
'name' => __('Rotate speed', 'ditty-news-ticker'),
|
326 |
+
'default' => 3,
|
327 |
+
'after' => __('Tenths of a second', 'ditty-news-ticker'),
|
328 |
+
'description' => __('Set the speed & easing of the rotation.', 'ditty-news-ticker'),
|
329 |
+
'append' => array(
|
330 |
+
'_mtphr_dnt_rotate_ease' => array(
|
331 |
+
'type' => 'select',
|
332 |
+
'options' => array('linear','swing','jswing','easeInQuad','easeInCubic','easeInQuart','easeInQuint','easeInSine','easeInExpo','easeInCirc','easeInElastic','easeInBack','easeInBounce','easeOutQuad','easeOutCubic','easeOutQuart','easeOutQuint','easeOutSine','easeOutExpo','easeOutCirc','easeOutElastic','easeOutBack','easeOutBounce','easeInOutQuad','easeInOutCubic','easeInOutQuart','easeInOutQuint','easeInOutSine','easeInOutExpo','easeInOutCirc','easeInOutElastic','easeInOutBack','easeInOutBounce')
|
333 |
+
)
|
334 |
+
)
|
335 |
+
);
|
336 |
+
|
337 |
+
// Add the rotate navigation field
|
338 |
+
$rotate_fields['rotate_directional_nav'] = array(
|
339 |
+
'id' => '_mtphr_dnt_rotate_directional_nav',
|
340 |
+
'type' => 'checkbox',
|
341 |
+
'name' => __('Directional Navigation', 'ditty-news-ticker'),
|
342 |
+
'label' => __('Enable', 'ditty-news-ticker'),
|
343 |
+
'description' => __('Set the directional navigation options.', 'ditty-news-ticker'),
|
344 |
+
'append' => array(
|
345 |
+
'_mtphr_dnt_rotate_directional_nav_hide' => array(
|
346 |
+
'type' => 'checkbox',
|
347 |
+
'label' => __('Autohide navigation', 'ditty-news-ticker')
|
348 |
+
)
|
349 |
+
)
|
350 |
+
);
|
351 |
+
|
352 |
+
// Add the rotate navigation field
|
353 |
+
$rotate_fields['rotate_control_nav'] = array(
|
354 |
+
'id' => '_mtphr_dnt_rotate_control_nav',
|
355 |
+
'type' => 'checkbox',
|
356 |
+
'name' => __('Control Navigation', 'ditty-news-ticker'),
|
357 |
+
'label' => __('Enable', 'ditty-news-ticker'),
|
358 |
+
'description' => __('Set the control navigation options.', 'ditty-news-ticker'),
|
359 |
+
'append' => array(
|
360 |
+
'_mtphr_dnt_rotate_control_nav_type' => array(
|
361 |
+
'type' => 'radio',
|
362 |
+
'options' => array(
|
363 |
+
'number' => __('Numbers', 'ditty-news-ticker'),
|
364 |
+
'button' => __('Buttons', 'ditty-news-ticker')
|
365 |
+
),
|
366 |
+
'display' => 'inline',
|
367 |
+
'default' => 'numbers'
|
368 |
+
)
|
369 |
+
)
|
370 |
+
);
|
371 |
+
|
372 |
+
// Create the metabox
|
373 |
+
$dnt_rotate_settings = array(
|
374 |
+
'id' => 'mtphr_dnt_mode_rotate',
|
375 |
+
'title' => __('Rotate Settings', 'ditty-news-ticker'),
|
376 |
+
'page' => array( 'ditty_news_ticker' ),
|
377 |
+
'context' => 'normal',
|
378 |
+
'priority' => 'high',
|
379 |
+
'fields' => apply_filters('mtphr_dnt_mode_fields_rotate', $rotate_fields)
|
380 |
+
);
|
381 |
+
new MTPHR_DNT_MetaBoxer( $dnt_rotate_settings );
|
382 |
+
}
|
383 |
+
|
384 |
+
|
385 |
+
|
386 |
+
|
387 |
+
add_action( 'admin_init', 'mtphr_dnt_mode_metabox_list', 12 );
|
388 |
+
/**
|
389 |
+
* Create the list metabox.
|
390 |
+
*
|
391 |
+
* @since 1.0.0
|
392 |
+
*/
|
393 |
+
function mtphr_dnt_mode_metabox_list() {
|
394 |
+
|
395 |
+
// Create an array to store the fields
|
396 |
+
$list_fields = array();
|
397 |
+
|
398 |
+
// Add the spacing field
|
399 |
+
$list_fields['list_padding'] = array(
|
400 |
+
'id' => '_mtphr_dnt_list_padding',
|
401 |
+
'type' => 'number',
|
402 |
+
'name' => __('List padding', 'ditty-news-ticker'),
|
403 |
+
'default' => 0,
|
404 |
+
'before' => __('Vertical padding', 'ditty-news-ticker'),
|
405 |
+
'description' => __('Set the vertical spacing of the list container.', 'ditty-news-ticker'),
|
406 |
+
'append' => array(
|
407 |
+
'_mtphr_dnt_list_margin' => array(
|
408 |
+
'type' => 'number',
|
409 |
+
'default' => 0,
|
410 |
+
'before' => __('Vertical margin', 'ditty-news-ticker')
|
411 |
+
)
|
412 |
+
)
|
413 |
+
);
|
414 |
+
|
415 |
+
// Add the list spacing field
|
416 |
+
$list_fields['tick_spacing'] = array(
|
417 |
+
'id' => '_mtphr_dnt_list_tick_spacing',
|
418 |
+
'type' => 'number',
|
419 |
+
'name' => __('Tick spacing', 'ditty-news-ticker'),
|
420 |
+
'default' => 10,
|
421 |
+
'after' => __('Pixels', 'ditty-news-ticker'),
|
422 |
+
'description' => __('Set the spacing between ticks.', 'ditty-news-ticker')
|
423 |
+
);
|
424 |
+
|
425 |
+
// Create the metabox
|
426 |
+
$dnt_list_settings = array(
|
427 |
+
'id' => 'mtphr_dnt_mode_list',
|
428 |
+
'title' => __('List Settings', 'ditty-news-ticker'),
|
429 |
+
'page' => array( 'ditty_news_ticker' ),
|
430 |
+
'context' => 'normal',
|
431 |
+
'priority' => 'high',
|
432 |
+
'fields' => apply_filters('mtphr_dnt_mode_fields_list', $list_fields)
|
433 |
+
);
|
434 |
+
new MTPHR_DNT_MetaBoxer( $dnt_list_settings );
|
435 |
+
}
|
436 |
+
|
437 |
+
|
438 |
+
|
439 |
+
|
440 |
+
add_action( 'admin_init', 'mtphr_dnt_global_settings', 13 );
|
441 |
+
/**
|
442 |
+
* Create the display metabox.
|
443 |
+
*
|
444 |
+
* @since 1.0.0
|
445 |
+
*/
|
446 |
+
function mtphr_dnt_global_settings() {
|
447 |
+
|
448 |
+
// Create an array to store the fields
|
449 |
+
$global_fields = array();
|
450 |
+
|
451 |
+
// Add the title field
|
452 |
+
$global_fields['title'] = array(
|
453 |
+
'id' => '_mtphr_dnt_title',
|
454 |
+
'type' => 'checkbox',
|
455 |
+
'label' => __('Display Title', 'ditty-news-ticker'),
|
456 |
+
);
|
457 |
+
|
458 |
+
// Add the title field
|
459 |
+
$global_fields['inline_title'] = array(
|
460 |
+
'id' => '_mtphr_dnt_inline_title',
|
461 |
+
'type' => 'checkbox',
|
462 |
+
'label' => __('Inline Title', 'ditty-news-ticker')
|
463 |
+
);
|
464 |
+
|
465 |
+
// Add the title field
|
466 |
+
/*
|
467 |
+
$global_fields['styled'] = array(
|
468 |
+
'id' => '_mtphr_dnt_styled',
|
469 |
+
'type' => 'checkbox',
|
470 |
+
'label' => __('Enable Default CSS Styles', 'ditty-news-ticker'),
|
471 |
+
);
|
472 |
+
*/
|
473 |
+
|
474 |
+
// Create the metabox
|
475 |
+
$dnt_global = array(
|
476 |
+
'id' => 'mtphr_dnt_global_settings',
|
477 |
+
'title' => __('Global Settings', 'ditty-news-ticker'),
|
478 |
+
'page' => array( 'ditty_news_ticker' ),
|
479 |
+
'context' => 'side',
|
480 |
+
'priority' => 'default',
|
481 |
+
'fields' => apply_filters('mtphr_dnt_display_fields', $global_fields)
|
482 |
+
);
|
483 |
+
new MTPHR_DNT_MetaBoxer( $dnt_global );
|
484 |
+
}
|
485 |
+
|
486 |
+
|
487 |
+
|
488 |
+
|
489 |
+
add_action( 'admin_init', 'mtphr_dnt_display_metabox', 13 );
|
490 |
+
/**
|
491 |
+
* Create the display metabox.
|
492 |
+
*
|
493 |
+
* @since 1.0.0
|
494 |
+
*/
|
495 |
+
function mtphr_dnt_display_metabox() {
|
496 |
+
|
497 |
+
// Create an array to store the fields
|
498 |
+
$display_fields = array();
|
499 |
+
|
500 |
+
// Add the shortcode field
|
501 |
+
$display_fields['shortcode'] = array(
|
502 |
+
'id' => '_mtphr_dnt_shortcode',
|
503 |
+
'type' => 'code',
|
504 |
+
'name' => __('Shortcode', 'ditty-news-ticker'),
|
505 |
+
'button' => __('Select Shortcode', 'ditty-news-ticker'),
|
506 |
+
'description' => __('Use this shortcode to insert the ticker into a post/page.', 'ditty-news-ticker'),
|
507 |
+
);
|
508 |
+
|
509 |
+
// Add the function field
|
510 |
+
$display_fields['function'] = array(
|
511 |
+
'id' => '_mtphr_dnt_function',
|
512 |
+
'type' => 'code',
|
513 |
+
'name' => __('Direct Function', 'ditty-news-ticker'),
|
514 |
+
'button' => __('Select Function', 'ditty-news-ticker'),
|
515 |
+
'description' => __('Place this code directly into your theme to display the ticker.', 'ditty-news-ticker'),
|
516 |
+
);
|
517 |
+
|
518 |
+
// Create the metabox
|
519 |
+
$dnt_display = array(
|
520 |
+
'id' => 'mtphr_dnt_display',
|
521 |
+
'title' => __('Ticker Display', 'ditty-news-ticker'),
|
522 |
+
'page' => array( 'ditty_news_ticker' ),
|
523 |
+
'context' => 'side',
|
524 |
+
'priority' => 'default',
|
525 |
+
'fields' => apply_filters('mtphr_dnt_display_fields', $display_fields)
|
526 |
+
);
|
527 |
+
new MTPHR_DNT_MetaBoxer( $dnt_display );
|
528 |
+
}
|
529 |
+
|
530 |
+
|
531 |
+
|
532 |
+
|
533 |
+
|
534 |
+
|
535 |
+
|
536 |
+
|
includes/metaboxer/images/arrow-resize-090.png
ADDED
Binary file
|
includes/metaboxer/images/attachment-audio.png
ADDED
Binary file
|
includes/metaboxer/images/attachment-delete.png
ADDED
Binary file
|
includes/metaboxer/images/attachment-image.png
ADDED
Binary file
|
includes/metaboxer/images/attachment-preview.png
ADDED
Binary file
|
includes/metaboxer/images/attachment-settings.png
ADDED
Binary file
|
includes/metaboxer/images/attachment-video.png
ADDED
Binary file
|
includes/metaboxer/images/attachment-vimeo.png
ADDED
Binary file
|
includes/metaboxer/images/attachment-youtube.png
ADDED
Binary file
|
includes/metaboxer/images/minus-circle.png
ADDED
Binary file
|
includes/metaboxer/images/plus-circle.png
ADDED
Binary file
|
includes/metaboxer/metaboxer-class.php
ADDED
@@ -0,0 +1,186 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* This is where the metabox magic happens.
|
4 |
+
*
|
5 |
+
* @package Ditty News Ticker
|
6 |
+
* @author Metaphor Creations
|
7 |
+
* @license http://www.opensource.org/licenses/gpl-license.php GPL v2.0 (or later)
|
8 |
+
* @link http://www.metaphorcreations.com/plugins/metatools
|
9 |
+
**/
|
10 |
+
|
11 |
+
/* Version 1.1 - 10/18/2012 */
|
12 |
+
|
13 |
+
|
14 |
+
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Create the metabox class
|
18 |
+
*
|
19 |
+
* @since 1.0.0
|
20 |
+
*/
|
21 |
+
if( !class_exists('MTPHR_DNT_MetaBoxer') ) {
|
22 |
+
|
23 |
+
class MTPHR_DNT_MetaBoxer {
|
24 |
+
|
25 |
+
public function __construct( $meta_box ) {
|
26 |
+
|
27 |
+
if ( !is_admin() ) return;
|
28 |
+
|
29 |
+
// Save the meta box data
|
30 |
+
$this->mb = $meta_box;
|
31 |
+
$this->mb_fields = &$this->mb['fields'];
|
32 |
+
|
33 |
+
add_action( 'add_meta_boxes', array(&$this, 'mtphr_dnt_metaboxer_add') );
|
34 |
+
add_action( 'save_post', array(&$this, 'mtphr_dnt_metaboxer_save') );
|
35 |
+
}
|
36 |
+
|
37 |
+
|
38 |
+
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Create the metaboxes
|
42 |
+
*
|
43 |
+
* @since 1.0.0
|
44 |
+
*/
|
45 |
+
public function mtphr_dnt_metaboxer_add() {
|
46 |
+
|
47 |
+
foreach ( $this->mb['page'] as $page ) {
|
48 |
+
add_meta_box( $this->mb['id'], $this->mb['title'], array(&$this, 'mtphr_dnt_metaboxer_render_content'), $page, $this->mb['context'], $this->mb['priority'] );
|
49 |
+
}
|
50 |
+
}
|
51 |
+
|
52 |
+
|
53 |
+
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Render the metabox content
|
57 |
+
*
|
58 |
+
* @since 1.0.0
|
59 |
+
*/
|
60 |
+
public function mtphr_dnt_metaboxer_render_content() {
|
61 |
+
?>
|
62 |
+
<table style="width:100%;" class="mtphr-dnt-metaboxer-admin-fields wrap">
|
63 |
+
<?php
|
64 |
+
foreach( $this->mb_fields as $field ) {
|
65 |
+
|
66 |
+
if ( isset( $field['id'] ) ) {
|
67 |
+
// Create a nonce field
|
68 |
+
echo'<input type="hidden" name="'.$field['id'].'_noncename" id="'.$field['id'].'_noncename" value="'.wp_create_nonce( plugin_basename(__FILE__) ).'" />';
|
69 |
+
}
|
70 |
+
|
71 |
+
// Output the field
|
72 |
+
mtphr_dnt_metaboxer_container( $field, $this->mb['context'] );
|
73 |
+
}
|
74 |
+
?>
|
75 |
+
</table>
|
76 |
+
<?php
|
77 |
+
}
|
78 |
+
|
79 |
+
|
80 |
+
|
81 |
+
|
82 |
+
/**
|
83 |
+
* Save the field values
|
84 |
+
*
|
85 |
+
* @since 1.0.0
|
86 |
+
*/
|
87 |
+
public function mtphr_dnt_metaboxer_save( $post_id ) {
|
88 |
+
|
89 |
+
global $post;
|
90 |
+
|
91 |
+
foreach( $this->mb_fields as $field ) {
|
92 |
+
|
93 |
+
if ( isset($field['id']) ) {
|
94 |
+
|
95 |
+
if ( isset($_POST[$field['id'].'_noncename']) ) {
|
96 |
+
|
97 |
+
// Verify the nonce and return if false
|
98 |
+
if ( !wp_verify_nonce($_POST[$field['id'].'_noncename'], plugin_basename(__FILE__)) ) {
|
99 |
+
return $post_id;
|
100 |
+
}
|
101 |
+
|
102 |
+
// Make sure the user can edit pages & posts
|
103 |
+
if ( 'page' == $_POST['post_type'] ) {
|
104 |
+
if ( !current_user_can('edit_page', $post_id) ) {
|
105 |
+
return $post_id;
|
106 |
+
}
|
107 |
+
} else {
|
108 |
+
if ( !current_user_can('edit_post', $post_id) ) {
|
109 |
+
return $post_id;
|
110 |
+
}
|
111 |
+
}
|
112 |
+
|
113 |
+
// Store the user data or set as empty string
|
114 |
+
$data = ( isset($_POST[$field['id']]) ) ? $_POST[$field['id']] : '';
|
115 |
+
|
116 |
+
// Update the meta
|
117 |
+
mtphr_dnt_metaboxer_update_meta( $post_id, $field['id'], $field['type'], $data );
|
118 |
+
|
119 |
+
// Save appended fields
|
120 |
+
mtphr_dnt_metaboxer_save_appended( $post_id, $field );
|
121 |
+
|
122 |
+
// Save row fields
|
123 |
+
mtphr_dnt_metaboxer_save_rows( $post_id, $field );
|
124 |
+
}
|
125 |
+
}
|
126 |
+
}
|
127 |
+
}
|
128 |
+
}
|
129 |
+
|
130 |
+
/**
|
131 |
+
* Save the row field values
|
132 |
+
*
|
133 |
+
* @since 1.0.0
|
134 |
+
*/
|
135 |
+
function mtphr_dnt_metaboxer_save_rows( $post_id, $field ) {
|
136 |
+
|
137 |
+
if( isset($field['rows']) ) {
|
138 |
+
|
139 |
+
foreach( $field['rows'] as $id => $row ) {
|
140 |
+
|
141 |
+
$row_id = $row['id'];
|
142 |
+
|
143 |
+
// Store the user data or set as empty string
|
144 |
+
$data = ( isset($_POST[$row_id]) ) ? $_POST[$row_id] : '';
|
145 |
+
|
146 |
+
// Update the meta
|
147 |
+
mtphr_dnt_metaboxer_update_meta( $post_id, $row_id, $row['type'], $data );
|
148 |
+
|
149 |
+
// Save appended fields
|
150 |
+
mtphr_dnt_metaboxer_save_appended( $post_id, $row );
|
151 |
+
}
|
152 |
+
}
|
153 |
+
}
|
154 |
+
|
155 |
+
/**
|
156 |
+
* Save the appended field values
|
157 |
+
*
|
158 |
+
* @since 1.0.0
|
159 |
+
*/
|
160 |
+
function mtphr_dnt_metaboxer_save_appended( $post_id, $field ) {
|
161 |
+
|
162 |
+
if( isset($field['append']) ) {
|
163 |
+
|
164 |
+
foreach( $field['append'] as $id => $append ) {
|
165 |
+
|
166 |
+
// Store the user data or set as empty string
|
167 |
+
$data = ( isset($_POST[$id]) ) ? $_POST[$id] : '';
|
168 |
+
|
169 |
+
// Update the meta
|
170 |
+
mtphr_dnt_metaboxer_update_meta( $post_id, $id, $append['type'], $data );
|
171 |
+
}
|
172 |
+
}
|
173 |
+
}
|
174 |
+
|
175 |
+
/**
|
176 |
+
* Update the meta
|
177 |
+
*
|
178 |
+
* @since 1.0.0
|
179 |
+
*/
|
180 |
+
function mtphr_dnt_metaboxer_update_meta( $post_id, $id, $type, $data ) {
|
181 |
+
|
182 |
+
// Update the post meta
|
183 |
+
update_post_meta( $post_id, $id, $data );
|
184 |
+
}
|
185 |
+
|
186 |
+
}
|
includes/metaboxer/metaboxer.css
ADDED
@@ -0,0 +1,524 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/* Table of Contents
|
2 |
+
|
3 |
+
* Media Uploader
|
4 |
+
* General
|
5 |
+
* Fields
|
6 |
+
* Labels
|
7 |
+
* Content
|
8 |
+
|
9 |
+
* File
|
10 |
+
* Lists
|
11 |
+
* Sorts
|
12 |
+
* Code
|
13 |
+
* Radio
|
14 |
+
* Checkbox
|
15 |
+
* WYSIWYG
|
16 |
+
* Farbtastic
|
17 |
+
* jQuery Slider
|
18 |
+
* Pattern Select
|
19 |
+
* Image Select
|
20 |
+
* Attachments
|
21 |
+
* Single Image
|
22 |
+
* Clearfix
|
23 |
+
* Custom
|
24 |
+
|
25 |
+
*/
|
26 |
+
|
27 |
+
/* General
|
28 |
+
------------------------------------------------------------ */
|
29 |
+
|
30 |
+
.mtphr-dnt-metaboxer-admin-fields {
|
31 |
+
padding-top: 10px;
|
32 |
+
}
|
33 |
+
.mtphr-dnt-metaboxer-loading-gif {
|
34 |
+
opacity: 0;
|
35 |
+
}
|
36 |
+
.mtphr-dnt-metaboxer-appended {
|
37 |
+
display: inline;
|
38 |
+
margin-left: 10px;
|
39 |
+
}
|
40 |
+
|
41 |
+
|
42 |
+
/* Fields
|
43 |
+
------------------------------------------------------------ */
|
44 |
+
|
45 |
+
.mtphr-dnt-metaboxer-field {
|
46 |
+
margin-bottom: 20px;
|
47 |
+
}
|
48 |
+
#side-info-column .mtphr-dnt-metaboxer-field {
|
49 |
+
margin-bottom: 10px;
|
50 |
+
}
|
51 |
+
.mtphr-dnt-metaboxer-field:last-child {
|
52 |
+
margin-bottom: 20px;
|
53 |
+
}
|
54 |
+
|
55 |
+
/* Labels
|
56 |
+
------------------------------------------------------------ */
|
57 |
+
|
58 |
+
.mtphr-dnt-metaboxer-label {
|
59 |
+
vertical-align: top;
|
60 |
+
width: 20%;
|
61 |
+
overflow: hidden;
|
62 |
+
padding-bottom: 20px;
|
63 |
+
padding-right: 20px;
|
64 |
+
}
|
65 |
+
.mtphr-dnt-metaboxer-label label {
|
66 |
+
display: block;
|
67 |
+
font-weight: bold;
|
68 |
+
font-size: 12px;
|
69 |
+
}
|
70 |
+
.mtphr-dnt-metaboxer-label small {
|
71 |
+
font-size: 10px;
|
72 |
+
font-style: italic;
|
73 |
+
}
|
74 |
+
#side-sortables .mtphr-dnt-metaboxer-label {
|
75 |
+
width: auto;
|
76 |
+
margin: 0;
|
77 |
+
padding: 0;
|
78 |
+
}
|
79 |
+
|
80 |
+
/* Content
|
81 |
+
------------------------------------------------------------ */
|
82 |
+
.mtphr-dnt-metaboxer-field-content {
|
83 |
+
width: 80%;
|
84 |
+
vertical-align: top;
|
85 |
+
padding-bottom: 20px;
|
86 |
+
}
|
87 |
+
.mtphr-dnt-metaboxer-field-content-full {
|
88 |
+
width: 100%;
|
89 |
+
}
|
90 |
+
.vertical .mtphr-dnt-metaboxer-field-content,
|
91 |
+
#side-sortables .vertical .mtphr-dnt-metaboxer-field-content {
|
92 |
+
float: none;
|
93 |
+
width: auto;
|
94 |
+
}
|
95 |
+
|
96 |
+
/* File
|
97 |
+
------------------------------------------------------------ */
|
98 |
+
|
99 |
+
.wp-core-ui .mtphr-dnt-metaboxer-file-upload {
|
100 |
+
display: none;
|
101 |
+
}
|
102 |
+
.mtphr-dnt-metaboxer-file-table {
|
103 |
+
width: 100%;
|
104 |
+
}
|
105 |
+
.mtphr-dnt-metaboxer-file-display a {
|
106 |
+
display: block;
|
107 |
+
margin: 0;
|
108 |
+
padding: 10px;
|
109 |
+
background: #FEFEFE;
|
110 |
+
border: 1px solid #EEE;
|
111 |
+
white-space: normal;
|
112 |
+
text-decoration: none;
|
113 |
+
|
114 |
+
-webkit-border-radius: 5px;
|
115 |
+
-moz-border-radius: 5px;
|
116 |
+
border-radius: 5px;
|
117 |
+
}
|
118 |
+
.mtphr-dnt-metaboxer-file-display img {
|
119 |
+
display: block;
|
120 |
+
float: left;
|
121 |
+
margin-right: 10px;
|
122 |
+
}
|
123 |
+
.mtphr-dnt-metaboxer-file-display span {
|
124 |
+
text-decoration: none;
|
125 |
+
}
|
126 |
+
.mtphr-dnt-metaboxer-file-delete {
|
127 |
+
width: 16px;
|
128 |
+
padding-top: 4px !important;
|
129 |
+
}
|
130 |
+
.mtphr-dnt-metaboxer-file-delete a {
|
131 |
+
display: block;
|
132 |
+
text-indent: -9999px;
|
133 |
+
width: 16px;
|
134 |
+
height: 16px;
|
135 |
+
background: url(images/minus-circle.png) no-repeat top;
|
136 |
+
}
|
137 |
+
.mtphr-dnt-metaboxer-file-delete a:hover {
|
138 |
+
background-position: 0 -16px;
|
139 |
+
}
|
140 |
+
|
141 |
+
/* List Item
|
142 |
+
------------------------------------------------------------ */
|
143 |
+
|
144 |
+
.mtphr-dnt-metaboxer-list > table {
|
145 |
+
width: 100%;
|
146 |
+
}
|
147 |
+
.mtphr-dnt-metaboxer-list th,
|
148 |
+
.mtphr-dnt-metaboxer-list td {
|
149 |
+
text-align: left;
|
150 |
+
vertical-align: top;
|
151 |
+
padding: 0 3px;
|
152 |
+
}
|
153 |
+
.mtphr-dnt-metaboxer-list input[type="text"],
|
154 |
+
.mtphr-dnt-metaboxer-list input[type="number"],
|
155 |
+
.mtphr-dnt-metaboxer-list input[type="email"],
|
156 |
+
.mtphr-dnt-metaboxer-list input[type="password"],
|
157 |
+
.mtphr-dnt-metaboxer-list textarea {
|
158 |
+
width: 100%;
|
159 |
+
}
|
160 |
+
.mtphr-dnt-metaboxer-list-item-handle,
|
161 |
+
.mtphr-dnt-metaboxer-list-item-add,
|
162 |
+
.mtphr-dnt-metaboxer-list-item-delete {
|
163 |
+
width: 16px;
|
164 |
+
padding-top: 4px !important;
|
165 |
+
}
|
166 |
+
.mtphr-dnt-metaboxer-list-item-handle span,
|
167 |
+
.mtphr-dnt-metaboxer-list-item-add a,
|
168 |
+
.mtphr-dnt-metaboxer-list-item-delete a {
|
169 |
+
display: block;
|
170 |
+
text-indent: -9999px;
|
171 |
+
width: 16px;
|
172 |
+
height: 16px;
|
173 |
+
}
|
174 |
+
.mtphr-dnt-metaboxer-list-item-handle span {
|
175 |
+
background: url(images/arrow-resize-090.png) no-repeat top;
|
176 |
+
}
|
177 |
+
.mtphr-dnt-metaboxer-list-item-add a {
|
178 |
+
background: url(images/plus-circle.png) no-repeat top;
|
179 |
+
}
|
180 |
+
.mtphr-dnt-metaboxer-list-item-delete a {
|
181 |
+
background: url(images/minus-circle.png) no-repeat top;
|
182 |
+
}
|
183 |
+
.mtphr-dnt-metaboxer-list-item-handle span:hover,
|
184 |
+
.mtphr-dnt-metaboxer-list-item-add a:hover,
|
185 |
+
.mtphr-dnt-metaboxer-list-item-delete a:hover {
|
186 |
+
background-position: 0 -16px;
|
187 |
+
}
|
188 |
+
|
189 |
+
/* Sorts
|
190 |
+
------------------------------------------------------------ */
|
191 |
+
|
192 |
+
.mtphr-dnt-metaboxer-sort td {
|
193 |
+
padding: 6px 3px;
|
194 |
+
border-bottom: 1px dashed #CCC;
|
195 |
+
}
|
196 |
+
.mtphr-dnt-metaboxer-sort td.mtphr-dnt-metaboxer-sort-name {
|
197 |
+
font-weight: bold;
|
198 |
+
padding-right: 10px;
|
199 |
+
}
|
200 |
+
.mtphr-dnt-metaboxer-sort td.mtphr-dnt-metaboxer-sort-item-handle {
|
201 |
+
width: 16px;
|
202 |
+
padding-top: 2px !important;
|
203 |
+
border: none;
|
204 |
+
}
|
205 |
+
.mtphr-dnt-metaboxer-sort-item-handle span {
|
206 |
+
display: block;
|
207 |
+
text-indent: -9999px;
|
208 |
+
width: 16px;
|
209 |
+
height: 16px;
|
210 |
+
background: url(images/arrow-resize-090.png) no-repeat top;
|
211 |
+
}
|
212 |
+
.mtphr-dnt-metaboxer-sort-item-handle span:hover {
|
213 |
+
background-position: 0 -16px;
|
214 |
+
}
|
215 |
+
|
216 |
+
/* Code
|
217 |
+
------------------------------------------------------------ */
|
218 |
+
|
219 |
+
.mtphr-dnt-metaboxer-code pre {
|
220 |
+
margin: 0 0 5px 0;
|
221 |
+
padding: 10px;
|
222 |
+
background: #FFF;
|
223 |
+
border: 1px solid #EEE;
|
224 |
+
white-space: normal;
|
225 |
+
|
226 |
+
-webkit-border-radius: 5px;
|
227 |
+
-moz-border-radius: 5px;
|
228 |
+
border-radius: 5px;
|
229 |
+
}
|
230 |
+
.mtphr-dnt-metaboxer-code pre p {
|
231 |
+
margin: 0;
|
232 |
+
}
|
233 |
+
|
234 |
+
/* Radio
|
235 |
+
------------------------------------------------------------ */
|
236 |
+
|
237 |
+
.mtphr-dnt-metaboxer-radio input {
|
238 |
+
margin-top: 0;
|
239 |
+
margin-right: 1px;
|
240 |
+
}
|
241 |
+
|
242 |
+
/* Checkbox
|
243 |
+
------------------------------------------------------------ */
|
244 |
+
|
245 |
+
.mtphr-dnt-metaboxer-checkbox input {
|
246 |
+
margin-top: 0;
|
247 |
+
margin-right: 1px;
|
248 |
+
}
|
249 |
+
|
250 |
+
/* Textarea
|
251 |
+
------------------------------------------------------------ */
|
252 |
+
|
253 |
+
.mtphr-dnt-metaboxer-textarea textarea {
|
254 |
+
width: 96%;
|
255 |
+
}
|
256 |
+
|
257 |
+
/* WYSIWYG
|
258 |
+
------------------------------------------------------------ */
|
259 |
+
|
260 |
+
.mtphr-dnt-metaboxer-wysiwyg {
|
261 |
+
max-width: 800px;
|
262 |
+
}
|
263 |
+
.mtphr-dnt-metaboxer-wysiwyg .mceIframeContainer {
|
264 |
+
background: #FFF;
|
265 |
+
}
|
266 |
+
|
267 |
+
/* Farbtastic
|
268 |
+
------------------------------------------------------------ */
|
269 |
+
|
270 |
+
.farbtastic_cp {
|
271 |
+
float: left;
|
272 |
+
display: none;
|
273 |
+
}
|
274 |
+
|
275 |
+
/* jQuery Slider
|
276 |
+
------------------------------------------------------------ */
|
277 |
+
|
278 |
+
.slider-value {
|
279 |
+
display: inline;
|
280 |
+
font-weight: bold;
|
281 |
+
line-height: 12px;
|
282 |
+
color: #3D759B;
|
283 |
+
border: none !important;
|
284 |
+
margin: 0 0 0 5px;
|
285 |
+
padding: 0;
|
286 |
+
}
|
287 |
+
|
288 |
+
/* Pattern Select
|
289 |
+
------------------------------------------------------------ */
|
290 |
+
|
291 |
+
.mtphr-dnt-metaboxer-pattern_select select {
|
292 |
+
margin-bottom: 5px;
|
293 |
+
}
|
294 |
+
.mtphr-dnt-metaboxer-pattern-selection {
|
295 |
+
width: 200px;
|
296 |
+
height: 100px;
|
297 |
+
background-repeat: repeat;
|
298 |
+
}
|
299 |
+
|
300 |
+
/* Image Select
|
301 |
+
------------------------------------------------------------ */
|
302 |
+
|
303 |
+
.mtphr-dnt-metaboxer-image-select {
|
304 |
+
margin-bottom: 10px;
|
305 |
+
}
|
306 |
+
a.mtphr-dnt-metaboxer-image-select-link {
|
307 |
+
display: block;
|
308 |
+
float: left;
|
309 |
+
margin: 0 10px 10px 0;
|
310 |
+
text-decoration: none;
|
311 |
+
}
|
312 |
+
a.mtphr-dnt-metaboxer-image-select-link small {
|
313 |
+
display: block;
|
314 |
+
text-align: center;
|
315 |
+
font-weight: bold;
|
316 |
+
color: #333;
|
317 |
+
}
|
318 |
+
a.mtphr-dnt-metaboxer-image-select-link img {
|
319 |
+
opacity: .5;
|
320 |
+
-webkit-transition: opacity .2s linear;
|
321 |
+
-moz-transition: opacity .2s linear;
|
322 |
+
-o-transition: opacity .2s linear;
|
323 |
+
-ms-transition: opacity .2s linear;
|
324 |
+
transition: opacity .2s linear;
|
325 |
+
}
|
326 |
+
a.mtphr-dnt-metaboxer-image-select-link.selected img {
|
327 |
+
opacity: 1;
|
328 |
+
}
|
329 |
+
|
330 |
+
|
331 |
+
/* Attachments
|
332 |
+
------------------------------------------------------------ */
|
333 |
+
|
334 |
+
.mtphr-dnt-metaboxer-attachment-container {
|
335 |
+
margin: 0;
|
336 |
+
padding: 0;
|
337 |
+
}
|
338 |
+
.mtphr-dnt-metaboxer-attachment-buttons {
|
339 |
+
margin-bottom: 10px;
|
340 |
+
}
|
341 |
+
.mtphr-dnt-metaboxer-attachment-links {
|
342 |
+
opacity: 0;
|
343 |
+
-webkit-transition: opacity .2s linear;
|
344 |
+
-moz-transition: opacity .2s linear;
|
345 |
+
-o-transition: opacity .2s linear;
|
346 |
+
-ms-transition: opacity .2s linear;
|
347 |
+
transition: opacity .2s linear;
|
348 |
+
}
|
349 |
+
.mtphr-dnt-metaboxer-gallery-attachment:hover .mtphr-dnt-metaboxer-attachment-links,
|
350 |
+
.mtphr-dnt-metaboxer-single-attachment:hover .mtphr-dnt-metaboxer-attachment-links {
|
351 |
+
opacity: 1;
|
352 |
+
}
|
353 |
+
.mtphr-dnt-metaboxer-attachment-preview,
|
354 |
+
.mtphr-dnt-metaboxer-attachment-settings,
|
355 |
+
.mtphr-dnt-metaboxer-attachment-delete {
|
356 |
+
display: inline-block;
|
357 |
+
opacity: .5;
|
358 |
+
-webkit-transition: opacity .2s linear;
|
359 |
+
-moz-transition: opacity .2s linear;
|
360 |
+
-o-transition: opacity .2s linear;
|
361 |
+
-ms-transition: opacity .2s linear;
|
362 |
+
transition: opacity .2s linear;
|
363 |
+
}
|
364 |
+
.mtphr-dnt-metaboxer-attachment-preview:hover,
|
365 |
+
.mtphr-dnt-metaboxer-attachment-settings:hover,
|
366 |
+
.mtphr-dnt-metaboxer-attachment-delete:hover {
|
367 |
+
opacity: 1;
|
368 |
+
}
|
369 |
+
.mtphr-dnt-metaboxer-attachment-preview {
|
370 |
+
position: absolute;
|
371 |
+
top: 10px;
|
372 |
+
left: 10px;
|
373 |
+
width: 17px;
|
374 |
+
height: 17px;
|
375 |
+
background: url(images/attachment-preview.png);
|
376 |
+
}
|
377 |
+
.mtphr-dnt-metaboxer-attachment-settings {
|
378 |
+
position: absolute;
|
379 |
+
top: 10px;
|
380 |
+
right: 10px;
|
381 |
+
width: 17px;
|
382 |
+
height: 17px;
|
383 |
+
background: url(images/attachment-settings.png);
|
384 |
+
}
|
385 |
+
.mtphr-dnt-metaboxer-attachment-delete {
|
386 |
+
position: absolute;
|
387 |
+
bottom: 10px;
|
388 |
+
right: 10px;
|
389 |
+
width: 14px;
|
390 |
+
height: 14px;
|
391 |
+
background: url(images/attachment-delete.png);
|
392 |
+
}
|
393 |
+
.mtphr-dnt-metaboxer-attachment-mime-type {
|
394 |
+
position: absolute;
|
395 |
+
bottom: 10px;
|
396 |
+
left: 10px;
|
397 |
+
}
|
398 |
+
.mtphr-dnt-metaboxer-attachment-mime-type-vimeo {
|
399 |
+
width: 20px;
|
400 |
+
height: 20px;
|
401 |
+
background: url(images/attachment-vimeo.png);
|
402 |
+
}
|
403 |
+
.mtphr-dnt-metaboxer-attachment-mime-type-youtube {
|
404 |
+
width: 20px;
|
405 |
+
height: 23px;
|
406 |
+
background: url(images/attachment-youtube.png);
|
407 |
+
}
|
408 |
+
.mtphr-dnt-metaboxer-attachment-mime-type-audio {
|
409 |
+
width: 20px;
|
410 |
+
height: 20px;
|
411 |
+
background: url(images/attachment-audio.png);
|
412 |
+
}
|
413 |
+
.mtphr-dnt-metaboxer-attachment-mime-type-video {
|
414 |
+
width: 20px;
|
415 |
+
height: 20px;
|
416 |
+
background: url(images/attachment-video.png);
|
417 |
+
}
|
418 |
+
.mtphr-dnt-metaboxer-attachment-mime-type-image {
|
419 |
+
width: 20px;
|
420 |
+
height: 20px;
|
421 |
+
background: url(images/attachment-image.png);
|
422 |
+
}
|
423 |
+
.mtphr-dnt-metaboxer-gallery-attachment-container {
|
424 |
+
width:100%;
|
425 |
+
margin: 0;
|
426 |
+
}
|
427 |
+
.mtphr-dnt-metaboxer-gallery-attachment {
|
428 |
+
position: relative;
|
429 |
+
float: left;
|
430 |
+
width: 120px;
|
431 |
+
height: 120px;
|
432 |
+
|
433 |
+
margin: 0 10px 10px 0;
|
434 |
+
|
435 |
+
-webkit-border-radius: 5px;
|
436 |
+
-moz-border-radius: 5px;
|
437 |
+
border-radius: 5px;
|
438 |
+
|
439 |
+
-moz-box-shadow: 2px 0 0px #000, inset 0 0 3px #DDD;
|
440 |
+
-webkit-box-shadow: 2px 0 0px #000, inset 0 0 3px #DDD;
|
441 |
+
box-shadow: 0 0 1px #000;
|
442 |
+
|
443 |
+
opacity: 1;
|
444 |
+
-webkit-transition: opacity .2s linear;
|
445 |
+
-moz-transition: opacity .2s linear;
|
446 |
+
-o-transition: opacity .2s linear;
|
447 |
+
-ms-transition: opacity .2s linear;
|
448 |
+
transition: opacity .2s linear;
|
449 |
+
}
|
450 |
+
.mtphr-dnt-metaboxer-gallery-attachment:active {
|
451 |
+
opacity: .5;
|
452 |
+
}
|
453 |
+
.mtphr-dnt-metaboxer-gallery-attachment-bg {
|
454 |
+
width: 120px;
|
455 |
+
height: 120px;
|
456 |
+
background-position: center center;
|
457 |
+
background-size: auto 120px;
|
458 |
+
-webkit-border-radius: 5px;
|
459 |
+
-moz-border-radius: 5px;
|
460 |
+
border-radius: 5px;
|
461 |
+
}
|
462 |
+
.mtphr-dnt-metaboxer-gallery-attachment-bg-youtube {
|
463 |
+
background-size: auto 160px;
|
464 |
+
}
|
465 |
+
.mtphr-dnt-metaboxer-gallery-attachment img {
|
466 |
+
-webkit-border-radius: 5px;
|
467 |
+
-moz-border-radius: 5px;
|
468 |
+
border-radius: 5px;
|
469 |
+
}
|
470 |
+
.mtphr-dnt-metaboxer-gallery-attachment:active .mtphr-dnt-metaboxer-attachment-links {
|
471 |
+
opacity: 0;
|
472 |
+
}
|
473 |
+
.attachment-mtphr-dnt-metaboxer-gallery-thumb {
|
474 |
+
cursor: move;
|
475 |
+
-webkit-border-radius: 5px;
|
476 |
+
-moz-border-radius: 5px;
|
477 |
+
border-radius: 5px;
|
478 |
+
}
|
479 |
+
|
480 |
+
/* Single Image
|
481 |
+
------------------------------------------------------------ */
|
482 |
+
|
483 |
+
.mtphr-dnt-metaboxer-single-attachment {
|
484 |
+
float: left;
|
485 |
+
position: relative;
|
486 |
+
margin: 0;
|
487 |
+
padding: 0;
|
488 |
+
}
|
489 |
+
.mtphr-dnt-metaboxer-single-attachment img {
|
490 |
+
max-width: 90%;
|
491 |
+
height: auto;
|
492 |
+
padding: 20px;
|
493 |
+
margin: 0;
|
494 |
+
|
495 |
+
-webkit-border-radius: 5px;
|
496 |
+
-moz-border-radius: 5px;
|
497 |
+
border-radius: 5px;
|
498 |
+
|
499 |
+
-moz-box-shadow: 2px 0 0px #000, inset 0 0 3px #DDD;
|
500 |
+
-webkit-box-shadow: 2px 0 0px #000, inset 0 0 3px #DDD;
|
501 |
+
box-shadow: 0 0 1px #000;
|
502 |
+
}
|
503 |
+
|
504 |
+
/* Clearfix
|
505 |
+
------------------------------------------------------------ */
|
506 |
+
|
507 |
+
.clearfix {
|
508 |
+
*zoom: 1;
|
509 |
+
}
|
510 |
+
.clearfix:before,
|
511 |
+
.clearfix:after {
|
512 |
+
display: table;
|
513 |
+
content: "";
|
514 |
+
}
|
515 |
+
.clearfix:after {
|
516 |
+
clear: both;
|
517 |
+
}
|
518 |
+
|
519 |
+
/* Custom
|
520 |
+
------------------------------------------------------------ */
|
521 |
+
|
522 |
+
#mtphr_dnt_global_settings .mtphr-dnt-metaboxer-field-content {
|
523 |
+
padding-bottom: 0;
|
524 |
+
}
|
includes/metaboxer/metaboxer.js
ADDED
@@ -0,0 +1,383 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/* Table of Contents
|
2 |
+
|
3 |
+
* File
|
4 |
+
* Lists
|
5 |
+
* Code
|
6 |
+
* Metabox toggle
|
7 |
+
|
8 |
+
*/
|
9 |
+
|
10 |
+
|
11 |
+
|
12 |
+
|
13 |
+
jQuery(document).ready( function($) {
|
14 |
+
|
15 |
+
|
16 |
+
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Add file functionality.
|
20 |
+
*
|
21 |
+
* @since 1.0.0
|
22 |
+
*/
|
23 |
+
if( $('.mtphr-dnt-metaboxer-file').length > 0 ) {
|
24 |
+
mtphr_dnt_metaboxer_files();
|
25 |
+
}
|
26 |
+
function mtphr_dnt_metaboxer_files() {
|
27 |
+
|
28 |
+
// Loop through all files to initialize
|
29 |
+
$('.mtphr-dnt-metaboxer-file').each( function(index) {
|
30 |
+
|
31 |
+
// If there currently isn't a value, show the upload button
|
32 |
+
if( $(this).find('.mtphr-dnt-metaboxer-file-value').val() == '' ) {
|
33 |
+
$(this).find('.mtphr-dnt-metaboxer-file-upload').css('display','inline-block');
|
34 |
+
}
|
35 |
+
});
|
36 |
+
|
37 |
+
// Custom media upload functionality
|
38 |
+
$('.mtphr-dnt-metaboxer-file-upload').click(function() {
|
39 |
+
|
40 |
+
// Save the container
|
41 |
+
var $container = $(this).parent('.mtphr-dnt-metaboxer-field-content');
|
42 |
+
|
43 |
+
var send_attachment_bkp = wp.media.editor.send.attachment;
|
44 |
+
|
45 |
+
wp.media.editor.send.attachment = function( props, attachment ) {
|
46 |
+
|
47 |
+
// Set the field value
|
48 |
+
$container.find('.mtphr-dnt-metaboxer-file-value').val(attachment.id);
|
49 |
+
|
50 |
+
// Create the display
|
51 |
+
var data = {
|
52 |
+
action: 'mtphr_dnt_metaboxer_ajax_file_display',
|
53 |
+
id: attachment.id,
|
54 |
+
type: attachment.type,
|
55 |
+
url: attachment.url,
|
56 |
+
title: attachment.title,
|
57 |
+
caption: attachment.caption,
|
58 |
+
description: attachment.description,
|
59 |
+
security: mtphr_dnt_metaboxer_vars.security
|
60 |
+
};
|
61 |
+
|
62 |
+
// since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
|
63 |
+
jQuery.post( ajaxurl, data, function( response ) {
|
64 |
+
|
65 |
+
// Append the new data
|
66 |
+
$container.append( response );
|
67 |
+
|
68 |
+
// Hide the upload button
|
69 |
+
$container.find('.mtphr-dnt-metaboxer-file-upload').hide();
|
70 |
+
});
|
71 |
+
|
72 |
+
wp.media.editor.send.attachment = send_attachment_bkp;
|
73 |
+
}
|
74 |
+
|
75 |
+
wp.media.editor.open();
|
76 |
+
|
77 |
+
return false;
|
78 |
+
});
|
79 |
+
|
80 |
+
$('.mtphr-dnt-metaboxer-file-delete').live('click',function() {
|
81 |
+
|
82 |
+
// Save the container
|
83 |
+
var $container = $(this).parents('.mtphr-dnt-metaboxer-field-content');
|
84 |
+
|
85 |
+
// Remove the field value
|
86 |
+
$container.find('.mtphr-dnt-metaboxer-file-value').val('');
|
87 |
+
|
88 |
+
// Remove the current display
|
89 |
+
$container.find('.mtphr-dnt-metaboxer-file-table').remove();
|
90 |
+
|
91 |
+
// Disply the upload button
|
92 |
+
$container.find('.mtphr-dnt-metaboxer-file-upload').css('display','inline-block');
|
93 |
+
});
|
94 |
+
}
|
95 |
+
|
96 |
+
|
97 |
+
|
98 |
+
|
99 |
+
/**
|
100 |
+
* Add list functionality.
|
101 |
+
*
|
102 |
+
* @since 1.0.0
|
103 |
+
*/
|
104 |
+
if( $('.mtphr-dnt-metaboxer-list').length > 0 ) {
|
105 |
+
mtphr_dnt_metaboxer_lists();
|
106 |
+
}
|
107 |
+
function mtphr_dnt_metaboxer_lists() {
|
108 |
+
|
109 |
+
// Loop through all lists to initialize
|
110 |
+
$('.mtphr-dnt-metaboxer-list').each( function(index) {
|
111 |
+
|
112 |
+
// Set the field order
|
113 |
+
mtphr_dnt_metaboxer_lists_set_order( $(this) );
|
114 |
+
|
115 |
+
// Add sorting to the items
|
116 |
+
$(this).sortable( {
|
117 |
+
handle: '.mtphr-dnt-metaboxer-list-item-handle',
|
118 |
+
items: '.mtphr-dnt-metaboxer-list-item',
|
119 |
+
axis: 'y',
|
120 |
+
helper: function(e, tr) {
|
121 |
+
var $originals = tr.children();
|
122 |
+
var $helper = tr.clone();
|
123 |
+
$helper.children().each(function(index) {
|
124 |
+
// Set helper cell sizes to match the original sizes
|
125 |
+
$(this).width($originals.eq(index).width())
|
126 |
+
});
|
127 |
+
return $helper;
|
128 |
+
},
|
129 |
+
update: function( event, ui ) {
|
130 |
+
|
131 |
+
// Set the field order
|
132 |
+
mtphr_dnt_metaboxer_lists_set_order( $(this) );
|
133 |
+
}
|
134 |
+
});
|
135 |
+
});
|
136 |
+
|
137 |
+
// Set the list item order
|
138 |
+
function mtphr_dnt_metaboxer_lists_set_order( $list ) {
|
139 |
+
|
140 |
+
// Set the order of the items
|
141 |
+
$list.find('.mtphr-dnt-metaboxer-list-item').each( function(i) {
|
142 |
+
|
143 |
+
$(this).find('.mtphr-dnt-metaboxer-list-structure-item').each( function(e) {
|
144 |
+
|
145 |
+
var base = $(this).attr('base');
|
146 |
+
var field = $(this).attr('field');
|
147 |
+
$(this).find('input,textarea,select').attr('name', base+'['+i+']['+field+']');
|
148 |
+
});
|
149 |
+
});
|
150 |
+
|
151 |
+
// Hide the delete if only one element
|
152 |
+
if( $list.find('.mtphr-dnt-metaboxer-list-item').length == 1 ) {
|
153 |
+
|
154 |
+
$list.find('.mtphr-dnt-metaboxer-list-item-handle,.mtphr-dnt-metaboxer-list-item-delete').hide();
|
155 |
+
}
|
156 |
+
}
|
157 |
+
|
158 |
+
// Add item click
|
159 |
+
$('.mtphr-dnt-metaboxer-list-item-add').children('a').click( function(e) {
|
160 |
+
e.preventDefault();
|
161 |
+
|
162 |
+
// Create a new item with blank content
|
163 |
+
var $parent = $(this).parents('.mtphr-dnt-metaboxer-list-item');
|
164 |
+
var $new = $parent.clone(true).hide();
|
165 |
+
$new.find('input,textarea,select').removeAttr('value').removeAttr('checked').removeAttr('selected');
|
166 |
+
$parent.after($new);
|
167 |
+
$new.fadeIn();
|
168 |
+
|
169 |
+
// Set the field order
|
170 |
+
mtphr_dnt_metaboxer_lists_set_order( $(this).parents('.mtphr-dnt-metaboxer-list') );
|
171 |
+
|
172 |
+
// Show the handles
|
173 |
+
$(this).parents('.mtphr-dnt-metaboxer-list').find('.mtphr-dnt-metaboxer-list-item-handle,.mtphr-dnt-metaboxer-list-item-delete').show();
|
174 |
+
|
175 |
+
// Set the focus to the new input
|
176 |
+
var inputs = $new.find('input,textarea,select');
|
177 |
+
$(inputs[0]).focus();
|
178 |
+
});
|
179 |
+
|
180 |
+
// Delete item click
|
181 |
+
$('.mtphr-dnt-metaboxer-list-item-delete').children('a').click( function(e) {
|
182 |
+
e.preventDefault();
|
183 |
+
|
184 |
+
// Fade out the item
|
185 |
+
$(this).parents('.mtphr-dnt-metaboxer-list-item').fadeOut( function() {
|
186 |
+
|
187 |
+
// Get the list
|
188 |
+
var $list = $(this).parents('.mtphr-dnt-metaboxer-list');
|
189 |
+
|
190 |
+
// Remove the item
|
191 |
+
$(this).remove();
|
192 |
+
|
193 |
+
// Set the field order
|
194 |
+
mtphr_dnt_metaboxer_lists_set_order( $list );
|
195 |
+
});
|
196 |
+
});
|
197 |
+
}
|
198 |
+
|
199 |
+
|
200 |
+
|
201 |
+
|
202 |
+
/**
|
203 |
+
* Add list functionality.
|
204 |
+
*
|
205 |
+
* @since 1.0.0
|
206 |
+
*/
|
207 |
+
if( $('.mtphr-dnt-metaboxer-sort').length > 0 ) {
|
208 |
+
mtphr_dnt_metaboxer_sorts();
|
209 |
+
}
|
210 |
+
function mtphr_dnt_metaboxer_sorts() {
|
211 |
+
|
212 |
+
// Loop through all sorts to initialize
|
213 |
+
$('.mtphr-dnt-metaboxer-sort').each( function(index) {
|
214 |
+
|
215 |
+
// Set the field order
|
216 |
+
//mtphr_dnt_metaboxer_sorts_set_order( $(this) );
|
217 |
+
|
218 |
+
// Add sorting to the items
|
219 |
+
$(this).sortable( {
|
220 |
+
handle: '.mtphr-dnt-metaboxer-sort-item-handle',
|
221 |
+
items: '.mtphr-dnt-metaboxer-sort-item',
|
222 |
+
axis: 'y',
|
223 |
+
helper: function(e, tr) {
|
224 |
+
var $originals = tr.children();
|
225 |
+
var $helper = tr.clone();
|
226 |
+
$helper.children().each(function(index) {
|
227 |
+
// Set helper cell sizes to match the original sizes
|
228 |
+
$(this).width($originals.eq(index).width())
|
229 |
+
});
|
230 |
+
return $helper;
|
231 |
+
},
|
232 |
+
update: function( event, ui ) {
|
233 |
+
|
234 |
+
// Set the field order
|
235 |
+
//mtphr_dnt_metaboxer_sorts_set_order( $(this) );
|
236 |
+
}
|
237 |
+
});
|
238 |
+
});
|
239 |
+
|
240 |
+
// Set the list item order
|
241 |
+
/*
|
242 |
+
function mtphr_dnt_metaboxer_sorts_set_order( $sort ) {
|
243 |
+
|
244 |
+
// Set the order of the items
|
245 |
+
$list.find('.mtphr-dnt-metaboxer-list-item').each( function(i) {
|
246 |
+
|
247 |
+
$(this).find('.mtphr-dnt-metaboxer-list-structure-item').each( function(e) {
|
248 |
+
|
249 |
+
var base = $(this).attr('base');
|
250 |
+
var field = $(this).attr('field');
|
251 |
+
$(this).find('input,textarea,select').attr('name', base+'['+i+']['+field+']');
|
252 |
+
});
|
253 |
+
});
|
254 |
+
|
255 |
+
// Hide the delete if only one element
|
256 |
+
if( $list.find('.mtphr-dnt-metaboxer-list-item').length == 1 ) {
|
257 |
+
|
258 |
+
$list.find('.mtphr-dnt-metaboxer-list-item-handle,.mtphr-dnt-metaboxer-list-item-delete').hide();
|
259 |
+
}
|
260 |
+
}
|
261 |
+
*/
|
262 |
+
}
|
263 |
+
|
264 |
+
|
265 |
+
|
266 |
+
|
267 |
+
/**
|
268 |
+
* Add code functionality.
|
269 |
+
*
|
270 |
+
* @since 1.0.0
|
271 |
+
*/
|
272 |
+
if( $('.mtphr-dnt-metaboxer-code').length > 0 ) {
|
273 |
+
mtphr_dnt_metaboxer_codes();
|
274 |
+
}
|
275 |
+
function mtphr_dnt_metaboxer_codes() {
|
276 |
+
|
277 |
+
// Select the code on button click
|
278 |
+
$('.mtphr-dnt-metaboxer-code-select').click( function(e) {
|
279 |
+
e.preventDefault();
|
280 |
+
|
281 |
+
var $pre = $(this).parents('.mtphr-dnt-metaboxer-code').find('pre');
|
282 |
+
var refNode = $pre[0];
|
283 |
+
if ( jQuery.browser.msie ) {
|
284 |
+
var range = document.body.createTextRange();
|
285 |
+
range.moveToElementText( refNode );
|
286 |
+
range.select();
|
287 |
+
} else if ( jQuery.browser.mozilla || jQuery.browser.opera ) {
|
288 |
+
var selection = window.getSelection();
|
289 |
+
var range = document.createRange();
|
290 |
+
range.selectNodeContents( refNode );
|
291 |
+
selection.removeAllRanges();
|
292 |
+
selection.addRange( range );
|
293 |
+
} else if ( jQuery.browser.safari || jQuery.browser.chrome ) {
|
294 |
+
var selection = window.getSelection();
|
295 |
+
selection.setBaseAndExtent( refNode, 0, refNode, 1 );
|
296 |
+
}
|
297 |
+
});
|
298 |
+
}
|
299 |
+
|
300 |
+
|
301 |
+
|
302 |
+
|
303 |
+
/**
|
304 |
+
* Add metabox toggle functionality.
|
305 |
+
*
|
306 |
+
* @since 1.0.0
|
307 |
+
*/
|
308 |
+
if( $('.mtphr-dnt-metaboxer-field-metabox_toggle').length > 0 ) {
|
309 |
+
mtphr_dnt_metaboxer_metabox_toggles();
|
310 |
+
}
|
311 |
+
function mtphr_dnt_metaboxer_metabox_toggles() {
|
312 |
+
|
313 |
+
$('.mtphr-dnt-metaboxer-field-metabox_toggle').each( function(index) {
|
314 |
+
|
315 |
+
// Create an array to store all the toggled metaboxes
|
316 |
+
var metaboxes = Array();
|
317 |
+
$(this).find('.mtphr-dnt-metaboxer-metabox-toggle').each( function(index) {
|
318 |
+
|
319 |
+
// Get the metaboxes and merge into the main array
|
320 |
+
var m = $(this).attr('metaboxes').split(',');
|
321 |
+
$.merge( metaboxes, m );
|
322 |
+
});
|
323 |
+
var total_metaboxes = metaboxes.length;
|
324 |
+
|
325 |
+
// Hide the toggled metaboxes
|
326 |
+
mtphr_dnt_metaboxer_metabox_hide();
|
327 |
+
|
328 |
+
// Display the current metaboxes
|
329 |
+
if( $(this).find('.mtphr-dnt-metaboxer-metabox-toggle.button-primary').length > 0 ) {
|
330 |
+
$init_button = $(this).find('.mtphr-dnt-metaboxer-metabox-toggle.button-primary');
|
331 |
+
} else {
|
332 |
+
$init_button = $(this).find('.mtphr-dnt-metaboxer-metabox-toggle:first');
|
333 |
+
$init_button.addClass('button-primary');
|
334 |
+
}
|
335 |
+
mtphr_dnt_metaboxer_metabox_show( $init_button );
|
336 |
+
|
337 |
+
// Hide the toggled metaboxes
|
338 |
+
function mtphr_dnt_metaboxer_metabox_hide() {
|
339 |
+
for( var i=0; i<total_metaboxes; i++ ) {
|
340 |
+
$('#'+metaboxes[i]).hide();
|
341 |
+
$('input[name="'+metaboxes[i]+'-hide"]').removeAttr('checked');
|
342 |
+
}
|
343 |
+
}
|
344 |
+
|
345 |
+
// Show the selected metaboxes
|
346 |
+
function mtphr_dnt_metaboxer_metabox_show( $button ) {
|
347 |
+
|
348 |
+
// Get and display the selected metaboxes
|
349 |
+
var m = $button.attr('metaboxes').split(',');
|
350 |
+
var t = m.length;
|
351 |
+
|
352 |
+
// Show all the toggled metaboxes
|
353 |
+
for( var i=0; i<t; i++ ) {
|
354 |
+
$('#'+m[i]).show();
|
355 |
+
$('input[name="'+m[i]+'-hide"]').attr('checked', 'checked');
|
356 |
+
}
|
357 |
+
|
358 |
+
// Store the new value
|
359 |
+
$button.siblings('input').val($button.attr('href'));
|
360 |
+
}
|
361 |
+
|
362 |
+
// Select the code on button click
|
363 |
+
$(this).find('.mtphr-dnt-metaboxer-metabox-toggle').click( function(e) {
|
364 |
+
e.preventDefault();
|
365 |
+
|
366 |
+
// Hide all the toggled metaboxes
|
367 |
+
mtphr_dnt_metaboxer_metabox_hide();
|
368 |
+
|
369 |
+
// Show the selected metaboxes
|
370 |
+
mtphr_dnt_metaboxer_metabox_show( $(this) );
|
371 |
+
|
372 |
+
// Set the button classes
|
373 |
+
$(this).siblings('.mtphr-dnt-metaboxer-metabox-toggle').removeClass('button-primary');
|
374 |
+
$(this).addClass('button-primary');
|
375 |
+
});
|
376 |
+
});
|
377 |
+
}
|
378 |
+
|
379 |
+
|
380 |
+
|
381 |
+
|
382 |
+
|
383 |
+
});
|
includes/metaboxer/metaboxer.php
ADDED
@@ -0,0 +1,944 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Put all the Metaboxer admin function here fields here
|
4 |
+
*
|
5 |
+
* @package Ditty News Ticker
|
6 |
+
* @author Metaphor Creations
|
7 |
+
* @license http://www.opensource.org/licenses/gpl-license.php GPL v2.0 (or later)
|
8 |
+
* @link http://www.metaphorcreations.com/plugins/metatools
|
9 |
+
* @version 1.0.0
|
10 |
+
*/
|
11 |
+
|
12 |
+
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Create a field container and switch.
|
16 |
+
*
|
17 |
+
* @since 1.0.0
|
18 |
+
*/
|
19 |
+
function mtphr_dnt_metaboxer_container( $field, $context ) {
|
20 |
+
|
21 |
+
global $post;
|
22 |
+
|
23 |
+
$default = isset( $field['default'] ) ? $field['default'] : '';
|
24 |
+
$value = ( get_post_meta( $post->ID, $field['id'], true ) != '' ) ? get_post_meta( $post->ID, $field['id'], true ) : $default;
|
25 |
+
$display = isset( $field['display'] ) ? $field['display'] : '';
|
26 |
+
?>
|
27 |
+
<tr class="mtphr-dnt-metaboxer-field mtphr-dnt-metaboxer-field-<?php echo $field['type']; ?> mtphr-dnt-metaboxer<?php echo $field['id']; ?><?php if( isset($field['class']) ) { echo ' '.$field['class']; } ?> clearfix">
|
28 |
+
|
29 |
+
<?php
|
30 |
+
$content_class = 'mtphr-dnt-metaboxer-field-content mtphr-dnt-metaboxer-field-content-full mtphr-dnt-metaboxer-'.$field['type'].' clearfix';
|
31 |
+
$content_span = ' colspan="2"';
|
32 |
+
$label = false;
|
33 |
+
|
34 |
+
if ( isset($field['name']) || isset($field['description']) ) {
|
35 |
+
|
36 |
+
$content_class = 'mtphr-dnt-metaboxer-field-content mtphr-dnt-metaboxer-'.$field['type'].' clearfix';
|
37 |
+
$content_span = '';
|
38 |
+
$label = true;
|
39 |
+
?>
|
40 |
+
|
41 |
+
<?php if( $context == 'side' || $display == 'vertical' ) { ?><td><table><tr><?php } ?>
|
42 |
+
|
43 |
+
<td class="mtphr-dnt-metaboxer-label">
|
44 |
+
<?php if( isset($field['name']) ) { ?><label for="<?php echo $field['id']; ?>"><?php echo $field['name']; ?></label><?php } ?>
|
45 |
+
<?php if( isset($field['description']) ) { ?><small><?php echo $field['description']; ?></small><?php } ?>
|
46 |
+
</td>
|
47 |
+
|
48 |
+
<?php if( $context == 'side' || $display == 'vertical' ) { echo '</tr>'; } ?>
|
49 |
+
|
50 |
+
<?php
|
51 |
+
}
|
52 |
+
?>
|
53 |
+
|
54 |
+
<?php if( $label ) { if( $context == 'side' || $display == 'vertical' ) { echo '<tr>'; } } ?>
|
55 |
+
|
56 |
+
<td<?php echo $content_span; ?> class="<?php echo $content_class; ?>" id="<?php echo $post->ID; ?>">
|
57 |
+
<?php
|
58 |
+
// Call the function to display the field
|
59 |
+
if ( function_exists('mtphr_dnt_metaboxer_'.$field['type']) ) {
|
60 |
+
call_user_func( 'mtphr_dnt_metaboxer_'.$field['type'], $field, $value );
|
61 |
+
}
|
62 |
+
?>
|
63 |
+
</td>
|
64 |
+
|
65 |
+
<?php if( $label ) { if( $context == 'side' || $display == 'vertical' ) { echo '</tr></table></td>'; } } ?>
|
66 |
+
|
67 |
+
</tr>
|
68 |
+
<?php
|
69 |
+
}
|
70 |
+
|
71 |
+
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Add custom image sizes.
|
75 |
+
*
|
76 |
+
* @since 1.0.0
|
77 |
+
*/
|
78 |
+
if ( function_exists( 'add_image_size' ) ) {
|
79 |
+
|
80 |
+
// Create custom image sizes
|
81 |
+
add_image_size( 'metaboxer-gallery-thumb', 120, 120, true );
|
82 |
+
}
|
83 |
+
|
84 |
+
|
85 |
+
|
86 |
+
|
87 |
+
add_action( 'wp_ajax_mtphr_dnt_metaboxer_insert_attachment', 'mtphr_dnt_metaboxer_insert_attachment' );
|
88 |
+
/**
|
89 |
+
* Ajax function used to insert a single attachment
|
90 |
+
*
|
91 |
+
* @since 1.0.0
|
92 |
+
*/
|
93 |
+
function mtphr_dnt_metaboxer_insert_attachment() {
|
94 |
+
|
95 |
+
// Get access to the database
|
96 |
+
global $wpdb;
|
97 |
+
|
98 |
+
// Check the nonce
|
99 |
+
check_ajax_referer( 'mtphr_dnt_metaboxer_ajax_file_nonce', 'security' );
|
100 |
+
|
101 |
+
// Get variables
|
102 |
+
$file_id = $_POST['file_ids'];
|
103 |
+
$file_type = isset( $_POST['file_type'] ) ? $_POST['file_type'] : '';
|
104 |
+
$file_size = isset( $_POST['file_size'] ) ? $_POST['file_size'] : '';
|
105 |
+
|
106 |
+
$output = '<li class="mtphr-dnt-metaboxer-single-attachment" id="'.$file_id.'">'.wp_get_attachment_image( $file_id, ( $file_size != '' ) ? $file_size : 'thumbnail' );;
|
107 |
+
$output .= '<div class="mtphr-dnt-metaboxer-attachment-links">';
|
108 |
+
//$output .= '<a href="'.$file_id.'" class="mtphr-dnt-metaboxer-attachment-preview"></a>';
|
109 |
+
$output .= '<a href="'.$file_id.'" class="mtphr-dnt-metaboxer-attachment-settings"></a>';
|
110 |
+
$output .= '<a href="'.$file_id.'" class="mtphr-dnt-metaboxer-attachment-delete"></a>';
|
111 |
+
$output .= '</div><li>';
|
112 |
+
|
113 |
+
echo $output;
|
114 |
+
|
115 |
+
die(); // this is required to return a proper result
|
116 |
+
}
|
117 |
+
|
118 |
+
|
119 |
+
|
120 |
+
|
121 |
+
add_action( 'wp_ajax_mtphr_dnt_metaboxer_insert_attachments', 'mtphr_dnt_metaboxer_insert_attachments' );
|
122 |
+
/**
|
123 |
+
* Ajax function used to insert multiple attachments
|
124 |
+
*
|
125 |
+
* @since 1.0.0
|
126 |
+
*/
|
127 |
+
function mtphr_dnt_metaboxer_insert_attachments() {
|
128 |
+
|
129 |
+
// Get access to the database
|
130 |
+
global $wpdb;
|
131 |
+
|
132 |
+
// Check the nonce
|
133 |
+
check_ajax_referer( 'mtphr_dnt_metaboxer_ajax_file_nonce', 'security' );
|
134 |
+
|
135 |
+
// Get variables
|
136 |
+
$file_ids = $_POST['file_ids'];
|
137 |
+
|
138 |
+
// Create an array of ids
|
139 |
+
$files = explode( ',', $file_ids );
|
140 |
+
|
141 |
+
// Create the new files
|
142 |
+
foreach ( $files as $id ) {
|
143 |
+
echo mtphr_dnt_metaboxer_thumb( $id, false );
|
144 |
+
}
|
145 |
+
|
146 |
+
die(); // this is required to return a proper result
|
147 |
+
}
|
148 |
+
|
149 |
+
|
150 |
+
|
151 |
+
|
152 |
+
add_action( 'wp_ajax_mtphr_dnt_metaboxer_delete_attachments', 'mtphr_dnt_metaboxer_delete_attachments' );
|
153 |
+
/**
|
154 |
+
* Ajax function used to delete attachments
|
155 |
+
*
|
156 |
+
* @since 1.0.0
|
157 |
+
*/
|
158 |
+
function mtphr_dnt_metaboxer_delete_attachments() {
|
159 |
+
|
160 |
+
// Get access to the database
|
161 |
+
global $wpdb;
|
162 |
+
|
163 |
+
// Check the nonce
|
164 |
+
check_ajax_referer( 'mtphr_dnt_metaboxer_ajax_file_nonce', 'security' );
|
165 |
+
|
166 |
+
// Get variables
|
167 |
+
$file_ids = $_POST['file_ids'];
|
168 |
+
|
169 |
+
// Create an array of ids
|
170 |
+
$files = explode( ',', $file_ids );
|
171 |
+
|
172 |
+
// Delete the attachments
|
173 |
+
foreach ( $files as $id ) {
|
174 |
+
wp_delete_attachment( $id );
|
175 |
+
}
|
176 |
+
|
177 |
+
die(); // this is required to return a proper result
|
178 |
+
}
|
179 |
+
|
180 |
+
|
181 |
+
/**
|
182 |
+
* Append fields
|
183 |
+
*
|
184 |
+
* @since 1.0.0
|
185 |
+
*/
|
186 |
+
function mtphr_dnt_metaboxer_append_field( $field ) {
|
187 |
+
|
188 |
+
// Add appended fields
|
189 |
+
if( isset($field['append']) ) {
|
190 |
+
|
191 |
+
$fields = $field['append'];
|
192 |
+
$settings = ( isset($field['option'] ) ) ? $field['option'] : false;
|
193 |
+
|
194 |
+
if( is_array($fields) ) {
|
195 |
+
|
196 |
+
foreach( $fields as $id => $field ) {
|
197 |
+
|
198 |
+
// Get the value
|
199 |
+
if( $settings) {
|
200 |
+
$options = get_option( $settings );
|
201 |
+
$value = isset( $options[$id] ) ? $options[$id] : get_option( $id );
|
202 |
+
} else {
|
203 |
+
global $post;
|
204 |
+
$value = get_post_meta( $post->ID, $id, true );
|
205 |
+
}
|
206 |
+
|
207 |
+
// Set the default if no value
|
208 |
+
if( $value == '' && isset($field['default']) ) {
|
209 |
+
$value = $field['default'];
|
210 |
+
}
|
211 |
+
|
212 |
+
if( isset($field['type']) ) {
|
213 |
+
|
214 |
+
if( $settings ) {
|
215 |
+
$field['id'] = $settings.'['.$id.']';
|
216 |
+
$field['option'] = $settings;
|
217 |
+
} else {
|
218 |
+
$field['id'] = $id;
|
219 |
+
}
|
220 |
+
|
221 |
+
// Call the function to display the field
|
222 |
+
if ( function_exists('mtphr_dnt_metaboxer_'.$field['type']) ) {
|
223 |
+
echo '<div class="mtphr-dnt-metaboxer-appended mtphr-dnt-metaboxer'.$field['id'].'">';
|
224 |
+
call_user_func( 'mtphr_dnt_metaboxer_'.$field['type'], $field, $value );
|
225 |
+
echo '</div>';
|
226 |
+
}
|
227 |
+
}
|
228 |
+
}
|
229 |
+
}
|
230 |
+
}
|
231 |
+
}
|
232 |
+
|
233 |
+
|
234 |
+
|
235 |
+
/* Table of Contents
|
236 |
+
|
237 |
+
* text
|
238 |
+
* number
|
239 |
+
* textarea
|
240 |
+
* wysiwyg
|
241 |
+
* checkbox
|
242 |
+
* radio
|
243 |
+
* farbtastic
|
244 |
+
* image
|
245 |
+
* select
|
246 |
+
* image_select
|
247 |
+
* list
|
248 |
+
* sort
|
249 |
+
* html
|
250 |
+
* metabox toggle
|
251 |
+
* file
|
252 |
+
* gallery
|
253 |
+
* code
|
254 |
+
|
255 |
+
*/
|
256 |
+
|
257 |
+
/**
|
258 |
+
* Renders an text field.
|
259 |
+
*
|
260 |
+
* @since 1.0.0
|
261 |
+
*/
|
262 |
+
function mtphr_dnt_metaboxer_text( $field, $value='' ) {
|
263 |
+
$size = ( isset($field['size']) ) ? $field['size'] : 40;
|
264 |
+
$before = ( isset($field['before']) ) ? '<span>'.$field['before'].' </span>' : '';
|
265 |
+
$after = ( isset($field['after']) ) ? '<span> '.$field['after'].'</span>' : '';
|
266 |
+
$text_align = ( isset($field['text_align']) ) ? ' style="text-align:'.$field['text_align'].'"' : '' ;
|
267 |
+
$output = $before.'<input name="'.$field['id'].'" id="'.$field['id'].'" type="text" value="'.$value.'" size="'.$size.'"'.$text_align.'>'.$after;
|
268 |
+
echo $output;
|
269 |
+
|
270 |
+
// Add appended fields
|
271 |
+
mtphr_dnt_metaboxer_append_field($field);
|
272 |
+
}
|
273 |
+
|
274 |
+
/**
|
275 |
+
* Renders an number field.
|
276 |
+
*
|
277 |
+
* @since 1.0.0
|
278 |
+
*/
|
279 |
+
function mtphr_dnt_metaboxer_number( $field, $value='' ) {
|
280 |
+
$style = ( isset($field['style']) ) ? ' style="'.$field['style'].'"' : '';
|
281 |
+
$before = ( isset($field['before']) ) ? '<span>'.$field['before'].' </span>' : '';
|
282 |
+
$after = ( isset($field['after']) ) ? '<span> '.$field['after'].'</span>' : '';
|
283 |
+
$output = $before.'<input name="'.$field['id'].'" id="'.$field['id'].'" type="number" value="'.$value.'" class="small-text"'.$style.'>'.$after;
|
284 |
+
echo $output;
|
285 |
+
|
286 |
+
// Add appended fields
|
287 |
+
mtphr_dnt_metaboxer_append_field($field);
|
288 |
+
}
|
289 |
+
|
290 |
+
/**
|
291 |
+
* Renders a textarea custom field.
|
292 |
+
*
|
293 |
+
* @since 1.0.0
|
294 |
+
*/
|
295 |
+
function mtphr_dnt_metaboxer_textarea( $field, $value='' ) {
|
296 |
+
$rows = ( isset($field['rows']) ) ? $field['rows'] : 5;
|
297 |
+
$cols = ( isset($field['cols']) ) ? $field['cols'] : 40;
|
298 |
+
$output = '<textarea name="'.$field['id'].'" id="'.$field['id'].'" rows="'.$rows.'" cols="'.$cols.'">'.$value.'</textarea>';
|
299 |
+
echo $output;
|
300 |
+
|
301 |
+
// Add appended fields
|
302 |
+
mtphr_dnt_metaboxer_append_field($field);
|
303 |
+
}
|
304 |
+
|
305 |
+
/**
|
306 |
+
* Renders a wysiwyg field.
|
307 |
+
*
|
308 |
+
* @since 1.0.0
|
309 |
+
*/
|
310 |
+
function mtphr_dnt_metaboxer_wysiwyg( $field, $value='' ) {
|
311 |
+
$settings = array();
|
312 |
+
$settings['media_buttons'] = true;
|
313 |
+
$settings['textarea_rows'] = ( isset($field['rows']) ) ? $field['rows'] : 12;
|
314 |
+
wp_editor( $value, $field['id'], $settings );
|
315 |
+
|
316 |
+
// Add appended fields
|
317 |
+
mtphr_dnt_metaboxer_append_field($field);
|
318 |
+
}
|
319 |
+
|
320 |
+
/**
|
321 |
+
* Renders a checkbox custom field.
|
322 |
+
*
|
323 |
+
* @since 1.0.0
|
324 |
+
*/
|
325 |
+
function mtphr_dnt_metaboxer_checkbox( $field, $value='' ) {
|
326 |
+
|
327 |
+
$output = '';
|
328 |
+
|
329 |
+
if( isset($field['options']) ) {
|
330 |
+
|
331 |
+
$break = '<br/>';
|
332 |
+
if ( isset($field['display']) ) {
|
333 |
+
if( $field['display'] == 'inline' ) {
|
334 |
+
$break = ' ';
|
335 |
+
}
|
336 |
+
}
|
337 |
+
foreach( $field['options'] as $i => $option ) {
|
338 |
+
$checked = ( isset($value[$i]) ) ? 'checked="checked"' : '';
|
339 |
+
$output .= '<label><input name="'.$field['id'].'['.$i.']" id="'.$field['id'].'['.$i.']" type="checkbox" value="1" '.$checked.' /> '.$option.'</label>'.$break;
|
340 |
+
}
|
341 |
+
|
342 |
+
} else {
|
343 |
+
|
344 |
+
$checked = ( $value == 1 ) ? 'checked="checked"' : '';
|
345 |
+
$output .= '<label><input name="'.$field['id'].'" id="'.$field['id'].'" type="checkbox" value="1" '.$checked.' />';
|
346 |
+
if( isset($field['label']) ) {
|
347 |
+
$output .= ' '.$field['label'];
|
348 |
+
}
|
349 |
+
$output .= '</label>';
|
350 |
+
}
|
351 |
+
|
352 |
+
echo $output;
|
353 |
+
|
354 |
+
// Add appended fields
|
355 |
+
mtphr_dnt_metaboxer_append_field($field);
|
356 |
+
}
|
357 |
+
|
358 |
+
/**
|
359 |
+
* Renders a radio custom field.
|
360 |
+
*
|
361 |
+
* @since 1.0.0
|
362 |
+
*/
|
363 |
+
function mtphr_dnt_metaboxer_radio( $field, $value='' ) {
|
364 |
+
|
365 |
+
if( isset($field['options']) ) {
|
366 |
+
|
367 |
+
$output = '';
|
368 |
+
$break = '<br/>';
|
369 |
+
if ( isset($field['display']) ) {
|
370 |
+
if( $field['display'] == 'inline' ) {
|
371 |
+
$break = ' ';
|
372 |
+
}
|
373 |
+
}
|
374 |
+
foreach( $field['options'] as $i => $option ) {
|
375 |
+
$checked = ( $value == $i ) ? 'checked="checked"' : '';
|
376 |
+
$output .= '<label><input name="'.$field['id'].'" id="'.$field['id'].'" type="radio" value="'.$i.'" '.$checked.' /> '.$option.'</label>'.$break;
|
377 |
+
}
|
378 |
+
}
|
379 |
+
|
380 |
+
echo $output;
|
381 |
+
|
382 |
+
// Add appended fields
|
383 |
+
mtphr_dnt_metaboxer_append_field($field);
|
384 |
+
}
|
385 |
+
|
386 |
+
/**
|
387 |
+
* Renders a farbtastic custom field.
|
388 |
+
*
|
389 |
+
* @since 1.0.0
|
390 |
+
*/
|
391 |
+
function mtphr_dnt_metaboxer_farbtastic( $field, $value='' ) {
|
392 |
+
$output = '<div class="farbtastic_cp" id="'.$field['id'].'_cp"></div>';
|
393 |
+
$output .= '<input name="'.$field['id'].'" id="'.$field['id'].'" type="text" value="'.$value.'" />';
|
394 |
+
$output .= '<a href="#" class="farbtastic-pick button">Pick Color</a>';
|
395 |
+
echo $output;
|
396 |
+
|
397 |
+
// Add appended fields
|
398 |
+
mtphr_dnt_metaboxer_append_field($field);
|
399 |
+
}
|
400 |
+
|
401 |
+
/**
|
402 |
+
* Renders an image field.
|
403 |
+
*
|
404 |
+
* @since 1.0.0
|
405 |
+
*/
|
406 |
+
function mtphr_dnt_metaboxer_image( $field, $value=false ) {
|
407 |
+
$button = isset( $field['button'] ) ? $field['button'] : 'Upload Image';
|
408 |
+
$size = isset( $field['size'] ) ? $field['size'] : 'thumbnail';
|
409 |
+
|
410 |
+
$value = ( $value ) ? $value : false;
|
411 |
+
|
412 |
+
$output = '<div class="mtphr-dnt-metaboxer-attachment-buttons"><a href="#" class="button mtphr-dnt-metaboxer-upload-button">'.$button.'</a></div>';
|
413 |
+
$output .= '<input class="mtphr-dnt-metaboxer-attachment-limit" type="hidden" value="1" />';
|
414 |
+
$output .= '<input class="mtphr-dnt-metaboxer-attachment-size" type="hidden" value="'.$size.'" />';
|
415 |
+
$output .= '<div class="mtphr-dnt-metaboxer-input-container" id="'.$field['id'].'"></div>';
|
416 |
+
$output .= '<ul id="'.wp_create_nonce( 'mtphr_dnt_metaboxer_ajax_file_nonce' ).'" class="mtphr-dnt-metaboxer-attachment-container clearfix">';
|
417 |
+
if( $value ) {
|
418 |
+
if( get_post($value[0]) ) {
|
419 |
+
$output .= '<li id="'.$value[0].'" class="mtphr-dnt-metaboxer-single-attachment">'.wp_get_attachment_image( $value[0], isset( $field['size'] ) ? $field['size'] : 'thumbnail' );
|
420 |
+
$output .= '<div class="mtphr-dnt-metaboxer-attachment-links">';
|
421 |
+
//$output .= '<a href="'.$value[0].'" class="mtphr-dnt-metaboxer-attachment-preview"></a>';
|
422 |
+
$output .= '<a href="'.$value[0].'" class="mtphr-dnt-metaboxer-attachment-settings"></a>';
|
423 |
+
$output .= '<a href="'.$value[0].'" class="mtphr-dnt-metaboxer-attachment-delete"></a>';
|
424 |
+
$output .= '</div>';
|
425 |
+
$output .= '</li>';
|
426 |
+
}
|
427 |
+
}
|
428 |
+
$output .= '</ul>';
|
429 |
+
echo $output;
|
430 |
+
|
431 |
+
// Add appended fields
|
432 |
+
mtphr_dnt_metaboxer_append_field($field);
|
433 |
+
}
|
434 |
+
|
435 |
+
/**
|
436 |
+
* Renders a select field.
|
437 |
+
*
|
438 |
+
* @since 1.0.0
|
439 |
+
*/
|
440 |
+
function mtphr_dnt_metaboxer_select( $field, $value='' ) {
|
441 |
+
|
442 |
+
$before = ( isset($field['before']) ) ? '<span>'.$field['before'].' </span>' : '';
|
443 |
+
$after = ( isset($field['after']) ) ? '<span> '.$field['after'].'</span>' : '';
|
444 |
+
|
445 |
+
$output = $before.'<select name="'.$field['id'].'" id="'.$field['id'].'">';
|
446 |
+
|
447 |
+
if( $field['options'] ) {
|
448 |
+
|
449 |
+
$key_val = isset( $field['key_val'] ) ? true : false;
|
450 |
+
|
451 |
+
foreach ( $field['options'] as $key => $option ) {
|
452 |
+
if( is_numeric($key) && !$key_val ) {
|
453 |
+
$name = ( is_array( $option ) ) ? $option['name'] : $option;
|
454 |
+
$val = ( is_array( $option ) ) ? $option['value'] : $option;
|
455 |
+
} else {
|
456 |
+
$name = $option;
|
457 |
+
$val = $key;
|
458 |
+
}
|
459 |
+
$selected = ( $val == $value ) ? 'selected="selected"' : '';
|
460 |
+
$output .= '<option value="'.$val.'" '.$selected.'>'.stripslashes( $name ).'</option>';
|
461 |
+
}
|
462 |
+
}
|
463 |
+
$output .= '</select>'.$after;
|
464 |
+
|
465 |
+
echo $output;
|
466 |
+
|
467 |
+
// Add appended fields
|
468 |
+
mtphr_dnt_metaboxer_append_field($field);
|
469 |
+
}
|
470 |
+
|
471 |
+
/**
|
472 |
+
* Renders an image select
|
473 |
+
*
|
474 |
+
* @since 1.0.0
|
475 |
+
*/
|
476 |
+
function mtphr_dnt_metaboxer_image_select( $field, $value='' ) {
|
477 |
+
$output = '<input type="hidden" id="'.$field['id'].'" name="'.$field['id'].'" value="'.$value.'" />';
|
478 |
+
foreach ( $field['options'] as $option ) {
|
479 |
+
$selected = ( $value == $option['value'] ) ? 'selected' : '';
|
480 |
+
$output .= '<a class="mtphr-dnt-metaboxer-image-select-link '.$selected.'" href="'.$option['value'].'"><img src="'.$option['path'].'" /><small>'.$option['label'].'</small></a>';
|
481 |
+
}
|
482 |
+
echo $output;
|
483 |
+
|
484 |
+
// Add appended fields
|
485 |
+
mtphr_dnt_metaboxer_append_field($field);
|
486 |
+
}
|
487 |
+
|
488 |
+
/**
|
489 |
+
* Renders a list.
|
490 |
+
*
|
491 |
+
* @since 1.0.0
|
492 |
+
*/
|
493 |
+
function mtphr_dnt_metaboxer_list( $field, $value='' ) {
|
494 |
+
|
495 |
+
$output = '<table>';
|
496 |
+
|
497 |
+
$headers = false;
|
498 |
+
$header_str = '';
|
499 |
+
foreach( $field['structure'] as $id => $str ) {
|
500 |
+
|
501 |
+
$header_str .= '<th>';
|
502 |
+
if( isset($str['header']) ) {
|
503 |
+
$headers = true;
|
504 |
+
$header_str .= $str['header'];
|
505 |
+
}
|
506 |
+
$header_str .= '</th>';
|
507 |
+
}
|
508 |
+
if( $headers ) {
|
509 |
+
$output .= '<tr><td class="mtphr-dnt-metaboxer-list-item-handle"></td>'.$header_str.'</tr>';
|
510 |
+
}
|
511 |
+
|
512 |
+
$buttons = '<td class="mtphr-dnt-metaboxer-list-item-delete"><a href="#">Delete</a></td><td class="mtphr-dnt-metaboxer-list-item-add"><a href="#">Add</a></td>';
|
513 |
+
if( is_array($value) ) {
|
514 |
+
foreach( $value as $i=>$v ) {
|
515 |
+
$structure = mtphr_dnt_metaboxer_list_structure( $i, $field, $v );
|
516 |
+
$output .= '<tr class="mtphr-dnt-metaboxer-list-item"><td class="mtphr-dnt-metaboxer-list-item-handle"><span></span></td>'.$structure.$buttons.'</tr>';
|
517 |
+
}
|
518 |
+
}
|
519 |
+
|
520 |
+
// If nothing is being output make sure one field is showing
|
521 |
+
if( $value == '' ) {
|
522 |
+
$structure = mtphr_dnt_metaboxer_list_structure( 0, $field );
|
523 |
+
$output .= '<tr class="mtphr-dnt-metaboxer-list-item"><td class="mtphr-dnt-metaboxer-list-item-handle"><span></span></td>'.$structure.$buttons.'</tr>';
|
524 |
+
}
|
525 |
+
|
526 |
+
$output .= '</table>';
|
527 |
+
|
528 |
+
echo $output;
|
529 |
+
|
530 |
+
// Add appended fields
|
531 |
+
mtphr_dnt_metaboxer_append_field($field);
|
532 |
+
}
|
533 |
+
|
534 |
+
/**
|
535 |
+
* Add the list structure
|
536 |
+
*
|
537 |
+
* @since 1.0.0
|
538 |
+
*/
|
539 |
+
function mtphr_dnt_metaboxer_list_structure( $pos, $fields, $m_value='' ) {
|
540 |
+
|
541 |
+
$main_id = $fields['id'];
|
542 |
+
|
543 |
+
// Add appended fields
|
544 |
+
if( isset($fields['structure']) ) {
|
545 |
+
|
546 |
+
$fields = $fields['structure'];
|
547 |
+
$settings = ( isset($fields['option'] ) ) ? $fields['option'] : false;
|
548 |
+
|
549 |
+
if( is_array($fields) ) {
|
550 |
+
|
551 |
+
ob_start();
|
552 |
+
|
553 |
+
foreach( $fields as $id => $field ) {
|
554 |
+
|
555 |
+
// Get the value
|
556 |
+
$value = isset($m_value[$id]) ? $m_value[$id] : '';
|
557 |
+
|
558 |
+
// Get the width
|
559 |
+
$width = isset($field['width']) ? ' style="width:'.$field['width'].'"' : '';
|
560 |
+
|
561 |
+
if( isset($field['type']) ) {
|
562 |
+
|
563 |
+
$field['id'] = $main_id.'['.$pos.']['.$id.']';
|
564 |
+
|
565 |
+
// Call the function to display the field
|
566 |
+
if ( function_exists('mtphr_dnt_metaboxer_'.$field['type']) ) {
|
567 |
+
|
568 |
+
echo '<td'.$width.' class="mtphr-dnt-metaboxer-list-structure-item mtphr-dnt-metaboxer'.$main_id.'-'.$id.'" base="'.$main_id.'" field="'.$id.'">';
|
569 |
+
call_user_func( 'mtphr_dnt_metaboxer_'.$field['type'], $field, $value );
|
570 |
+
echo '</td>';
|
571 |
+
}
|
572 |
+
}
|
573 |
+
}
|
574 |
+
|
575 |
+
return ob_get_clean();
|
576 |
+
}
|
577 |
+
}
|
578 |
+
}
|
579 |
+
|
580 |
+
/**
|
581 |
+
* Renders a sort.
|
582 |
+
*
|
583 |
+
* @since 1.0.0
|
584 |
+
*/
|
585 |
+
function mtphr_dnt_metaboxer_sort( $field, $value='' ) {
|
586 |
+
|
587 |
+
global $post;
|
588 |
+
|
589 |
+
$rows = array();
|
590 |
+
if( is_array($value) ) {
|
591 |
+
foreach( $value as $id ) {
|
592 |
+
$rows[$id] = $field['rows'][$id];
|
593 |
+
}
|
594 |
+
} else {
|
595 |
+
$rows = $field['rows'];
|
596 |
+
}
|
597 |
+
|
598 |
+
$output = '<table>';
|
599 |
+
|
600 |
+
foreach( $rows as $id => $data ) {
|
601 |
+
|
602 |
+
$output .= '<tr class="mtphr-dnt-metaboxer-sort-item"><td class="mtphr-dnt-metaboxer-sort-item-handle"><span></span></td>';
|
603 |
+
if( isset($data['name']) ) {
|
604 |
+
$output .= '<td class="mtphr-dnt-metaboxer-sort-name">'.$data['name'].'</td>';
|
605 |
+
}
|
606 |
+
$output .= '<td><input name="'.$field['id'].'[]" id="'.$field['id'].'[]" type="hidden" value="'.$id.'">';
|
607 |
+
|
608 |
+
// Find the value
|
609 |
+
$data_value = get_post_meta( $post->ID, $data['id'], true );
|
610 |
+
if( $data_value == '' && isset($data['default']) ) {
|
611 |
+
$data_value = $data['default'];
|
612 |
+
}
|
613 |
+
|
614 |
+
ob_start();
|
615 |
+
// Call the function to display the field
|
616 |
+
if ( function_exists('mtphr_dnt_metaboxer_'.$data['type']) ) {
|
617 |
+
call_user_func( 'mtphr_dnt_metaboxer_'.$data['type'], $data, $data_value );
|
618 |
+
}
|
619 |
+
$output .= ob_get_clean();
|
620 |
+
|
621 |
+
$output .= '</td>';
|
622 |
+
|
623 |
+
$output .= '</tr>';
|
624 |
+
}
|
625 |
+
|
626 |
+
$output .= '</table>';
|
627 |
+
|
628 |
+
echo $output;
|
629 |
+
|
630 |
+
// Add appended fields
|
631 |
+
mtphr_dnt_metaboxer_append_field($field);
|
632 |
+
}
|
633 |
+
|
634 |
+
/**
|
635 |
+
* Renders an html field.
|
636 |
+
*
|
637 |
+
* @since 1.0.0
|
638 |
+
*/
|
639 |
+
function mtphr_dnt_metaboxer_html( $field, $value='' ) {
|
640 |
+
|
641 |
+
// Echo the html
|
642 |
+
echo $value;
|
643 |
+
|
644 |
+
// Add appended fields
|
645 |
+
mtphr_dnt_metaboxer_append_field($field);
|
646 |
+
}
|
647 |
+
|
648 |
+
/**
|
649 |
+
* Renders a metabox toggle.
|
650 |
+
*
|
651 |
+
* @since 1.0.0
|
652 |
+
*/
|
653 |
+
function mtphr_dnt_metaboxer_metabox_toggle( $field, $value='' ) {
|
654 |
+
|
655 |
+
if( isset($field['options']) ) {
|
656 |
+
|
657 |
+
$output = '';
|
658 |
+
$output .= '<input type="hidden" id="'.$field['id'].'" name="'.$field['id'].'" value="'.$value.'" />';
|
659 |
+
|
660 |
+
foreach( $field['options'] as $i => $option ) {
|
661 |
+
|
662 |
+
$button = $option['button'];
|
663 |
+
$metaboxes = $option['metaboxes'];
|
664 |
+
$metabox_list = join( ',', $metaboxes );
|
665 |
+
|
666 |
+
// Create a button
|
667 |
+
$selected = ( $value == $i ) ? ' button-primary' : '';
|
668 |
+
$output .= '<a href="'.$i.'" metaboxes="'.$metabox_list.'" class="mtphr-dnt-metaboxer-metabox-toggle button'.$selected.'">'.$button.'</a> ';
|
669 |
+
}
|
670 |
+
|
671 |
+
echo $output;
|
672 |
+
}
|
673 |
+
|
674 |
+
// Add appended fields
|
675 |
+
mtphr_dnt_metaboxer_append_field($field);
|
676 |
+
}
|
677 |
+
|
678 |
+
|
679 |
+
|
680 |
+
|
681 |
+
/**
|
682 |
+
* Redners a file attachment
|
683 |
+
*
|
684 |
+
* @since 1.0.0
|
685 |
+
*/
|
686 |
+
function mtphr_dnt_metaboxer_file( $field, $value='' ) {
|
687 |
+
|
688 |
+
// Check if there's actually a file
|
689 |
+
$file = false;
|
690 |
+
if( $value != '' ) {
|
691 |
+
$file = get_post( $value );
|
692 |
+
}
|
693 |
+
|
694 |
+
// If there isn't a file reset the value
|
695 |
+
if( !$file ) {
|
696 |
+
$value = '';
|
697 |
+
}
|
698 |
+
?>
|
699 |
+
|
700 |
+
<input class="mtphr-dnt-metaboxer-file-value" type="hidden" id="<?php echo $field['id']; ?>" name="<?php echo $field['id']; ?>" value="<?php echo $value; ?>" />
|
701 |
+
|
702 |
+
<?php
|
703 |
+
echo isset( $field['button'] ) ? '<a href="#" class="button mtphr-dnt-metaboxer-file-upload">'.$field['button'].'</a>' : '<a href="#" class="button custom-media-upload">Insert File</a>';
|
704 |
+
|
705 |
+
if( $file ) {
|
706 |
+
|
707 |
+
$type = explode( '/', $file->post_mime_type );
|
708 |
+
|
709 |
+
// Display the file
|
710 |
+
echo mtphr_dnt_metaboxer_file_display( $file->ID, $type[0], $file->guid, $file->post_title, $file -> post_excerpt, $file->post_content );
|
711 |
+
}
|
712 |
+
|
713 |
+
// Add appended fields
|
714 |
+
mtphr_dnt_metaboxer_append_field($field);
|
715 |
+
}
|
716 |
+
|
717 |
+
add_action( 'wp_ajax_mtphr_dnt_metaboxer_ajax_file_display', 'mtphr_dnt_metaboxer_ajax_file_display' );
|
718 |
+
/**
|
719 |
+
* Ajax function used to delete attachments
|
720 |
+
*
|
721 |
+
* @since 1.0.0
|
722 |
+
*/
|
723 |
+
function mtphr_dnt_metaboxer_ajax_file_display() {
|
724 |
+
|
725 |
+
// Get access to the database
|
726 |
+
global $wpdb;
|
727 |
+
|
728 |
+
// Check the nonce
|
729 |
+
check_ajax_referer( 'mtphr_dnt', 'security' );
|
730 |
+
|
731 |
+
// Get variables
|
732 |
+
$id = $_POST['id'];
|
733 |
+
$type = $_POST['type'];
|
734 |
+
$url = $_POST['url'];
|
735 |
+
$title = $_POST['title'];
|
736 |
+
$caption = $_POST['caption'];
|
737 |
+
$description = $_POST['description'];
|
738 |
+
|
739 |
+
// Display the file
|
740 |
+
mtphr_dnt_metaboxer_file_display( $id, $type, $url, $title, $caption, $description );
|
741 |
+
|
742 |
+
die(); // this is required to return a proper result
|
743 |
+
}
|
744 |
+
|
745 |
+
// Display the file
|
746 |
+
function mtphr_dnt_metaboxer_file_display( $id, $type, $url, $title, $caption, $description ) {
|
747 |
+
|
748 |
+
$src = '';
|
749 |
+
switch( $type ) {
|
750 |
+
|
751 |
+
case 'image':
|
752 |
+
$att = wp_get_attachment_image_src( $id, 'thumbnail' );
|
753 |
+
$src = $att[0];
|
754 |
+
break;
|
755 |
+
|
756 |
+
case 'application':
|
757 |
+
$att = wp_get_attachment_image_src( $id, 'thumbnail', true );
|
758 |
+
$src = $att[0];
|
759 |
+
break;
|
760 |
+
}
|
761 |
+
?>
|
762 |
+
<table class="mtphr-dnt-metaboxer-file-table">
|
763 |
+
<tr>
|
764 |
+
<td class="mtphr-dnt-metaboxer-file-display">
|
765 |
+
<a href="<?php echo $url; ?>" target="_blank" class="clearfix">
|
766 |
+
<img class="custom_media_image" src="<?php echo $src; ?>" />
|
767 |
+
<span class="mtphr-dnt-metaboxer-file-title"><strong>Title:</strong> <?php echo $title; ?></span><br/>
|
768 |
+
<?php if( $caption != '' ) { ?>
|
769 |
+
<span class="mtphr-dnt-metaboxer-file-caption"><strong>Caption:</strong> <?php echo $caption; ?></span><br/>
|
770 |
+
<?php }
|
771 |
+
if( $description != '' ) { ?>
|
772 |
+
<span class="mtphr-dnt-metaboxer-file-description"><strong>Description:</strong> <?php echo $description; ?></span>
|
773 |
+
<?php } ?>
|
774 |
+
</a>
|
775 |
+
</td>
|
776 |
+
<td class="mtphr-dnt-metaboxer-file-delete">
|
777 |
+
<a href="#"></a>
|
778 |
+
</td>
|
779 |
+
</tr>
|
780 |
+
</table>
|
781 |
+
<?php
|
782 |
+
}
|
783 |
+
|
784 |
+
|
785 |
+
|
786 |
+
|
787 |
+
/**
|
788 |
+
* Render a gallery attachment
|
789 |
+
*
|
790 |
+
* @since 1.0.0
|
791 |
+
*/
|
792 |
+
function mtphr_dnt_metaboxer_gallery( $field, $value='' ) {
|
793 |
+
|
794 |
+
/* Create the buttons */
|
795 |
+
$button = isset( $field['button'] ) ? $field['button'] : 'Insert Media';
|
796 |
+
|
797 |
+
$output = '<div class="mtphr-dnt-metaboxer-attachment-buttons"><a href="#" class="button mtphr-dnt-metaboxer-upload-button">'.$button.'</a></div>';
|
798 |
+
|
799 |
+
/* If there is a file limit */
|
800 |
+
if ( isset( $field['limit'] ) ) {
|
801 |
+
$output .= '<input class="mtphr-dnt-metaboxer-attachment-limit" type="hidden" value="'.$field['limit'].'" />';
|
802 |
+
}
|
803 |
+
$output .= '<div class="mtphr-dnt-metaboxer-input-container" id="'.$field['id'].'"></div>';
|
804 |
+
$output .= '<ul id="'.wp_create_nonce( 'mtphr_dnt_metaboxer_ajax_file_nonce' ).'" class="mtphr-dnt-metaboxer-gallery-attachment-container mtphr-dnt-metaboxer-attachment-container clearfix">';
|
805 |
+
|
806 |
+
/* Loop through the existing attachments */
|
807 |
+
if( $value != '' ){
|
808 |
+
foreach( $value as $id ) {
|
809 |
+
$output .= mtphr_dnt_metaboxer_thumb( $id );
|
810 |
+
}
|
811 |
+
}
|
812 |
+
$output .= '</ul>';
|
813 |
+
echo $output;
|
814 |
+
|
815 |
+
// Add appended fields
|
816 |
+
mtphr_dnt_metaboxer_append_field($field);
|
817 |
+
}
|
818 |
+
|
819 |
+
/**
|
820 |
+
* Create the gallery thumbnail containers.
|
821 |
+
*
|
822 |
+
* @since 1.0.0
|
823 |
+
*/
|
824 |
+
function mtphr_dnt_metaboxer_thumb( $id, $preview=true ) {
|
825 |
+
|
826 |
+
$html = '';
|
827 |
+
$attachment = get_post( $id );
|
828 |
+
$nonce = wp_create_nonce( 'mtphr_dnt_metaboxer_ajax_file_nonce' );
|
829 |
+
|
830 |
+
if ( $attachment ) {
|
831 |
+
|
832 |
+
$mime = $attachment->post_mime_type;
|
833 |
+
|
834 |
+
$html = '<li id="'.$id.'" class="mtphr-dnt-metaboxer-gallery-attachment mtphr-dnt-metaboxer-sort-container clearfix">';
|
835 |
+
|
836 |
+
switch ( $mime ) {
|
837 |
+
|
838 |
+
case 'image/jpeg':
|
839 |
+
$thumb = wp_get_attachment_image_src( $id, 'metaboxer-gallery-thumb' );
|
840 |
+
$html .= '<div class="mtphr-dnt-metaboxer-gallery-attachment-bg mtphr-dnt-metaboxer-gallery-attachment-bg-image" style="background-image:url('.$thumb[0].');"></div>';
|
841 |
+
$html .= '<div class="mtphr-dnt-metaboxer-attachment-mime-type mtphr-dnt-metaboxer-attachment-mime-type-image"></div>';
|
842 |
+
break;
|
843 |
+
|
844 |
+
case 'image/png':
|
845 |
+
$thumb = wp_get_attachment_image_src( $id, 'metaboxer-gallery-thumb' );
|
846 |
+
$html .= '<div class="mtphr-dnt-metaboxer-gallery-attachment-bg mtphr-dnt-metaboxer-gallery-attachment-bg-image" style="background-image:url('.$thumb[0].');"></div>';
|
847 |
+
$html .= '<div class="mtphr-dnt-metaboxer-attachment-mime-type mtphr-dnt-metaboxer-attachment-mime-type-image"></div>';
|
848 |
+
break;
|
849 |
+
|
850 |
+
case 'application/pdf':
|
851 |
+
$thumb = wp_get_attachment_image_src( $id, false, true );
|
852 |
+
$html .= '<div class="mtphr-dnt-metaboxer-gallery-attachment-bg mtphr-dnt-metaboxer-gallery-attachment-bg-pdf" style="background-image:url('.$thumb[0].');"></div>';
|
853 |
+
$html .= '<div class="mtphr-dnt-metaboxer-attachment-mime-type mtphr-dnt-metaboxer-attachment-mime-type-pdf"></div>';
|
854 |
+
break;
|
855 |
+
|
856 |
+
case 'application/zip':
|
857 |
+
$thumb = wp_get_attachment_image_src( $id, false, true );
|
858 |
+
$html .= '<div class="mtphr-dnt-metaboxer-gallery-attachment-bg mtphr-dnt-metaboxer-gallery-attachment-bg-zip" style="background-image:url('.$thumb[0].');"></div>';
|
859 |
+
$html .= '<div class="mtphr-dnt-metaboxer-attachment-mime-type mtphr-dnt-metaboxer-attachment-mime-type-zip"></div>';
|
860 |
+
break;
|
861 |
+
|
862 |
+
case 'audio/mpeg':
|
863 |
+
$image_id = get_post_meta( $id, '_attachment_poster_image', true );
|
864 |
+
$default = ( !$image_id || $image_id=='none' ) ? true : false;
|
865 |
+
$thumb = ( $default ) ? wp_get_attachment_image_src( $id, false, true ) : wp_get_attachment_image_src( $image_id, 'metaboxer-gallery-thumb' );
|
866 |
+
$html .= '<div class="mtphr-dnt-metaboxer-gallery-attachment-bg mtphr-dnt-metaboxer-gallery-attachment-bg-audio" style="background-image:url('.$thumb[0].');"></div>';
|
867 |
+
$html .= '<div class="mtphr-dnt-metaboxer-attachment-mime-type mtphr-dnt-metaboxer-attachment-mime-type-audio"></div>';
|
868 |
+
break;
|
869 |
+
|
870 |
+
case 'video/mp4':
|
871 |
+
$image_id = get_post_meta( $id, '_attachment_poster_image', true );
|
872 |
+
$default = ( !$image_id || $image_id=='none' ) ? true : false;
|
873 |
+
$thumb = ( $default ) ? wp_get_attachment_image_src( $id, false, true ) : wp_get_attachment_image_src( $image_id, 'metaboxer-gallery-thumb' );
|
874 |
+
$html .= '<div class="mtphr-dnt-metaboxer-gallery-attachment-bg mtphr-dnt-metaboxer-gallery-attachment-bg-video" style="background-image:url('.$thumb[0].');"></div>';
|
875 |
+
$html .= '<div class="mtphr-dnt-metaboxer-attachment-mime-type mtphr-dnt-metaboxer-attachment-mime-type-video"></div>';
|
876 |
+
break;
|
877 |
+
|
878 |
+
case 'video/m4v':
|
879 |
+
$image_id = get_post_meta( $id, '_attachment_poster_image', true );
|
880 |
+
$default = ( !$image_id || $image_id=='none' ) ? true : false;
|
881 |
+
$thumb = ( $default ) ? wp_get_attachment_image_src( $id, false, true ) : wp_get_attachment_image_src( $image_id, 'metaboxer-gallery-thumb' );
|
882 |
+
$html .= '<div class="mtphr-dnt-metaboxer-gallery-attachment-bg mtphr-dnt-metaboxer-gallery-attachment-bg-video" style="background-image:url('.$thumb[0].');"></div>';
|
883 |
+
$html .= '<div class="mtphr-dnt-metaboxer-attachment-mime-type mtphr-dnt-metaboxer-attachment-mime-type-video"></div>';
|
884 |
+
break;
|
885 |
+
|
886 |
+
case 'vimeo':
|
887 |
+
$thumb = get_post_meta( $id, '_video_thumb_large', true );
|
888 |
+
$html .= '<div class="mtphr-dnt-metaboxer-gallery-attachment-bg mtphr-dnt-metaboxer-gallery-attachment-bg-vimeo" style="background-image:url('.$thumb.');"></div>';
|
889 |
+
$html .= '<div class="mtphr-dnt-metaboxer-attachment-mime-type mtphr-dnt-metaboxer-attachment-mime-type-vimeo"></div>';
|
890 |
+
break;
|
891 |
+
|
892 |
+
case 'youtube':
|
893 |
+
$thumb = get_post_meta( $id, '_video_thumb_large', true );
|
894 |
+
$html .= '<div class="mtphr-dnt-metaboxer-gallery-attachment-bg mtphr-dnt-metaboxer-gallery-attachment-bg-youtube" style="background-image:url('.$thumb.');"></div>';
|
895 |
+
$html .= '<div class="mtphr-dnt-metaboxer-attachment-mime-type mtphr-dnt-metaboxer-attachment-mime-type-youtube"></div>';
|
896 |
+
break;
|
897 |
+
|
898 |
+
default:
|
899 |
+
// Call the function to display the custom field
|
900 |
+
call_user_func( 'mtphr_dnt_metaboxer_'.str_replace('%/%','_',$mime).'_thumb', $id, $nonce );
|
901 |
+
$html .= $mime;
|
902 |
+
break;
|
903 |
+
}
|
904 |
+
|
905 |
+
$html .= '<div class="mtphr-dnt-metaboxer-attachment-links">';
|
906 |
+
//$html .= '<a href="'.$id.'" rel="attachment_preview" class="mtphr-dnt-metaboxer-attachment-preview"></a>';
|
907 |
+
$html .= '<a href="'.$id.'" class="mtphr-dnt-metaboxer-attachment-settings"></a>';
|
908 |
+
$html .= '<a href="'.$id.'" class="mtphr-dnt-metaboxer-attachment-delete"></a>';
|
909 |
+
$html .= '</div>';
|
910 |
+
|
911 |
+
$html .= '</li>';
|
912 |
+
}
|
913 |
+
|
914 |
+
return $html;
|
915 |
+
}
|
916 |
+
|
917 |
+
|
918 |
+
|
919 |
+
|
920 |
+
/**
|
921 |
+
* Renders the code fields.
|
922 |
+
*
|
923 |
+
* @since 1.0.0
|
924 |
+
*/
|
925 |
+
function mtphr_dnt_metaboxer_code( $field, $value='' ) {
|
926 |
+
|
927 |
+
global $post;
|
928 |
+
|
929 |
+
// Display the shortcode code
|
930 |
+
if( $field['id'] == '_mtphr_dnt_shortcode' ) {
|
931 |
+
|
932 |
+
echo '<pre><p>[ditty_news_ticker id="'.$post->ID.'"]</p></pre>';
|
933 |
+
|
934 |
+
// Display the function code
|
935 |
+
} elseif( $field['id'] == '_mtphr_dnt_function' ) {
|
936 |
+
|
937 |
+
echo '<pre><p>ditty_news_ticker('.$post->ID.');</p></pre>';
|
938 |
+
}
|
939 |
+
|
940 |
+
// Display a "Select All" button
|
941 |
+
$button = isset($field['button']) ? $field['button'] : __('Select Code', 'ditty-news-ticker');
|
942 |
+
echo '<a href="#" class="button mtphr-dnt-metaboxer-code-select">'.$button.'</a>';
|
943 |
+
}
|
944 |
+
|
includes/post-types.php
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Create the News Ticker post type
|
4 |
+
*
|
5 |
+
* @package Ditty News Ticker
|
6 |
+
*/
|
7 |
+
|
8 |
+
|
9 |
+
|
10 |
+
|
11 |
+
add_action( 'init','mtphr_dnt_posttype' );
|
12 |
+
/**
|
13 |
+
* Add post types
|
14 |
+
*
|
15 |
+
* @since 1.0.0
|
16 |
+
*/
|
17 |
+
function mtphr_dnt_posttype() {
|
18 |
+
|
19 |
+
$labels = array(
|
20 |
+
'name' => __( 'News Tickers', 'rj' ),
|
21 |
+
'singular_name' => __( 'News Ticker', 'rj' ),
|
22 |
+
'add_new' => __( 'Add New', 'rj' ),
|
23 |
+
'add_new_item' => __( 'Add New News Ticker', 'rj' ),
|
24 |
+
'edit_item' => __( 'Edit News Ticker', 'rj' ),
|
25 |
+
'new_item' => __( 'New News Ticker', 'rj' ),
|
26 |
+
'view_item' => __( 'View News Ticker', 'rj' ),
|
27 |
+
'search_items' => __( 'Search News Tickers', 'rj' ),
|
28 |
+
'not_found' => __( 'No News Tickers Found', 'rj' ),
|
29 |
+
'not_found_in_trash' => __( 'No News Tickers Found In Trash', 'rj' ),
|
30 |
+
'parent_item_colon' => '',
|
31 |
+
'menu_name' => __( 'News Tickers', 'rj' )
|
32 |
+
);
|
33 |
+
|
34 |
+
// Create the arguments
|
35 |
+
$args = array(
|
36 |
+
'labels' => $labels,
|
37 |
+
'public' => false,
|
38 |
+
'publicly_queryable' => true,
|
39 |
+
'exclude_from_search' => true,
|
40 |
+
'show_ui' => true,
|
41 |
+
'show_in_menu' => true,
|
42 |
+
'query_var' => true,
|
43 |
+
'rewrite' => true,
|
44 |
+
'supports' => array( 'title' ),
|
45 |
+
'show_in_nav_menus' => false
|
46 |
+
);
|
47 |
+
|
48 |
+
register_post_type( 'ditty_news_ticker', $args );
|
49 |
+
}
|
50 |
+
|
51 |
+
|
includes/scripts.php
ADDED
@@ -0,0 +1,594 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Load CSS & jQuery Scripts
|
4 |
+
*
|
5 |
+
* @package Ditty News Ticker
|
6 |
+
*/
|
7 |
+
|
8 |
+
|
9 |
+
|
10 |
+
|
11 |
+
add_action( 'admin_enqueue_scripts', 'mtphr_dnt_admin_scripts' );
|
12 |
+
/**
|
13 |
+
* Load the metaboxer scripts
|
14 |
+
*
|
15 |
+
* @since 1.0.0
|
16 |
+
*/
|
17 |
+
function mtphr_dnt_admin_scripts( $hook ) {
|
18 |
+
|
19 |
+
global $typenow;
|
20 |
+
|
21 |
+
if ( $typenow == 'ditty_news_ticker' ) {
|
22 |
+
|
23 |
+
// Load the metaboxer style sheet
|
24 |
+
wp_register_style( 'ditty-metaboxer', MTPHR_DNT_URL.'/includes/metaboxer/metaboxer.css', array( 'colors', 'thickbox' ), MTPHR_DNT_VERSION );
|
25 |
+
wp_enqueue_style( 'ditty-metaboxer' );
|
26 |
+
|
27 |
+
// Load scipts for the media uploader
|
28 |
+
if(function_exists( 'wp_enqueue_media' )){
|
29 |
+
wp_enqueue_media();
|
30 |
+
} else {
|
31 |
+
wp_enqueue_style('thickbox');
|
32 |
+
wp_enqueue_script('media-upload');
|
33 |
+
wp_enqueue_script('thickbox');
|
34 |
+
}
|
35 |
+
|
36 |
+
// Load the metaboxer jQuery
|
37 |
+
wp_register_script( 'ditty-metaboxer', MTPHR_DNT_URL.'/includes/metaboxer/metaboxer.js', array( 'jquery','jquery-ui-core','jquery-ui-sortable' ), MTPHR_DNT_VERSION, true );
|
38 |
+
wp_enqueue_script( 'ditty-metaboxer' );
|
39 |
+
}
|
40 |
+
|
41 |
+
// Load the plugin css
|
42 |
+
wp_register_style( 'mtphr-dnt-admin', MTPHR_DNT_URL.'/assets/css/style-admin.css', false, MTPHR_DNT_VERSION );
|
43 |
+
wp_enqueue_style( 'mtphr-dnt-admin' );
|
44 |
+
}
|
45 |
+
|
46 |
+
|
47 |
+
|
48 |
+
|
49 |
+
add_action( 'wp_enqueue_scripts', 'mtphr_dnt_scripts' );
|
50 |
+
/**
|
51 |
+
* Load the front end scripts
|
52 |
+
*
|
53 |
+
* @since 1.0.0
|
54 |
+
*/
|
55 |
+
function mtphr_dnt_scripts() {
|
56 |
+
|
57 |
+
// Load the css
|
58 |
+
wp_register_style( 'ditty-news-ticker', MTPHR_DNT_URL.'/assets/css/style.css', false, MTPHR_DNT_VERSION );
|
59 |
+
wp_enqueue_style( 'ditty-news-ticker' );
|
60 |
+
|
61 |
+
// Load the jQuery easing
|
62 |
+
wp_register_script( 'jquery-easing', MTPHR_DNT_URL.'/assets/js/jquery.easing.1.3.js', array('jquery'), MTPHR_DNT_VERSION, true );
|
63 |
+
wp_enqueue_script( 'jquery-easing' );
|
64 |
+
|
65 |
+
// Load the jQuery
|
66 |
+
wp_register_script( 'ditty-news-ticker', MTPHR_DNT_URL.'/assets/js/ditty-news-ticker.js', array('jquery'), MTPHR_DNT_VERSION, true );
|
67 |
+
wp_enqueue_script( 'ditty-news-ticker' );
|
68 |
+
}
|
69 |
+
|
70 |
+
|
71 |
+
|
72 |
+
|
73 |
+
add_action( 'mtphr_dnt_after', 'mtphr_dnt_ticker_scripts', 10, 2 );
|
74 |
+
/**
|
75 |
+
* Add the class scripts
|
76 |
+
*
|
77 |
+
* @since 1.0.0
|
78 |
+
*/
|
79 |
+
function mtphr_dnt_ticker_scripts( $id, $meta_data ) {
|
80 |
+
|
81 |
+
extract( $meta_data );
|
82 |
+
|
83 |
+
// Get the ticker classe
|
84 |
+
$ticker = '#mtphr-dnt-'.$id;
|
85 |
+
|
86 |
+
// Add a unique id class, if there is one
|
87 |
+
if( isset($_mtphr_dnt_unique_id) ) {
|
88 |
+
if( $_mtphr_dnt_unique_id != '' ) {
|
89 |
+
$ticker = '#mtphr-dnt-'.$id.'-'.sanitize_html_class( $_mtphr_dnt_unique_id );
|
90 |
+
}
|
91 |
+
}
|
92 |
+
|
93 |
+
if( $_mtphr_dnt_mode == 'scroll' ) {
|
94 |
+
$pause = 0;
|
95 |
+
if( isset($_mtphr_dnt_scroll_pause) ) {
|
96 |
+
$pause = $_mtphr_dnt_scroll_pause ? 1 : 0;
|
97 |
+
}
|
98 |
+
ob_start(); ?>
|
99 |
+
<script>
|
100 |
+
jQuery( document ).ready( function($) {
|
101 |
+
$( '<?php echo $ticker; ?>' ).ditty_news_ticker({
|
102 |
+
type : '<?php echo $_mtphr_dnt_mode; ?>',
|
103 |
+
scroll_direction : '<?php echo $_mtphr_dnt_scroll_direction; ?>',
|
104 |
+
scroll_speed : <?php echo intval($_mtphr_dnt_scroll_speed); ?>,
|
105 |
+
scroll_pause : <?php echo $pause; ?>,
|
106 |
+
scroll_spacing : <?php echo intval($_mtphr_dnt_scroll_tick_spacing); ?>
|
107 |
+
});
|
108 |
+
});
|
109 |
+
</script>
|
110 |
+
<?php // Echo the compressed scripts
|
111 |
+
echo mtphr_dnt_compress_script( ob_get_clean() );
|
112 |
+
|
113 |
+
} elseif( $_mtphr_dnt_mode == 'rotate' ) {
|
114 |
+
$rotate = 0; $pause = 0; $nav_autohide = 0; $nav_reverse = 0;
|
115 |
+
if( isset($_mtphr_dnt_auto_rotate) ) {
|
116 |
+
$rotate = $_mtphr_dnt_auto_rotate ? 1 : 0;
|
117 |
+
}
|
118 |
+
if( isset($_mtphr_dnt_rotate_pause) ) {
|
119 |
+
$pause = $_mtphr_dnt_rotate_pause ? 1 : 0;
|
120 |
+
}
|
121 |
+
if( isset($_mtphr_dnt_rotate_directional_nav_reverse) ) {
|
122 |
+
$nav_reverse = $_mtphr_dnt_rotate_directional_nav_reverse ? 1 : 0;
|
123 |
+
}
|
124 |
+
ob_start(); ?>
|
125 |
+
<script>
|
126 |
+
jQuery( document ).ready( function($) {
|
127 |
+
$( '<?php echo $ticker; ?>' ).ditty_news_ticker({
|
128 |
+
type : '<?php echo $_mtphr_dnt_mode; ?>',
|
129 |
+
rotate_type : '<?php echo $_mtphr_dnt_rotate_type; ?>',
|
130 |
+
auto_rotate : <?php echo $rotate; ?>,
|
131 |
+
rotate_delay : <?php echo intval($_mtphr_dnt_rotate_delay); ?>,
|
132 |
+
rotate_pause : <?php echo $pause; ?>,
|
133 |
+
rotate_speed : <?php echo intval($_mtphr_dnt_rotate_speed); ?>,
|
134 |
+
rotate_ease : '<?php echo $_mtphr_dnt_rotate_ease; ?>',
|
135 |
+
nav_reverse : <?php echo $nav_reverse; ?>
|
136 |
+
});
|
137 |
+
});
|
138 |
+
</script>
|
139 |
+
<?php // Echo the compressed scripts
|
140 |
+
echo mtphr_dnt_compress_script( ob_get_clean() );
|
141 |
+
|
142 |
+
// Add the rotation in/out scripts to the footer
|
143 |
+
if( function_exists('mtphr_dnt_rotate_'.$_mtphr_dnt_rotate_type.'_scripts') ) {
|
144 |
+
add_action( 'wp_footer', 'mtphr_dnt_rotate_'.$_mtphr_dnt_rotate_type.'_scripts' );
|
145 |
+
}
|
146 |
+
|
147 |
+
if( $nav_reverse) {
|
148 |
+
|
149 |
+
switch( $_mtphr_dnt_rotate_type ) {
|
150 |
+
|
151 |
+
case 'slide_left':
|
152 |
+
if( function_exists('mtphr_dnt_rotate_slide_right_scripts') ) {
|
153 |
+
add_action( 'wp_footer', 'mtphr_dnt_rotate_slide_right_scripts' );
|
154 |
+
}
|
155 |
+
break;
|
156 |
+
|
157 |
+
case 'slide_right':
|
158 |
+
if( function_exists('mtphr_dnt_rotate_slide_left_scripts') ) {
|
159 |
+
add_action( 'wp_footer', 'mtphr_dnt_rotate_slide_left_scripts' );
|
160 |
+
}
|
161 |
+
break;
|
162 |
+
|
163 |
+
case 'slide_up':
|
164 |
+
if( function_exists('mtphr_dnt_rotate_slide_down_scripts') ) {
|
165 |
+
add_action( 'wp_footer', 'mtphr_dnt_rotate_slide_down_scripts' );
|
166 |
+
}
|
167 |
+
break;
|
168 |
+
|
169 |
+
case 'slide_down':
|
170 |
+
if( function_exists('mtphr_dnt_rotate_slide_up_scripts') ) {
|
171 |
+
add_action( 'wp_footer', 'mtphr_dnt_rotate_slide_up_scripts' );
|
172 |
+
}
|
173 |
+
break;
|
174 |
+
}
|
175 |
+
}
|
176 |
+
}
|
177 |
+
}
|
178 |
+
|
179 |
+
|
180 |
+
|
181 |
+
|
182 |
+
add_action( 'wp_head', 'mtphr_dnt_custom_css' );
|
183 |
+
/**
|
184 |
+
* Add custom css
|
185 |
+
*
|
186 |
+
* @since 1.0.0
|
187 |
+
*/
|
188 |
+
function mtphr_dnt_custom_css() {
|
189 |
+
$settings = get_option( 'mtphr_dnt_general_settings' );
|
190 |
+
if( $settings ) {
|
191 |
+
|
192 |
+
if( isset($settings['css']) ) {
|
193 |
+
|
194 |
+
$styles = '<style>'.sanitize_text_field( $settings['css'] ).'</style>';
|
195 |
+
echo mtphr_dnt_compress_script( $styles );
|
196 |
+
}
|
197 |
+
}
|
198 |
+
}
|
199 |
+
|
200 |
+
|
201 |
+
|
202 |
+
|
203 |
+
/**
|
204 |
+
* Add the rotate fade scripts
|
205 |
+
*
|
206 |
+
* @since 1.0.0
|
207 |
+
*/
|
208 |
+
function mtphr_dnt_rotate_fade_scripts() {
|
209 |
+
ob_start(); ?>
|
210 |
+
<script>
|
211 |
+
|
212 |
+
// Initialize the ticks and ticker
|
213 |
+
function mtphr_dnt_rotator_fade_init( $ticker, ticks, rotate_speed, ease ) {
|
214 |
+
|
215 |
+
// Get the first tick
|
216 |
+
$tick = ticks[0];
|
217 |
+
|
218 |
+
// Find the width of the tick
|
219 |
+
var w = $tick.parents('.mtphr-dnt-rotate').width();
|
220 |
+
var h = $tick.height();
|
221 |
+
|
222 |
+
// Set the height of the ticker
|
223 |
+
$ticker.css( 'height', h+'px' );
|
224 |
+
|
225 |
+
// Set the initial position of the width & make sure it's visible
|
226 |
+
$tick.show();
|
227 |
+
}
|
228 |
+
|
229 |
+
// Show the new tick
|
230 |
+
function mtphr_dnt_rotator_fade_in( $ticker, $tick, $prev, rotate_speed, ease ) {
|
231 |
+
$tick.fadeIn( rotate_speed );
|
232 |
+
|
233 |
+
var h = $tick.height();
|
234 |
+
|
235 |
+
// Resize the ticker
|
236 |
+
$ticker.stop().animate( {
|
237 |
+
height: h+'px'
|
238 |
+
}, rotate_speed, ease, function() {
|
239 |
+
});
|
240 |
+
}
|
241 |
+
|
242 |
+
// Hide the old tick
|
243 |
+
function mtphr_dnt_rotator_fade_out( $ticker, $tick, $next, rotate_speed, ease ) {
|
244 |
+
$tick.fadeOut( rotate_speed );
|
245 |
+
}
|
246 |
+
</script>
|
247 |
+
<?php // Echo the compressed scripts
|
248 |
+
echo mtphr_dnt_compress_script( ob_get_clean() );
|
249 |
+
}
|
250 |
+
|
251 |
+
/**
|
252 |
+
* Add the rotate slide left scripts
|
253 |
+
*
|
254 |
+
* @since 1.0.0
|
255 |
+
*/
|
256 |
+
function mtphr_dnt_rotate_slide_left_scripts() {
|
257 |
+
ob_start(); ?>
|
258 |
+
<script>
|
259 |
+
|
260 |
+
// Initialize the ticks and ticker
|
261 |
+
function mtphr_dnt_rotator_slide_left_init( $ticker, ticks, rotate_speed, ease ) {
|
262 |
+
|
263 |
+
// Get the first tick
|
264 |
+
$tick = ticks[0];
|
265 |
+
|
266 |
+
// Find the dimensions of the tick
|
267 |
+
var w = $tick.parents('.mtphr-dnt-rotate').width();
|
268 |
+
var h = $tick.height();
|
269 |
+
|
270 |
+
// Set the height of the ticker
|
271 |
+
$ticker.css( 'height', h+'px' );
|
272 |
+
|
273 |
+
// Set the initial position of the width & make sure it's visible
|
274 |
+
$tick.css( 'left', 0 );
|
275 |
+
$tick.show();
|
276 |
+
|
277 |
+
// If there are any images, reset height after loading
|
278 |
+
if( $tick.find('img').length > 0 ) {
|
279 |
+
|
280 |
+
$tick.find('img').each( function(index) {
|
281 |
+
|
282 |
+
jQuery(this).load( function() {
|
283 |
+
|
284 |
+
// Find the height of the tick
|
285 |
+
var h = $tick.height();
|
286 |
+
|
287 |
+
// Set the height of the ticker
|
288 |
+
$ticker.css( 'height', h+'px' );
|
289 |
+
});
|
290 |
+
});
|
291 |
+
}
|
292 |
+
}
|
293 |
+
|
294 |
+
// Show the new tick
|
295 |
+
function mtphr_dnt_rotator_slide_left_in( $ticker, $tick, $prev, rotate_speed, ease ) {
|
296 |
+
|
297 |
+
// Find the dimensions of the tick
|
298 |
+
var w = $tick.parents('.mtphr-dnt-rotate').width();
|
299 |
+
var h = $tick.height();
|
300 |
+
|
301 |
+
// Set the initial position of the width & make sure it's visible
|
302 |
+
$tick.css( 'left', w+'px' );
|
303 |
+
$tick.show();
|
304 |
+
|
305 |
+
// Resize the ticker
|
306 |
+
$ticker.stop().animate( {
|
307 |
+
height: h+'px'
|
308 |
+
}, rotate_speed, ease, function() {
|
309 |
+
});
|
310 |
+
|
311 |
+
// Slide the tick in
|
312 |
+
$tick.stop().animate( {
|
313 |
+
left: '0'
|
314 |
+
}, rotate_speed, ease, function() {
|
315 |
+
});
|
316 |
+
}
|
317 |
+
|
318 |
+
// Hide the old tick
|
319 |
+
function mtphr_dnt_rotator_slide_left_out( $ticker, $tick, $next, rotate_speed, ease ) {
|
320 |
+
|
321 |
+
// Find the dimensions of the tick
|
322 |
+
var w = $tick.parents('.mtphr-dnt-rotate').width();
|
323 |
+
var h = $tick.height();
|
324 |
+
|
325 |
+
// Slide the tick in
|
326 |
+
$tick.stop().animate( {
|
327 |
+
left: '-'+w+'px'
|
328 |
+
}, rotate_speed, ease, function() {
|
329 |
+
// Hide the tick
|
330 |
+
$tick.hide();
|
331 |
+
});
|
332 |
+
}
|
333 |
+
</script>
|
334 |
+
<?php // Echo the compressed scripts
|
335 |
+
echo mtphr_dnt_compress_script( ob_get_clean() );
|
336 |
+
}
|
337 |
+
|
338 |
+
/**
|
339 |
+
* Add the rotate slide right scripts
|
340 |
+
*
|
341 |
+
* @since 1.0.0
|
342 |
+
*/
|
343 |
+
function mtphr_dnt_rotate_slide_right_scripts() {
|
344 |
+
ob_start(); ?>
|
345 |
+
<script>
|
346 |
+
|
347 |
+
// Initialize the ticks and ticker
|
348 |
+
function mtphr_dnt_rotator_slide_right_init( $ticker, ticks, rotate_speed, ease ) {
|
349 |
+
|
350 |
+
// Get the first tick
|
351 |
+
$tick = ticks[0];
|
352 |
+
|
353 |
+
// Find the dimensions of the tick
|
354 |
+
var w = $tick.parents('.mtphr-dnt-rotate').width();
|
355 |
+
var h = $tick.height();
|
356 |
+
|
357 |
+
// Set the height of the ticker
|
358 |
+
$ticker.css( 'height', h+'px' );
|
359 |
+
|
360 |
+
// Set the initial position of the width & make sure it's visible
|
361 |
+
$tick.css( 'left', 0 );
|
362 |
+
$tick.show();
|
363 |
+
|
364 |
+
// If there are any images, reset height after loading
|
365 |
+
if( $tick.find('img').length > 0 ) {
|
366 |
+
|
367 |
+
$tick.find('img').each( function(index) {
|
368 |
+
|
369 |
+
jQuery(this).load( function() {
|
370 |
+
|
371 |
+
// Find the height of the tick
|
372 |
+
var h = $tick.height();
|
373 |
+
|
374 |
+
// Set the height of the ticker
|
375 |
+
$ticker.css( 'height', h+'px' );
|
376 |
+
});
|
377 |
+
});
|
378 |
+
}
|
379 |
+
}
|
380 |
+
|
381 |
+
// Show the new tick
|
382 |
+
function mtphr_dnt_rotator_slide_right_in( $ticker, $tick, $prev, rotate_speed, ease ) {
|
383 |
+
|
384 |
+
// Find the dimensions of the tick
|
385 |
+
var w = $tick.parents('.mtphr-dnt-rotate').width();
|
386 |
+
var h = $tick.height();
|
387 |
+
|
388 |
+
// Set the initial position of the width & make sure it's visible
|
389 |
+
$tick.css( 'left', '-'+w+'px' );
|
390 |
+
$tick.show();
|
391 |
+
|
392 |
+
// Resize the ticker
|
393 |
+
$ticker.stop().animate( {
|
394 |
+
height: h+'px'
|
395 |
+
}, rotate_speed, ease, function() {
|
396 |
+
});
|
397 |
+
|
398 |
+
// Slide the tick in
|
399 |
+
$tick.stop().animate( {
|
400 |
+
left: '0'
|
401 |
+
}, rotate_speed, ease, function() {
|
402 |
+
});
|
403 |
+
}
|
404 |
+
|
405 |
+
// Hide the old tick
|
406 |
+
function mtphr_dnt_rotator_slide_right_out( $ticker, $tick, $next, rotate_speed, ease ) {
|
407 |
+
|
408 |
+
// Find the dimensions of the tick
|
409 |
+
var w = $tick.parents('.mtphr-dnt-rotate').width();
|
410 |
+
var h = $tick.height();
|
411 |
+
|
412 |
+
// Slide the tick in
|
413 |
+
$tick.stop().animate( {
|
414 |
+
left: w+'px'
|
415 |
+
}, rotate_speed, ease, function() {
|
416 |
+
// Hide the tick
|
417 |
+
$tick.hide();
|
418 |
+
});
|
419 |
+
}
|
420 |
+
</script>
|
421 |
+
<?php // Echo the compressed scripts
|
422 |
+
echo mtphr_dnt_compress_script( ob_get_clean() );
|
423 |
+
}
|
424 |
+
|
425 |
+
/**
|
426 |
+
* Add the rotate slide down scripts
|
427 |
+
*
|
428 |
+
* @since 1.0.0
|
429 |
+
*/
|
430 |
+
function mtphr_dnt_rotate_slide_down_scripts() {
|
431 |
+
ob_start(); ?>
|
432 |
+
<script>
|
433 |
+
|
434 |
+
// Initialize the ticks and ticker
|
435 |
+
function mtphr_dnt_rotator_slide_down_init( $ticker, ticks, rotate_speed, ease ) {
|
436 |
+
|
437 |
+
// Get the first tick
|
438 |
+
$tick = ticks[0];
|
439 |
+
|
440 |
+
// Find the height of the tick
|
441 |
+
var h = $tick.height();
|
442 |
+
|
443 |
+
// Set the height of the ticker
|
444 |
+
$ticker.css( 'height', h+'px' );
|
445 |
+
|
446 |
+
// Set the initial position of the width & make sure it's visible
|
447 |
+
$tick.css( 'top', 0 );
|
448 |
+
$tick.show();
|
449 |
+
|
450 |
+
// If there are any images, reset height after loading
|
451 |
+
if( $tick.find('img').length > 0 ) {
|
452 |
+
|
453 |
+
$tick.find('img').each( function(index) {
|
454 |
+
|
455 |
+
jQuery(this).load( function() {
|
456 |
+
|
457 |
+
// Find the height of the tick
|
458 |
+
var h = $tick.height();
|
459 |
+
|
460 |
+
// Set the height of the ticker
|
461 |
+
$ticker.css( 'height', h+'px' );
|
462 |
+
});
|
463 |
+
});
|
464 |
+
}
|
465 |
+
}
|
466 |
+
|
467 |
+
// Show the new tick
|
468 |
+
function mtphr_dnt_rotator_slide_down_in( $ticker, $tick, $prev, rotate_speed, ease ) {
|
469 |
+
|
470 |
+
// Find the height of the tick
|
471 |
+
var h = $tick.height();
|
472 |
+
|
473 |
+
// Set the initial position of the width & make sure it's visible
|
474 |
+
$tick.css( 'top', '-'+h+'px' );
|
475 |
+
$tick.show();
|
476 |
+
|
477 |
+
// Resize the ticker
|
478 |
+
$ticker.stop().animate( {
|
479 |
+
height: h+'px'
|
480 |
+
}, rotate_speed, ease, function() {
|
481 |
+
});
|
482 |
+
|
483 |
+
// Slide the tick in
|
484 |
+
$tick.stop().animate( {
|
485 |
+
top: '0'
|
486 |
+
}, rotate_speed, ease, function() {
|
487 |
+
});
|
488 |
+
}
|
489 |
+
|
490 |
+
// Hide the old tick
|
491 |
+
function mtphr_dnt_rotator_slide_down_out( $ticker, $tick, $next, rotate_speed, ease ) {
|
492 |
+
|
493 |
+
// Find the height of the next tick
|
494 |
+
var h = $next.height();
|
495 |
+
|
496 |
+
// Slide the tick in
|
497 |
+
$tick.stop().animate( {
|
498 |
+
top: h+'px'
|
499 |
+
}, rotate_speed, ease, function() {
|
500 |
+
// Hide the tick
|
501 |
+
$tick.hide();
|
502 |
+
});
|
503 |
+
}
|
504 |
+
</script>
|
505 |
+
<?php // Echo the compressed scripts
|
506 |
+
echo mtphr_dnt_compress_script( ob_get_clean() );
|
507 |
+
}
|
508 |
+
|
509 |
+
/**
|
510 |
+
* Add the rotate slide up scripts
|
511 |
+
*
|
512 |
+
* @since 1.0.2
|
513 |
+
*/
|
514 |
+
function mtphr_dnt_rotate_slide_up_scripts() {
|
515 |
+
ob_start(); ?>
|
516 |
+
<script>
|
517 |
+
|
518 |
+
// Initialize the ticks and ticker
|
519 |
+
function mtphr_dnt_rotator_slide_up_init( $ticker, ticks, rotate_speed, ease ) {
|
520 |
+
|
521 |
+
// Get the first tick
|
522 |
+
$tick = ticks[0];
|
523 |
+
|
524 |
+
// Find the height of the tick
|
525 |
+
var h = $tick.height();
|
526 |
+
|
527 |
+
// Set the height of the ticker
|
528 |
+
$ticker.css( 'height', h+'px' );
|
529 |
+
|
530 |
+
// Set the initial position of the width & make sure it's visible
|
531 |
+
$tick.css( 'top', 0 );
|
532 |
+
$tick.show();
|
533 |
+
|
534 |
+
// If there are any images, reset height after loading
|
535 |
+
if( $tick.find('img').length > 0 ) {
|
536 |
+
|
537 |
+
$tick.find('img').each( function(index) {
|
538 |
+
|
539 |
+
jQuery(this).load( function() {
|
540 |
+
|
541 |
+
// Find the height of the tick
|
542 |
+
var h = $tick.height();
|
543 |
+
|
544 |
+
// Set the height of the ticker
|
545 |
+
$ticker.css( 'height', h+'px' );
|
546 |
+
});
|
547 |
+
});
|
548 |
+
}
|
549 |
+
}
|
550 |
+
|
551 |
+
// Show the new tick
|
552 |
+
function mtphr_dnt_rotator_slide_up_in( $ticker, $tick, $prev, rotate_speed, ease ) {
|
553 |
+
|
554 |
+
// Find the height of the tick
|
555 |
+
var h = $tick.height();
|
556 |
+
|
557 |
+
// Set the initial position of the width & make sure it's visible
|
558 |
+
$tick.css( 'top', $prev.height()+'px' );
|
559 |
+
$tick.show();
|
560 |
+
|
561 |
+
// Resize the ticker
|
562 |
+
$ticker.stop().animate( {
|
563 |
+
height: h+'px'
|
564 |
+
}, rotate_speed, ease, function() {
|
565 |
+
});
|
566 |
+
|
567 |
+
// Slide the tick in
|
568 |
+
$tick.stop().animate( {
|
569 |
+
top: '0'
|
570 |
+
}, rotate_speed, ease, function() {
|
571 |
+
});
|
572 |
+
}
|
573 |
+
|
574 |
+
// Hide the old tick
|
575 |
+
function mtphr_dnt_rotator_slide_up_out( $ticker, $tick, $next, rotate_speed, ease ) {
|
576 |
+
|
577 |
+
// Find the height of the next tick
|
578 |
+
var h = $tick.height();
|
579 |
+
|
580 |
+
// Slide the tick in
|
581 |
+
$tick.stop().animate( {
|
582 |
+
top: '-'+h+'px'
|
583 |
+
}, rotate_speed, ease, function() {
|
584 |
+
// Hide the tick
|
585 |
+
$tick.hide();
|
586 |
+
});
|
587 |
+
}
|
588 |
+
</script>
|
589 |
+
<?php // Echo the compressed scripts
|
590 |
+
echo mtphr_dnt_compress_script( ob_get_clean() );
|
591 |
+
}
|
592 |
+
|
593 |
+
|
594 |
+
|
includes/settings.php
ADDED
@@ -0,0 +1,227 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* The global settings
|
4 |
+
*
|
5 |
+
* @package Ditty News Ticker
|
6 |
+
*/
|
7 |
+
|
8 |
+
|
9 |
+
|
10 |
+
|
11 |
+
add_action( 'admin_menu', 'mtphr_dnt_settings_menu', 9 );
|
12 |
+
/**
|
13 |
+
* Create the settings page
|
14 |
+
*
|
15 |
+
* @since 1.0.0
|
16 |
+
*/
|
17 |
+
function mtphr_dnt_settings_menu() {
|
18 |
+
|
19 |
+
add_submenu_page(
|
20 |
+
'edit.php?post_type=ditty_news_ticker', // The ID of the top-level menu page to which this submenu item belongs
|
21 |
+
__( 'Settings', 'ditty-news-ticker' ), // The value used to populate the browser's title bar when the menu page is active
|
22 |
+
__( 'Settings', 'ditty-news-ticker' ), // The label of this submenu item displayed in the menu
|
23 |
+
'administrator', // What roles are able to access this submenu item
|
24 |
+
'mtphr_dnt_settings', // The ID used to represent this submenu item
|
25 |
+
'mtphr_dnt_settings_display' // The callback function used to render the options for this submenu item
|
26 |
+
);
|
27 |
+
}
|
28 |
+
|
29 |
+
|
30 |
+
|
31 |
+
|
32 |
+
add_action( 'admin_init', 'mtphr_dnt_initialize_settings' );
|
33 |
+
/**
|
34 |
+
* Setup the custom options for the settings page
|
35 |
+
*
|
36 |
+
* @since 1.0.0
|
37 |
+
*/
|
38 |
+
function mtphr_dnt_initialize_settings() {
|
39 |
+
|
40 |
+
/**
|
41 |
+
* General options sections
|
42 |
+
*/
|
43 |
+
$settings = array();
|
44 |
+
|
45 |
+
$settings['css'] = array(
|
46 |
+
'title' => __( 'Custom CSS', 'ditty-news-ticker' ),
|
47 |
+
'type' => 'textarea',
|
48 |
+
'rows' => 20,
|
49 |
+
'description' => __( 'Custom CSS will be added to the head of each page that includes a Ditty News Ticker.', 'ditty-news-ticker' )
|
50 |
+
);
|
51 |
+
if( false == get_option('mtphr_dnt_general_settings') ) {
|
52 |
+
add_option( 'mtphr_dnt_general_settings' );
|
53 |
+
}
|
54 |
+
|
55 |
+
/* Register the general options */
|
56 |
+
add_settings_section(
|
57 |
+
'mtphr_dnt_general_settings_section', // ID used to identify this section and with which to register options
|
58 |
+
__( ' ', 'ditty-news-ticker' ), // Title to be displayed on the administration page
|
59 |
+
false, // Callback used to render the description of the section
|
60 |
+
'mtphr_dnt_general_settings' // Page on which to add this section of options
|
61 |
+
);
|
62 |
+
|
63 |
+
if( is_array($settings) ) {
|
64 |
+
foreach( $settings as $id => $setting ) {
|
65 |
+
$setting['option'] = 'mtphr_dnt_general_settings';
|
66 |
+
$setting['option_id'] = $id;
|
67 |
+
$setting['id'] = 'mtphr_dnt_general_settings['.$id.']';
|
68 |
+
add_settings_field( $setting['id'], $setting['title'], 'mtphr_dnt_settings_callback', 'mtphr_dnt_general_settings', 'mtphr_dnt_general_settings_section', $setting);
|
69 |
+
}
|
70 |
+
}
|
71 |
+
|
72 |
+
// Register the fields with WordPress
|
73 |
+
register_setting( 'mtphr_dnt_general_settings', 'mtphr_dnt_general_settings' );
|
74 |
+
|
75 |
+
/**
|
76 |
+
* License options sections
|
77 |
+
*/
|
78 |
+
$license_settings = array();
|
79 |
+
|
80 |
+
/*
|
81 |
+
$license_settings['test'] = array(
|
82 |
+
'title' => __( 'Test', 'ditty-news-ticker' ),
|
83 |
+
'type' => 'text',
|
84 |
+
'default' => 'sidebar-right'
|
85 |
+
);
|
86 |
+
*/
|
87 |
+
|
88 |
+
if( false == get_option('mtphr_dnt_license_settings') ) {
|
89 |
+
add_option( 'mtphr_dnt_license_settings' );
|
90 |
+
}
|
91 |
+
|
92 |
+
// Register the style options
|
93 |
+
add_settings_section(
|
94 |
+
'mtphr_dnt_license_settings_section', // ID used to identify this section and with which to register options
|
95 |
+
__( ' ', 'ditty-news-ticker' ), // Title to be displayed on the administration page
|
96 |
+
false, // Callback used to render the description of the section
|
97 |
+
'mtphr_dnt_license_settings' // Page on which to add this section of options
|
98 |
+
);
|
99 |
+
|
100 |
+
$license_settings = apply_filters( 'mtphr_dnt_license_settings', $license_settings );
|
101 |
+
|
102 |
+
if( is_array($license_settings) ) {
|
103 |
+
foreach( $license_settings as $id => $setting ) {
|
104 |
+
$setting['option'] = 'mtphr_dnt_license_settings';
|
105 |
+
$setting['option_id'] = $id;
|
106 |
+
$setting['id'] = 'mtphr_dnt_license_settings['.$id.']';
|
107 |
+
add_settings_field( $setting['id'], $setting['title'], 'mtphr_dnt_settings_callback', 'mtphr_dnt_license_settings', 'mtphr_dnt_license_settings_section', $setting);
|
108 |
+
}
|
109 |
+
}
|
110 |
+
|
111 |
+
// Register the fields with WordPress
|
112 |
+
register_setting( 'mtphr_dnt_license_settings', 'mtphr_dnt_license_settings' );
|
113 |
+
|
114 |
+
}
|
115 |
+
|
116 |
+
|
117 |
+
|
118 |
+
|
119 |
+
/**
|
120 |
+
* Render the theme options page
|
121 |
+
*
|
122 |
+
* @since 1.0.0
|
123 |
+
*/
|
124 |
+
function mtphr_dnt_settings_display( $active_tab = null ) {
|
125 |
+
?>
|
126 |
+
<!-- Create a header in the default WordPress 'wrap' container -->
|
127 |
+
<div class="wrap">
|
128 |
+
|
129 |
+
<div id="icon-themes" class="icon32"></div>
|
130 |
+
<h2><?php _e( 'Ditty News Ticker Settings', 'ditty-news-ticker' ); ?></h2>
|
131 |
+
<?php settings_errors(); ?>
|
132 |
+
|
133 |
+
<?php
|
134 |
+
if( isset( $_GET[ 'tab' ] ) ) {
|
135 |
+
$active_tab = $_GET[ 'tab' ];
|
136 |
+
} else if( $active_tab == 'license_settings' ) {
|
137 |
+
$active_tab = 'license_settings';
|
138 |
+
} else {
|
139 |
+
$active_tab = 'general_settings';
|
140 |
+
}
|
141 |
+
?>
|
142 |
+
|
143 |
+
<h2 class="nav-tab-wrapper">
|
144 |
+
<a href="?post_type=ditty_news_ticker&page=mtphr_dnt_settings&tab=general_settings" class="nav-tab <?php echo $active_tab == 'general_settings' ? 'nav-tab-active' : ''; ?>"><?php _e( 'General', 'ditty-news-ticker' ); ?></a>
|
145 |
+
<!-- <a href="?post_type=ditty_news_ticker&page=mtphr_dnt_settings&tab=license_settings" class="nav-tab <?php echo $active_tab == 'license_settings' ? 'nav-tab-active' : ''; ?>"><?php _e( 'Extension Licenses', 'ditty-news-ticker' ); ?></a> -->
|
146 |
+
</h2>
|
147 |
+
|
148 |
+
<form method="post" action="options.php">
|
149 |
+
<?php
|
150 |
+
if( $active_tab == 'license_settings' ) {
|
151 |
+
|
152 |
+
settings_fields( 'mtphr_dnt_license_settings' );
|
153 |
+
do_settings_sections( 'mtphr_dnt_license_settings' );
|
154 |
+
|
155 |
+
} else {
|
156 |
+
|
157 |
+
settings_fields( 'mtphr_dnt_general_settings' );
|
158 |
+
do_settings_sections( 'mtphr_dnt_general_settings' );
|
159 |
+
}
|
160 |
+
|
161 |
+
submit_button();
|
162 |
+
?>
|
163 |
+
</form>
|
164 |
+
|
165 |
+
</div><!-- /.wrap -->
|
166 |
+
<?php
|
167 |
+
}
|
168 |
+
|
169 |
+
|
170 |
+
|
171 |
+
|
172 |
+
/**
|
173 |
+
* General options section callback
|
174 |
+
*
|
175 |
+
* @since 1.0.0
|
176 |
+
*/
|
177 |
+
function mtphr_dnt_general_settings_callback() {
|
178 |
+
echo '<p>'.__( 'Add global settings to your news tickers.', 'ditty-news-ticker' ).'</p>';
|
179 |
+
echo '<p>'.__( 'Use the Custom CSS textarea to set global or individual styles to each of your tickers.', 'ditty-news-ticker' ).'</p>';
|
180 |
+
}
|
181 |
+
|
182 |
+
/**
|
183 |
+
* License options section callback
|
184 |
+
*
|
185 |
+
* @since 1.0.0
|
186 |
+
*/
|
187 |
+
function mtphr_dnt_license_settings_callback() {
|
188 |
+
echo '<p>'.__( 'Add the licenses for each of your extensions.', 'ditty-news-ticker' ).'</p>';
|
189 |
+
}
|
190 |
+
|
191 |
+
|
192 |
+
|
193 |
+
|
194 |
+
/**
|
195 |
+
* The custom field callback.
|
196 |
+
*
|
197 |
+
* @since 1.0.0
|
198 |
+
*/
|
199 |
+
function mtphr_dnt_settings_callback( $args ) {
|
200 |
+
|
201 |
+
// First, we read the options collection
|
202 |
+
if( isset($args['option']) ) {
|
203 |
+
$options = get_option( $args['option'] );
|
204 |
+
$value = isset( $options[$args['option_id']] ) ? $options[$args['option_id']] : '';
|
205 |
+
} else {
|
206 |
+
$value = get_option( $args['id'] );
|
207 |
+
}
|
208 |
+
if( $value == '' && isset($args['default']) ) {
|
209 |
+
$value = $args['default'];
|
210 |
+
}
|
211 |
+
if( isset($args['type']) ) {
|
212 |
+
|
213 |
+
echo '<div class="mtphr-dnt-metaboxer-field mtphr-dnt-metaboxer-'.$args['type'].'">';
|
214 |
+
|
215 |
+
// Call the function to display the field
|
216 |
+
if ( function_exists('mtphr_dnt_metaboxer_'.$args['type']) ) {
|
217 |
+
call_user_func( 'mtphr_dnt_metaboxer_'.$args['type'], $args, $value );
|
218 |
+
}
|
219 |
+
|
220 |
+
echo '<div>';
|
221 |
+
}
|
222 |
+
|
223 |
+
// Add a descriptions
|
224 |
+
if( isset($args['description']) ) {
|
225 |
+
echo '<span class="description"><small>'.$args['description'].'</small></span>';
|
226 |
+
}
|
227 |
+
}
|
includes/shortcodes.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Shortcodes
|
4 |
+
*
|
5 |
+
* @package Ditty News Ticker
|
6 |
+
*/
|
7 |
+
|
8 |
+
|
9 |
+
add_shortcode( 'ditty_news_ticker', 'ditty_news_ticker_display' );
|
10 |
+
/**
|
11 |
+
* Add the news ticker.
|
12 |
+
*
|
13 |
+
* @since 1.0.0
|
14 |
+
*/
|
15 |
+
function ditty_news_ticker_display( $atts, $content = null ) {
|
16 |
+
extract( shortcode_atts( array(
|
17 |
+
'id' => '',
|
18 |
+
'class' => ''
|
19 |
+
), $atts ) );
|
20 |
+
|
21 |
+
// Remove the id & class before passing the atts
|
22 |
+
unset( $atts['id'] );
|
23 |
+
unset( $atts['class'] );
|
24 |
+
|
25 |
+
// Return the ticker
|
26 |
+
return get_mtphr_dnt_ticker( $id, $class, $atts );
|
27 |
+
}
|
28 |
+
|
29 |
+
|
includes/taxonomies.php
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Add custom taxonomies
|
4 |
+
*
|
5 |
+
* @package Ditty News Ticker
|
6 |
+
*/
|
7 |
+
|
8 |
+
|
9 |
+
|
10 |
+
|
11 |
+
add_action( 'init', 'mtphr_dnt_categories', 0 );
|
12 |
+
/**
|
13 |
+
* Create a category taxonomy
|
14 |
+
*
|
15 |
+
* @since 1.0.0
|
16 |
+
*/
|
17 |
+
function mtphr_dnt_categories() {
|
18 |
+
|
19 |
+
// Create labels
|
20 |
+
$labels = array(
|
21 |
+
'name' => __('Categories', 'ditty-news-ticker'),
|
22 |
+
'singular_name' => __('Category', 'ditty-news-ticker'),
|
23 |
+
'search_items' => __('Search Categories', 'ditty-news-ticker'),
|
24 |
+
'all_items' => __('All Categories', 'ditty-news-ticker'),
|
25 |
+
'parent_item' => __('Parent', 'ditty-news-ticker'),
|
26 |
+
'parent_item_colon' => __('Parent:', 'ditty-news-ticker'),
|
27 |
+
'edit_item' => __('Edit Category', 'ditty-news-ticker'),
|
28 |
+
'update_item' => __('Update Category', 'ditty-news-ticker'),
|
29 |
+
'add_new_item' => __('Add New Category', 'ditty-news-ticker'),
|
30 |
+
'new_item_name' => __('New Category', 'ditty-news-ticker'),
|
31 |
+
'menu_name' => __('Categories', 'ditty-news-ticker'),
|
32 |
+
);
|
33 |
+
|
34 |
+
// Create the arguments
|
35 |
+
$args = array(
|
36 |
+
'labels' => $labels
|
37 |
+
);
|
38 |
+
|
39 |
+
// Register the taxonomy
|
40 |
+
register_taxonomy( 'dnt_category', array( 'ditty_news_ticker' ), $args );
|
41 |
+
}
|
42 |
+
|
includes/widget.php
ADDED
@@ -0,0 +1,164 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Create a sidebar widget
|
4 |
+
*
|
5 |
+
* @package Ditty News Ticker
|
6 |
+
*/
|
7 |
+
|
8 |
+
|
9 |
+
|
10 |
+
/* Register the widget - @since 1.0 */
|
11 |
+
add_action( 'widgets_init', 'mtphr_dnt_widget_init' );
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Register the widget
|
15 |
+
*
|
16 |
+
* @since 1.0
|
17 |
+
*/
|
18 |
+
function mtphr_dnt_widget_init() {
|
19 |
+
register_widget( 'mtphr_dnt_widget' );
|
20 |
+
}
|
21 |
+
|
22 |
+
|
23 |
+
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Create a class for the widget
|
27 |
+
*
|
28 |
+
* @since 1.0
|
29 |
+
*/
|
30 |
+
class mtphr_dnt_widget extends WP_Widget {
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Widget setup
|
34 |
+
*
|
35 |
+
* @since 1.0
|
36 |
+
*/
|
37 |
+
function mtphr_dnt_widget() {
|
38 |
+
|
39 |
+
// Widget settings
|
40 |
+
$widget_ops = array(
|
41 |
+
'classname' => 'mtphr-dnt-widget',
|
42 |
+
'description' => __('Displays a Ditty News Ticker.', 'ditty-news-ticker')
|
43 |
+
);
|
44 |
+
|
45 |
+
// Widget control settings
|
46 |
+
$control_ops = array(
|
47 |
+
'id_base' => 'mtphr-dnt-widget'
|
48 |
+
);
|
49 |
+
|
50 |
+
// Create the widget
|
51 |
+
$this->WP_Widget( 'mtphr-dnt-widget', __('Ditty News Ticker', 'ditty-news-ticker'), $widget_ops, $control_ops );
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Display the widget
|
56 |
+
*
|
57 |
+
* @since 1.0
|
58 |
+
*/
|
59 |
+
function widget( $args, $instance ) {
|
60 |
+
|
61 |
+
extract( $args );
|
62 |
+
|
63 |
+
// User-selected settings
|
64 |
+
$title = $instance['title'];
|
65 |
+
$title = apply_filters( 'widget_title', $title );
|
66 |
+
|
67 |
+
$ticker = $instance['ticker'];
|
68 |
+
$ticker_title = isset( $instance['ticker_title'] );
|
69 |
+
|
70 |
+
// Before widget (defined by themes)
|
71 |
+
echo $before_widget;
|
72 |
+
|
73 |
+
// Title of widget (before and after defined by themes)
|
74 |
+
if ( $title ) {
|
75 |
+
echo $before_title . $title . $after_title;
|
76 |
+
}
|
77 |
+
|
78 |
+
// Set custom attributes
|
79 |
+
$atts = array();
|
80 |
+
|
81 |
+
// Set the ticker title visibility
|
82 |
+
$atts['title'] = 0;
|
83 |
+
if( $ticker_title ) {
|
84 |
+
$atts['title'] = 1;
|
85 |
+
}
|
86 |
+
|
87 |
+
// Ad a unique widget ID
|
88 |
+
$atts['unique_id'] = 'widget';
|
89 |
+
|
90 |
+
// Display the ticker
|
91 |
+
if( $ticker != '' ) {
|
92 |
+
ditty_news_ticker( $ticker, '', $atts );
|
93 |
+
}
|
94 |
+
|
95 |
+
// After widget (defined by themes)
|
96 |
+
echo $after_widget;
|
97 |
+
}
|
98 |
+
|
99 |
+
/**
|
100 |
+
* Update the widget
|
101 |
+
*
|
102 |
+
* @since 1.0
|
103 |
+
*/
|
104 |
+
function update( $new_instance, $old_instance ) {
|
105 |
+
|
106 |
+
$instance = $old_instance;
|
107 |
+
|
108 |
+
// Strip tags (if needed) and update the widget settings
|
109 |
+
$instance['title'] = sanitize_text_field( $new_instance['title'] );
|
110 |
+
$instance['ticker'] = $new_instance['ticker'];
|
111 |
+
$instance['ticker_title'] = $new_instance['ticker_title'];
|
112 |
+
|
113 |
+
return $instance;
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* Widget settings
|
118 |
+
*
|
119 |
+
* @since 1.0
|
120 |
+
*/
|
121 |
+
function form( $instance ) {
|
122 |
+
|
123 |
+
// Set up some default widget settings
|
124 |
+
$defaults = array(
|
125 |
+
'title' => '',
|
126 |
+
'ticker' => '',
|
127 |
+
'ticker_title' => ''
|
128 |
+
);
|
129 |
+
|
130 |
+
$instance = wp_parse_args( (array) $instance, $defaults ); ?>
|
131 |
+
|
132 |
+
<!-- Widget Title: Text Input -->
|
133 |
+
<p>
|
134 |
+
<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'ditty-news-ticker' ); ?></label>
|
135 |
+
<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $instance['title']; ?>" style="width:97%;" />
|
136 |
+
</p>
|
137 |
+
|
138 |
+
<!-- Ticker: Select -->
|
139 |
+
<p>
|
140 |
+
<label for="<?php echo $this->get_field_id( 'ticker' ); ?>"><?php _e( 'Select a Ticker:', 'ditty-news-ticker' ); ?></label><br/>
|
141 |
+
<select id="<?php echo $this->get_field_id( 'ticker' ); ?>" name="<?php echo $this->get_field_name( 'ticker' ); ?>">
|
142 |
+
<?php
|
143 |
+
$tickers = get_posts( 'numberposts=0&post_type=ditty_news_ticker&orderby=name&order=ASC' );
|
144 |
+
foreach( $tickers as $ticker ) {
|
145 |
+
if( $instance['ticker'] == $ticker->ID ) {
|
146 |
+
echo '<option value="'.$ticker->ID.'" selected="selected">'.$ticker->post_title.'</option>';
|
147 |
+
} else {
|
148 |
+
echo '<option value="'.$ticker->ID.'">'.$ticker->post_title.'</option>';
|
149 |
+
}
|
150 |
+
}
|
151 |
+
?>
|
152 |
+
</select>
|
153 |
+
</p>
|
154 |
+
|
155 |
+
<!-- Display Ticker Title: Checkbox -->
|
156 |
+
<p>
|
157 |
+
<input class="checkbox" type="checkbox" <?php checked( $instance['ticker_title'], 'on' ); ?> id="<?php echo $this->get_field_id( 'ticker_title' ); ?>" name="<?php echo $this->get_field_name( 'ticker_title' ); ?>" />
|
158 |
+
<label for="<?php echo $this->get_field_id( 'ticker_title' ); ?>"><?php _e( 'Display Ticker Title?', 'ditty-news-ticker' ); ?></label>
|
159 |
+
</p>
|
160 |
+
|
161 |
+
<?php
|
162 |
+
}
|
163 |
+
}
|
164 |
+
|
readme.txt
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== Ditty News Ticker ===
|
2 |
+
Contributors: metaphorcreations
|
3 |
+
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=FUZKZGAJSBAE6
|
4 |
+
Tags: ticker, news, news ticker, rotator, data rotator, lists, data
|
5 |
+
Requires at least: 3.2
|
6 |
+
Tested up to: 3.5.1
|
7 |
+
Stable tag: /trunk/
|
8 |
+
License: GPL2
|
9 |
+
|
10 |
+
Ditty News Ticker is a multi-functional data display plugin.
|
11 |
+
|
12 |
+
== Description ==
|
13 |
+
|
14 |
+
Ditty News Ticker is a multi-functional data display plugin. Easily add custom news tickers to your site either through shortcodes, direct functions, or in a custom Ditty News Ticker Widget.
|
15 |
+
|
16 |
+
#### There are 3 default ticker modes
|
17 |
+
|
18 |
+
* **Scroll Mode** - Scroll the ticker data left, right, up or down
|
19 |
+
* **Rotate Mode** - Rotate through the ticker data
|
20 |
+
* **List Mode** - Display your ticker data in a list
|
21 |
+
|
22 |
+
[**View samples of each mode.**](http://dittynewsticker.com/ticker-modes/)
|
23 |
+
|
24 |
+
#### Extensions
|
25 |
+
Ditty News Ticker is built to easily be extended to add extra Ticker Types and extra Ticker Modes.
|
26 |
+
To see a list of all extensions, visit the [**extensions page**](http://dittynewsticker.com/extensions/).
|
27 |
+
|
28 |
+
== Installation ==
|
29 |
+
|
30 |
+
1. Upload `ditty-news-ticker` directory to the `/wp-content/plugins/` directory
|
31 |
+
2. Activate the plugin through the 'Plugins' menu in WordPress
|
32 |
+
3. Create tickers by going to **News Tickers > Add New**
|
33 |
+
4. Insert your tickers by copying and pasting the provided shortcode into another post.
|
34 |
+
5. Optionally, insert your tickers by copying and pasting the direct function code directly into your theme or plugin.
|
35 |
+
|
36 |
+
== Frequently Asked Questions ==
|
37 |
+
|
38 |
+
= Are there any settings I need to configure? =
|
39 |
+
|
40 |
+
Each individual Ticker post has multiple settings to customize.
|
41 |
+
|
42 |
+
== Screenshots ==
|
43 |
+
|
44 |
+
1. Default Ticker Type options
|
45 |
+
2. Scroll Mode options
|
46 |
+
3. Rotate Mode options
|
47 |
+
4. List Mode options
|
48 |
+
|
49 |
+
== Changelog ==
|
50 |
+
|
51 |
+
= 1.0.2 =
|
52 |
+
* Added 'mtphr_dnt_tick_before' and 'mtphr_dnt_tick_after' actions.
|
53 |
+
* Fixed error in 'rotate_scroll_up' script.
|
54 |
+
* Updated Metabox scripts.
|
55 |
+
|
56 |
+
= 1.0.1 =
|
57 |
+
* Minor code update.
|
58 |
+
|
59 |
+
= 1.0.0 =
|
60 |
+
* Initial upload of Ditty News Ticker - a multi-functional data display plugin.
|
61 |
+
|
62 |
+
== Upgrade Notice ==
|
63 |
+
|
64 |
+
= 1.0.2 =
|
65 |
+
Added additional actions along with some code updates.
|
66 |
+
|
67 |
+
= 1.0.1 =
|
68 |
+
Minor code update.
|
69 |
+
|
70 |
+
= 1.0.0 =
|
71 |
+
Create a multi-functional data display plugin.
|
72 |
+
|