-
Notifications
You must be signed in to change notification settings - Fork 8
/
wpfp-widgets.php
145 lines (131 loc) · 4.88 KB
/
wpfp-widgets.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<?php
// Include Admin Page Framework library.
include( dirname( __FILE__ ) . '/include/library/admin-page-framework/admin-page-framework.php' );
if ( ! class_exists( 'WPFavoritePostsAdminPageFramework_Widget' ) ) {
return;
}
// WP Favorite Posts Widget
class WPFavoritePostsWidget extends WPFavoritePostsAdminPageFramework_Widget {
public function load( $oAdminWidget = null ) {
$this->addSettingFields(
array(
'field_id' => 'title',
'type' => 'text',
'title' => 'Title',
'default' => 'Your Favorite Posts',
),
array(
'field_id' => 'number',
'type' => 'number',
'title' => 'Number',
'description' => 'Number of posts to display.',
'default' => '5',
),
array(
'field_id' => 'thumbnail_show',
'type' => 'checkbox',
'title' => __( 'Show feature image thumbnail?', 'wp-favorite-posts' ),
'label' => __( 'Enable', 'wp-favorite-posts' ),
'description' => __( 'Select this option to show the feature image of a post next to the post\'s title in the favorite list table.', 'wp-favorite-posts' ),
'default' => true,
),
array(
'field_id' => 'thumbnail_alignment',
'type' => 'select',
'title' => __( 'Thumbnail alignment relative to post title', 'wp-favorite-posts' ),
'description' => __( 'Thumbnail alignment uses the default WordPress image CSS classes. Select \'Natural\' to apply no CSS alignment class.', 'wp-favorite-posts' ),
'label' => array(
'left' => __( 'Left', 'wp-favorite-posts' ),
'right' => __( 'Right', 'wp-favorite-posts' ),
'center' => __( 'Center', 'wp-favorite-posts' ),
'none' => __( 'None', 'wp-favorite-posts' ),
'natural' => __( 'Natural', 'wp-favorite-posts' ),
),
'default' => 'none',
),
array(
'field_id' => 'thumbnail_default',
'type' => 'image',
'title' => __( 'Add default image', 'wp-favorite-posts' ),
'description' => __( 'This image displays alongside posts that have no set feature image.', 'wp-favorite-posts' ),
'attributes' => array(
'style' => 'max-width: 150px;',
)
),
array(
'field_id' => 'thumbnail_width',
'type' => 'number',
'title' => __( 'Thumbnail width (pixels)', 'wp-favorite-posts' ),
'description' => __( 'Set a preferred width for the thumbnail.' ),
'label_min_width' => '',
'default' => 50,
'attributes' => array(
'style' => 'width: 60px',
),
),
array(
'field_id' => 'thumbnail_height',
'type' => 'number',
'title' => __( 'Thumbnail height (pixels)', 'wp-favorite-posts' ),
'description' => __( 'Set a preferred height for the thumbnail.' ),
'label_min_width' => '',
'default' => 50,
'attributes' => array(
'style' => 'width: 60px',
),
),
array(
'field_id' => 'clear',
'type' => 'text',
'title' => __( 'Clear all favorites link text', 'wp-favorite-posts' ),
'default' => 'Clear all favorites?',
),
array(
'field_id' => 'cleared',
'type' => 'text',
'title' => __( 'Favorites cleared text', 'wp-favorite-posts' ),
'default' => 'Favorites cleared!',
),
array(
'field_id' => 'favorites_empty',
'type' => 'textarea',
'title' => __( 'Favorites are empty text', 'wp-favorite-posts' ),
'default' => 'There are no favorites to show! Add some.',
'attributes' => array(
'rows' => 6,
'style' => '100%',
),
),
array(
'field_id' => 'cookie_warning',
'type' => 'textarea',
'title' => __( 'Favorites saved to cookies text', 'wp-favorite-posts' ),
'default' => 'Your favorite posts have been saved to your browsers cookies. If you clear cookies your list of favorite posts will be deleted also.',
'attributes' => array(
'rows' => 6,
'style' => '100%',
)
)
);
}
public function content( $sContent, $aArguments, $aFormData ) {
ob_start();
if ( @file_exists(TEMPLATEPATH.'/wpfp-widget-template.php') || @file_exists(STYLESHEETPATH.'/wpfp-widget-template.php') ):
if(@file_exists(TEMPLATEPATH.'/wpfp-widget-template.php')) :
include(TEMPLATEPATH.'/wpfp-widget-template.php');
else :
include(STYLESHEETPATH.'/wpfp-widget-template.php');
endif;
else:
include( realpath(dirname(__FILE__)) . "/templates/wpfp-widget-template.php");
endif;
$list = ob_get_clean();
return $sContent . $list;
}
}
new WPFavoritePostsWidget(
'WP Favorite Posts', // widget title
array(
'description' => 'Shows a visitors favorite posts.',
)
);