0
|
1 |
<?php |
|
2 |
/* |
5
|
3 |
Plugin Name: Portfolio by BestWebSoft |
|
4 |
Plugin URI: http://bestwebsoft.com/products/ |
0
|
5 |
Description: Plugin for portfolio. |
|
6 |
Author: BestWebSoft |
5
|
7 |
Version: 2.33 |
0
|
8 |
Author URI: http://bestwebsoft.com/ |
|
9 |
License: GPLv2 or later |
|
10 |
*/ |
|
11 |
|
5
|
12 |
/* |
|
13 |
@ Copyright 2015 BestWebSoft ( http://support.bestwebsoft.com ) |
0
|
14 |
|
5
|
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. |
0
|
23 |
|
5
|
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 |
global $prtfl_filenames, $prtfl_filepath, $prtfl_themepath; |
|
29 |
$prtfl_filepath = WP_PLUGIN_DIR . '/portfolio/template/'; |
|
30 |
$prtfl_themepath = get_stylesheet_directory() . '/'; |
0
|
31 |
|
5
|
32 |
$prtfl_filenames[] = 'portfolio.php'; |
|
33 |
$prtfl_filenames[] = 'portfolio-post.php'; |
|
34 |
|
0
|
35 |
$prtfl_boxes = array(); |
|
36 |
|
5
|
37 |
/* Function are using to add on admin-panel Wordpress page 'bws_plugins' and sub-page of this plugin */ |
|
38 |
if ( ! function_exists( 'add_prtfl_admin_menu' ) ) { |
|
39 |
function add_prtfl_admin_menu() { |
|
40 |
bws_add_general_menu( plugin_basename( __FILE__ ) ); |
|
41 |
add_submenu_page( 'bws_plugins', __( 'Portfolio', 'portfolio' ), __( 'Portfolio', 'portfolio' ), 'manage_options', "portfolio.php", 'prtfl_settings_page' ); |
0
|
42 |
} |
|
43 |
} |
|
44 |
|
5
|
45 |
if ( ! function_exists ( 'prtfl_init' ) ) { |
|
46 |
function prtfl_init() { |
|
47 |
global $prtfl_boxes, $prtfl_plugin_info; |
|
48 |
/* Internationalization, first(!) */ |
|
49 |
load_plugin_textdomain( 'portfolio', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); |
0
|
50 |
|
5
|
51 |
require_once( dirname( __FILE__ ) . '/bws_menu/bws_functions.php' ); |
|
52 |
|
|
53 |
if ( ! $prtfl_plugin_info ) { |
|
54 |
if ( ! function_exists( 'get_plugin_data' ) ) |
|
55 |
require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
|
56 |
$prtfl_plugin_info = get_plugin_data( __FILE__ ); |
0
|
57 |
} |
5
|
58 |
/* Function check if plugin is compatible with current WP version */ |
|
59 |
bws_wp_version_check( plugin_basename( __FILE__ ), $prtfl_plugin_info, "3.1" ); |
0
|
60 |
|
|
61 |
$prtfl_boxes['Portfolio-Info'] = array( |
|
62 |
array( '_prtfl_short_descr', __( 'Short description', 'portfolio' ), __( 'A short description which you\'d like to be displayed on your portfolio page', 'portfolio' ), '', '' ), |
|
63 |
array( '_prtfl_date_compl', __( 'Date of completion', 'portfolio' ), __( 'The date when the task was completed', 'portfolio' ), '', '' ), |
|
64 |
array( '_prtfl_link', __( 'Link', 'portfolio' ), __( 'A link to the site', 'portfolio' ), '', '' ), |
|
65 |
array( '_prtfl_svn', __( 'SVN', 'portfolio' ), __( 'SVN URL', 'portfolio' ), '', '' ), |
|
66 |
); |
5
|
67 |
/* Call register settings function */ |
|
68 |
register_prtfl_settings(); |
|
69 |
/* Register post type */ |
|
70 |
prtfl_post_type_portfolio(); |
|
71 |
/* Register taxonomy for portfolio */ |
|
72 |
prtfl_taxonomy_portfolio(); |
|
73 |
} |
|
74 |
} |
0
|
75 |
|
5
|
76 |
if ( ! function_exists( 'prtfl_admin_init' ) ) { |
|
77 |
function prtfl_admin_init() { |
|
78 |
global $bws_plugin_info, $prtfl_plugin_info; |
|
79 |
|
|
80 |
if ( ! isset( $bws_plugin_info ) || empty( $bws_plugin_info ) ) |
|
81 |
$bws_plugin_info = array( 'id' => '74', 'version' => $prtfl_plugin_info["Version"] ); |
|
82 |
|
|
83 |
prtfl_admin_error(); |
|
84 |
} |
|
85 |
} |
|
86 |
|
|
87 |
/* Register settings function */ |
|
88 |
if ( ! function_exists( 'register_prtfl_settings' ) ) { |
|
89 |
function register_prtfl_settings() { |
|
90 |
global $prtfl_options, $prtfl_plugin_info; |
|
91 |
|
|
92 |
$prtfl_option_defaults = array( |
|
93 |
'prtfl_custom_size_name' => array( 'portfolio-thumb', 'portfolio-photo-thumb' ), |
|
94 |
'prtfl_custom_size_px' => array( array( 280, 300 ), array( 240, 260 ) ), |
|
95 |
'prtfl_order_by' => 'menu_order', |
|
96 |
'prtfl_order' => 'ASC', |
|
97 |
'prtfl_custom_image_row_count' => 3, |
|
98 |
'prtfl_date_additional_field' => 1, |
|
99 |
'prtfl_link_additional_field' => 1, |
|
100 |
'prtfl_shrdescription_additional_field' => 1, |
|
101 |
'prtfl_description_additional_field' => 1, |
|
102 |
'prtfl_svn_additional_field' => 1, |
|
103 |
'prtfl_executor_additional_field' => 1, |
|
104 |
'prtfl_technologies_additional_field' => 1, |
|
105 |
'prtfl_link_additional_field_for_non_registered' => 1, |
|
106 |
'prtfl_date_text_field' => __( 'Date of completion:', 'portfolio' ), |
|
107 |
'prtfl_link_text_field' => __( 'Link:', 'portfolio' ), |
|
108 |
'prtfl_shrdescription_text_field' => __( 'Short description:', 'portfolio' ), |
|
109 |
'prtfl_description_text_field' => __( 'Description:', 'portfolio' ), |
|
110 |
'prtfl_svn_text_field' => __( 'SVN:', 'portfolio' ), |
|
111 |
'prtfl_executor_text_field' => __( 'Executor Profile:', 'portfolio' ), |
|
112 |
'prtfl_screenshot_text_field' => __( 'More screenshots:', 'portfolio' ), |
|
113 |
'prtfl_technologies_text_field' => __( 'Technologies:', 'portfolio' ), |
|
114 |
'prtfl_slug' => 'portfolio', |
|
115 |
'prtfl_rewrite_template' => 1, |
|
116 |
'prtfl_rename_file' => 0, |
|
117 |
'plugin_option_version' => $prtfl_plugin_info["Version"], |
|
118 |
'widget_updated' => 1 /* this option is for updating plugin was added in v2.29 */ |
|
119 |
); |
|
120 |
|
|
121 |
/* Install the option defaults */ |
|
122 |
if ( ! get_option( 'prtfl_options' ) ) |
|
123 |
add_option( 'prtfl_options', $prtfl_option_defaults ); |
|
124 |
|
|
125 |
/* Get options from the database */ |
|
126 |
$prtfl_options = get_option( 'prtfl_options' ); |
|
127 |
|
|
128 |
if ( isset( $prtfl_options['prtfl_prettyPhoto_style'] ) ) |
|
129 |
unset( $prtfl_options['prtfl_prettyPhoto_style'] ); |
|
130 |
|
|
131 |
/* Array merge incase this version has added new options */ |
|
132 |
if ( ! isset( $prtfl_options['plugin_option_version'] ) || $prtfl_options['plugin_option_version'] != $prtfl_plugin_info["Version"] ) { |
|
133 |
if ( ! isset( $prtfl_options['plugin_option_version'] ) || $prtfl_options['plugin_option_version'] < '2.29' ) |
|
134 |
$prtfl_option_defaults['widget_updated'] = 0; |
|
135 |
|
|
136 |
$prtfl_options = array_merge( $prtfl_option_defaults, $prtfl_options ); |
|
137 |
$prtfl_options['plugin_option_version'] = $prtfl_plugin_info["Version"]; |
|
138 |
update_option( 'prtfl_options', $prtfl_options ); |
|
139 |
/* update templates when updating plugin */ |
|
140 |
prtfl_plugin_install(); |
|
141 |
} |
|
142 |
|
|
143 |
if ( function_exists( 'add_image_size' ) ) { |
|
144 |
add_image_size( 'portfolio-thumb', $prtfl_options['prtfl_custom_size_px'][0][0], $prtfl_options['prtfl_custom_size_px'][0][1], true ); |
|
145 |
add_image_size( 'portfolio-photo-thumb', $prtfl_options['prtfl_custom_size_px'][1][0], $prtfl_options['prtfl_custom_size_px'][1][1], true ); |
|
146 |
} |
|
147 |
} |
|
148 |
} |
|
149 |
|
|
150 |
|
|
151 |
if ( ! function_exists( 'prtfl_plugin_install' ) ) { |
|
152 |
function prtfl_plugin_install() { |
|
153 |
global $prtfl_filenames, $prtfl_filepath, $prtfl_themepath, $prtfl_options; |
|
154 |
|
|
155 |
if ( empty( $prtfl_options ) ) |
|
156 |
register_prtfl_settings(); |
|
157 |
|
|
158 |
foreach ( $prtfl_filenames as $filename ) { |
|
159 |
if ( ! file_exists( $prtfl_themepath . $filename ) ) { |
|
160 |
$handle = @fopen( $prtfl_filepath . $filename, "r" ); |
|
161 |
$contents = @fread( $handle, filesize( $prtfl_filepath . $filename ) ); |
|
162 |
@fclose( $handle ); |
|
163 |
if ( ! ( $handle = @fopen( $prtfl_themepath . $filename, 'w' ) ) ) |
|
164 |
return false; |
|
165 |
@fwrite( $handle, $contents ); |
|
166 |
@fclose( $handle ); |
|
167 |
@chmod( $prtfl_themepath . $filename, octdec( 755 ) ); |
|
168 |
} elseif ( ! isset( $prtfl_options['prtfl_rewrite_template'] ) || 1 == $prtfl_options['prtfl_rewrite_template'] ) { |
|
169 |
$handle = @fopen( $prtfl_themepath . $filename, "r" ); |
|
170 |
$contents = @fread( $handle, filesize( $prtfl_themepath . $filename ) ); |
|
171 |
@fclose( $handle ); |
|
172 |
if ( ! ( $handle = @fopen( $prtfl_themepath . $filename . '.bak', 'w' ) ) ) |
|
173 |
return false; |
|
174 |
@fwrite( $handle, $contents ); |
|
175 |
@fclose( $handle ); |
|
176 |
|
|
177 |
$handle = @fopen( $prtfl_filepath . $filename, "r" ); |
|
178 |
$contents = @fread( $handle, filesize( $prtfl_filepath . $filename ) ); |
|
179 |
@fclose( $handle ); |
|
180 |
if ( ! ( $handle = @fopen( $prtfl_themepath . $filename, 'w' ) ) ) |
|
181 |
return false; |
|
182 |
@fwrite( $handle, $contents ); |
|
183 |
@fclose( $handle ); |
|
184 |
@chmod( $prtfl_themepath . $filename, octdec( 755 ) ); |
|
185 |
} |
|
186 |
} |
|
187 |
} |
|
188 |
} |
|
189 |
|
|
190 |
if ( ! function_exists ( 'prtfl_after_switch_theme' ) ) { |
|
191 |
function prtfl_after_switch_theme() { |
|
192 |
global $prtfl_filenames, $prtfl_themepath; |
|
193 |
$file_exists_flag = true; |
|
194 |
foreach ( $prtfl_filenames as $filename ) { |
|
195 |
if ( ! file_exists( $prtfl_themepath . $filename ) ) |
|
196 |
$file_exists_flag = false; |
|
197 |
} |
|
198 |
if ( ! $file_exists_flag ) |
|
199 |
prtfl_plugin_install(); |
|
200 |
} |
|
201 |
} |
|
202 |
|
|
203 |
if ( ! function_exists( 'prtfl_admin_error' ) ) { |
|
204 |
function prtfl_admin_error() { |
|
205 |
global $prtfl_filenames, $prtfl_filepath, $prtfl_themepath; |
|
206 |
|
|
207 |
$post = isset( $_REQUEST['post'] ) ? $_REQUEST['post'] : "" ; |
|
208 |
$post_type = isset( $_REQUEST['post_type'] ) ? $_REQUEST['post_type'] : "" ; |
|
209 |
$file_exists_flag = true; |
|
210 |
if ( ( 'portfolio' == get_post_type( $post ) || 'portfolio' == $post_type ) || ( isset( $_REQUEST['page'] ) && 'portfolio.php' == $_REQUEST['page'] ) ) { |
|
211 |
foreach ( $prtfl_filenames as $filename ) { |
|
212 |
if ( ! file_exists( $prtfl_themepath . $filename ) ) |
|
213 |
$file_exists_flag = false; |
|
214 |
} |
|
215 |
} |
|
216 |
if ( ! $file_exists_flag ) |
|
217 |
echo '<div class="error"><p><strong>' . __( 'The files "portfolio.php" and "portfolio-post.php" are not found in your theme directory. Please copy them from the directory `wp-content/plugins/portfolio/template/` to your theme directory for correct work of the Portfolio plugin', 'portfolio' ) . '</strong></p></div>'; |
0
|
218 |
} |
|
219 |
} |
|
220 |
|
5
|
221 |
if ( ! function_exists( 'prtfl_settings_page' ) ) { |
|
222 |
function prtfl_settings_page() { |
|
223 |
global $prtfl_options, $wpdb, $wp_version, $prtfl_plugin_info; |
|
224 |
$error = $message = $cstmsrch_options_name = ""; |
|
225 |
$plugin_basename = plugin_basename( __FILE__ ); |
|
226 |
|
|
227 |
if ( false !== get_option( 'cstmsrchpr_options' ) ) |
|
228 |
$cstmsrch_options_name = "cstmsrchpr_options"; |
|
229 |
elseif ( false !== get_option( 'cstmsrch_options' ) ) |
|
230 |
$cstmsrch_options_name = "cstmsrch_options"; |
|
231 |
elseif ( false !== get_option( 'bws_custom_search' ) ) |
|
232 |
$cstmsrch_options_name = "bws_custom_search"; |
|
233 |
|
|
234 |
$all_plugins = get_plugins(); |
|
235 |
if ( isset( $cstmsrch_options_name ) && "" != $cstmsrch_options_name ) |
|
236 |
$cstmsrch_options = get_option( $cstmsrch_options_name ); |
|
237 |
|
|
238 |
/* Save data for settings page */ |
|
239 |
if ( isset( $_REQUEST['prtfl_form_submit'] ) && check_admin_referer( $plugin_basename, 'prtfl_nonce_name' ) ) { |
|
240 |
$prtfl_request_options = array(); |
|
241 |
$prtfl_request_options["prtfl_custom_size_name"] = $prtfl_options["prtfl_custom_size_name"]; |
|
242 |
|
|
243 |
$prtfl_request_options["prtfl_custom_size_px"] = array( |
|
244 |
array( intval( trim( $_REQUEST['prtfl_custom_image_size_w_album'] ) ), intval( trim( $_REQUEST['prtfl_custom_image_size_h_album'] ) ) ), |
|
245 |
array( intval( trim( $_REQUEST['prtfl_custom_image_size_w_photo'] ) ), intval( trim( $_REQUEST['prtfl_custom_image_size_h_photo'] ) ) ) |
|
246 |
); |
|
247 |
$prtfl_request_options["prtfl_custom_image_row_count"] = intval( $_REQUEST['prtfl_custom_image_row_count'] ); |
|
248 |
if ( "" == $prtfl_request_options["prtfl_custom_image_row_count"] || 1 > $prtfl_request_options["prtfl_custom_image_row_count"] ) |
|
249 |
$prtfl_request_options["prtfl_custom_image_row_count"] = 1; |
|
250 |
|
|
251 |
$prtfl_request_options["prtfl_order_by"] = $_REQUEST['prtfl_order_by']; |
|
252 |
$prtfl_request_options["prtfl_order"] = $_REQUEST['prtfl_order']; |
|
253 |
|
|
254 |
$prtfl_request_options["prtfl_date_additional_field"] = isset( $_REQUEST["prtfl_date_additional_field"] ) ? $_REQUEST["prtfl_date_additional_field"] : 0; |
|
255 |
$prtfl_request_options["prtfl_link_additional_field"] = isset( $_REQUEST["prtfl_link_additional_field"] ) ? $_REQUEST["prtfl_link_additional_field"] : 0; |
|
256 |
$prtfl_request_options["prtfl_shrdescription_additional_field"] = isset( $_REQUEST["prtfl_shrdescription_additional_field"] ) ? $_REQUEST["prtfl_shrdescription_additional_field"] : 0; |
|
257 |
$prtfl_request_options["prtfl_description_additional_field"] = isset( $_REQUEST["prtfl_description_additional_field"] ) ? $_REQUEST["prtfl_description_additional_field"] : 0; |
|
258 |
$prtfl_request_options["prtfl_svn_additional_field"] = isset( $_REQUEST["prtfl_svn_additional_field"] ) ? $_REQUEST["prtfl_svn_additional_field"] : 0; |
|
259 |
$prtfl_request_options["prtfl_executor_additional_field"] = isset( $_REQUEST["prtfl_executor_additional_field"] ) ? $_REQUEST["prtfl_executor_additional_field"] : 0; |
|
260 |
$prtfl_request_options["prtfl_technologies_additional_field"] = isset( $_REQUEST["prtfl_technologies_additional_field"] ) ? $_REQUEST["prtfl_technologies_additional_field"] : 0; |
|
261 |
|
|
262 |
$prtfl_request_options["prtfl_link_additional_field_for_non_registered"] = isset( $_REQUEST["prtfl_link_additional_field_for_non_registered"] ) ? $_REQUEST["prtfl_link_additional_field_for_non_registered"] : 0; |
|
263 |
|
|
264 |
$prtfl_request_options["prtfl_date_text_field"] = stripslashes( esc_html( $_REQUEST["prtfl_date_text_field"] ) ); |
|
265 |
$prtfl_request_options["prtfl_link_text_field"] = stripslashes( esc_html( $_REQUEST["prtfl_link_text_field"] ) ); |
|
266 |
$prtfl_request_options["prtfl_shrdescription_text_field"] = stripslashes( esc_html( $_REQUEST["prtfl_shrdescription_text_field"] ) ); |
|
267 |
$prtfl_request_options["prtfl_description_text_field"] = stripslashes( esc_html( $_REQUEST["prtfl_description_text_field"] ) ); |
|
268 |
$prtfl_request_options["prtfl_svn_text_field"] = stripslashes( esc_html( $_REQUEST["prtfl_svn_text_field"] ) ); |
|
269 |
$prtfl_request_options["prtfl_executor_text_field"] = stripslashes( esc_html( $_REQUEST["prtfl_executor_text_field"] ) ); |
|
270 |
$prtfl_request_options["prtfl_screenshot_text_field"] = stripslashes( esc_html( $_REQUEST["prtfl_screenshot_text_field"] ) ); |
|
271 |
$prtfl_request_options["prtfl_technologies_text_field"] = stripslashes( esc_html( $_REQUEST["prtfl_technologies_text_field"] ) ); |
|
272 |
|
|
273 |
$prtfl_request_options["prtfl_slug"] = trim( $_REQUEST['prtfl_slug'] ); |
|
274 |
$prtfl_request_options["prtfl_slug"] = strtolower( $prtfl_request_options["prtfl_slug"] ); |
|
275 |
$prtfl_request_options["prtfl_slug"] = preg_replace( "/[^a-z0-9\s-]/", "", $prtfl_request_options["prtfl_slug"] ); |
|
276 |
$prtfl_request_options["prtfl_slug"] = trim( preg_replace( "/[\s-]+/", " ", $prtfl_request_options["prtfl_slug"] ) ); |
|
277 |
$prtfl_request_options["prtfl_slug"] = preg_replace( "/\s/", "-", $prtfl_request_options["prtfl_slug"] ); |
|
278 |
|
|
279 |
$prtfl_request_options["prtfl_rewrite_template"] = isset( $_REQUEST["prtfl_rewrite_template"] ) ? 1 : 0; |
|
280 |
$prtfl_request_options["prtfl_rename_file"] = isset( $_REQUEST["prtfl_rename_file"] ) ? 1 : 0; |
|
281 |
|
|
282 |
if ( isset( $_REQUEST['prtfl_add_to_search'] ) && "" != $cstmsrch_options_name ) { |
|
283 |
if ( false !== get_option( $cstmsrch_options_name ) ) { |
|
284 |
$cstmsrch_options = get_option( $cstmsrch_options_name ); |
|
285 |
if ( ! in_array( 'portfolio', $cstmsrch_options ) ) { |
|
286 |
array_push( $cstmsrch_options, 'portfolio' ); |
|
287 |
update_option( $cstmsrch_options_name, $cstmsrch_options ); |
|
288 |
} |
|
289 |
} |
|
290 |
} else { |
|
291 |
if ( false !== get_option( $cstmsrch_options_name ) ) { |
|
292 |
$cstmsrch_options = get_option( $cstmsrch_options_name ); |
|
293 |
if ( in_array( 'portfolio', $cstmsrch_options ) ) { |
|
294 |
$key = array_search( 'portfolio', $cstmsrch_options ); |
|
295 |
unset( $cstmsrch_options[ $key ] ); |
|
296 |
update_option( $cstmsrch_options_name, $cstmsrch_options ); |
|
297 |
} |
|
298 |
} |
|
299 |
} |
|
300 |
|
|
301 |
/* For revrite prtfl_slug */ |
|
302 |
global $wp_rewrite; |
|
303 |
$rules = get_option( 'rewrite_rules' ); |
|
304 |
prtfl_custom_permalinks( $rules ); |
|
305 |
$wp_rewrite->flush_rules(); |
|
306 |
|
|
307 |
/* Array merge incase this version has added new options */ |
|
308 |
$prtfl_options = array_merge( $prtfl_options, $prtfl_request_options ); |
|
309 |
|
|
310 |
/* Check select one point in the blocks Arithmetic actions and Difficulty on settings page */ |
|
311 |
update_option( 'prtfl_options', $prtfl_options ); |
|
312 |
$message = __( "Settings saved.", 'portfolio' ); |
|
313 |
|
|
314 |
} |
|
315 |
/* GO PRO */ |
|
316 |
if ( isset( $_GET['action'] ) && 'go_pro' == $_GET['action'] ) { |
|
317 |
$go_pro_result = bws_go_pro_tab_check( $plugin_basename ); |
|
318 |
if ( ! empty( $go_pro_result['error'] ) ) |
|
319 |
$error = $go_pro_result['error']; |
|
320 |
} |
|
321 |
/* Display form on the setting page */ ?> |
|
322 |
<div class="wrap"> |
|
323 |
<div class="icon32 icon32-bws" id="icon-options-general"></div> |
|
324 |
<h2><?php _e( 'Portfolio Settings', 'portfolio' ); ?></h2> |
|
325 |
<h2 class="nav-tab-wrapper"> |
|
326 |
<a class="nav-tab<?php echo ! isset( $_GET['action'] ) ? ' nav-tab-active': ''; ?>" href="admin.php?page=portfolio.php"><?php _e( 'Settings', 'portfolio' ); ?></a> |
|
327 |
<a class="nav-tab" href="http://bestwebsoft.com/products/portfolio/faq/" target="_blank"><?php _e( 'FAQ', 'portfolio' ); ?></a> |
|
328 |
<a class="nav-tab bws_go_pro_tab<?php if ( isset( $_GET['action'] ) && 'go_pro' == $_GET['action'] ) echo ' nav-tab-active'; ?>" href="admin.php?page=portfolio.php&action=go_pro"><?php _e( 'Go PRO', 'portfolio' ); ?></a> |
|
329 |
</h2> |
|
330 |
<div class="updated fade" <?php if ( ! isset( $_REQUEST['prtfl_form_submit'] ) || "" != $error ) echo 'style="display:none"'; ?>><p><strong><?php echo $message; ?></strong></p></div> |
|
331 |
<div class="error" <?php if ( "" == $error ) echo 'style="display:none"'; ?>><p><strong><?php echo $error; ?></strong></p></div> |
|
332 |
<div id="prtfl_settings_notice" class="updated fade" style="display:none"><p><strong><?php _e( "Notice:", 'portfolio' ); ?></strong> <?php _e( "The plugin's settings have been changed. In order to save them please don't forget to click the 'Save Changes' button.", 'portfolio' ); ?></p></div> |
|
333 |
<?php if ( ! ( isset( $_GET['action'] ) && 'go_pro' == $_GET['action'] ) ) { ?> |
|
334 |
<p><?php _e( "If you would like to add the Latest Portfolio Items to your page or post, just copy and paste this shortcode into your post or page:", 'portfolio' ); ?> [latest_portfolio_items count=3], <?php _e( 'where count=3 is a number of posts to show up in the portfolio.', 'portfolio' ); ?></p> |
|
335 |
<?php $prefix = ( '1' == get_option( 'prtfl_tag_update' ) ) ? '_prtfl' : '_prtf'; |
|
336 |
if ( NULL != $wpdb->get_var( "SELECT `meta_id` FROM `" . $wpdb->postmeta . "` WHERE `meta_key` = '" . $prefix . "_short_descr' LIMIT 1" ) ) { ?> |
|
337 |
<table class="form-table"> |
|
338 |
<tr valign="top"> |
|
339 |
<th scope="row"><?php _e( 'Change the way to store your post_meta information for portfolio', 'portfolio' ); ?> </th> |
|
340 |
<td style="position:relative"> |
|
341 |
<input type="button" value="<?php _e( 'Update All Info', 'portfolio' ); ?>" id="ajax_update_postmeta" name="ajax_update_postmeta" class="button" onclick="javascript:update_postmeta();"> <div id="prtfl_loader"><img src="<?php echo plugins_url( 'images/ajax-loader.gif', __FILE__ ); ?>" alt="loader" /></div> |
|
342 |
</td> |
|
343 |
</tr> |
|
344 |
</table> |
|
345 |
<?php } ?> |
|
346 |
<table class="form-table"> |
|
347 |
<tr valign="top"> |
|
348 |
<th scope="row"><?php _e( 'Update images for portfolio', 'portfolio' ); ?> </th> |
|
349 |
<td style="position:relative"> |
|
350 |
<input type="button" value="<?php _e( 'Update images', 'portfolio' ); ?>" id="ajax_update_images" name="ajax_update_images" class="button" onclick="javascript:update_images();"> <div id="prtfl_img_loader"><img src="<?php echo plugins_url( 'images/ajax-loader.gif', __FILE__ ); ?>" alt="loader" /></div> |
|
351 |
</td> |
|
352 |
</tr> |
|
353 |
<tr valign="top"> |
|
354 |
</tr> |
|
355 |
</table> |
|
356 |
<br /> |
|
357 |
<form method="post" action="admin.php?page=portfolio.php" id="prtfl_form_image_size"> |
|
358 |
<table class="form-table"> |
|
359 |
<tr valign="top"> |
|
360 |
<th scope="row"><?php _e( 'Image size for the album cover', 'portfolio' ); ?> </th> |
|
361 |
<td> |
|
362 |
<label><?php _e( 'Image size name', 'portfolio' ); ?></label> <?php echo $prtfl_options["prtfl_custom_size_name"][0]; ?><br /> |
|
363 |
<label><?php _e( 'Width (in px)', 'portfolio' ); ?></label> <input type="text" name="prtfl_custom_image_size_w_album" value="<?php echo $prtfl_options["prtfl_custom_size_px"][0][0]; ?>" /><br /> |
|
364 |
<label><?php _e( 'Height (in px)', 'portfolio' ); ?></label> <input type="text" name="prtfl_custom_image_size_h_album" value="<?php echo $prtfl_options["prtfl_custom_size_px"][0][1]; ?>" /> |
|
365 |
</td> |
|
366 |
</tr> |
|
367 |
<tr valign="top"> |
|
368 |
<th scope="row"><?php _e( 'Image size for thumbnails', 'portfolio' ); ?> </th> |
|
369 |
<td> |
|
370 |
<label><?php _e( 'Image size name', 'portfolio' ); ?></label> <?php echo $prtfl_options["prtfl_custom_size_name"][1]; ?><br /> |
|
371 |
<label><?php _e( 'Width (in px)', 'portfolio' ); ?></label> <input type="text" name="prtfl_custom_image_size_w_photo" value="<?php echo $prtfl_options["prtfl_custom_size_px"][1][0]; ?>" /><br /> |
|
372 |
<label><?php _e( 'Height (in px)', 'portfolio' ); ?></label> <input type="text" name="prtfl_custom_image_size_h_photo" value="<?php echo $prtfl_options["prtfl_custom_size_px"][1][1]; ?>" /> |
|
373 |
</td> |
|
374 |
</tr> |
|
375 |
<tr valign="top"> |
|
376 |
<td colspan="2"><span style="color: #888888;font-size: 10px;"><?php _e( 'WordPress will copy thumbnails with the specified dimensions when you upload a new image. It is necessary to click the Update images button at the top of this page in order to generate new images and set new dimensions', 'portfolio' ); ?></span></th> |
|
377 |
</tr> |
|
378 |
<tr valign="top"> |
|
379 |
<th scope="row"><?php _e( 'Sort portfolio by', 'portfolio' ); ?> </th> |
|
380 |
<td> |
|
381 |
<label class="label_radio"><input type="radio" name="prtfl_order_by" value="ID" <?php if ( 'ID' == $prtfl_options["prtfl_order_by"] ) echo 'checked="checked"'; ?> /> <?php _e( 'portfolio id', 'portfolio' ); ?></label><br /> |
|
382 |
<label class="label_radio"><input type="radio" name="prtfl_order_by" value="title" <?php if ( 'title' == $prtfl_options["prtfl_order_by"] ) echo 'checked="checked"'; ?> /> <?php _e( 'portfolio title', 'portfolio' ); ?></label><br /> |
|
383 |
<label class="label_radio"><input type="radio" name="prtfl_order_by" value="date" <?php if ( 'date' == $prtfl_options["prtfl_order_by"] ) echo 'checked="checked"'; ?> /> <?php _e( 'date', 'portfolio' ); ?></label><br /> |
|
384 |
<label class="label_radio"><input type="radio" name="prtfl_order_by" value="menu_order" <?php if ( 'menu_order' == $prtfl_options["prtfl_order_by"] ) echo 'checked="checked"'; ?> /> <?php _e( 'menu order', 'portfolio' ); ?></label><br /> |
|
385 |
<label class="label_radio"><input type="radio" name="prtfl_order_by" value="rand" <?php if ( 'rand' == $prtfl_options["prtfl_order_by"] ) echo 'checked="checked"'; ?> /> <?php _e( 'random', 'portfolio' ); ?></label> |
|
386 |
</td> |
|
387 |
</tr> |
|
388 |
<tr valign="top"> |
|
389 |
<th scope="row"><?php _e( 'Portfolio sorting', 'portfolio' ); ?> </th> |
|
390 |
<td> |
|
391 |
<label class="label_radio" style="width: auto;"><input type="radio" name="prtfl_order" value="ASC" <?php if ( 'ASC' == $prtfl_options["prtfl_order"] ) echo 'checked="checked"'; ?> /> <?php _e( 'ASC (ascending order from lowest to highest values - 1, 2, 3; a, b, c)', 'portfolio' ); ?></label><br /> |
|
392 |
<label class="label_radio" style="width: auto;"><input type="radio" name="prtfl_order" value="DESC" <?php if ( 'DESC' == $prtfl_options["prtfl_order"] ) echo 'checked="checked"'; ?> /> <?php _e( 'DESC (descending order from highest to lowest values - 3, 2, 1; c, b, a)', 'portfolio' ); ?></label> |
|
393 |
</td> |
|
394 |
</tr> |
|
395 |
<tr valign="top"> |
|
396 |
<th scope="row"><?php _e( 'Number of images in the row', 'portfolio' ); ?> </th> |
|
397 |
<td> |
|
398 |
<input type="text" name="prtfl_custom_image_row_count" value="<?php echo $prtfl_options["prtfl_custom_image_row_count"]; ?>" /> |
|
399 |
</td> |
|
400 |
</tr> |
|
401 |
<tr valign="top"> |
|
402 |
<th scope="row"><?php _e( 'Display additional fields', 'portfolio' ); ?> </th> |
|
403 |
<td> |
|
404 |
<input type="checkbox" name="prtfl_date_additional_field" value="1" id="prtfl_date_additional_field" <?php if ( 1 == $prtfl_options['prtfl_date_additional_field'] ) echo 'checked="checked"'; ?> /> <label for="prtfl_date_additional_field" style="float:none;"><?php _e( 'Date', 'portfolio' ); ?></label> |
|
405 |
<input type="checkbox" name="prtfl_link_additional_field" value="1" id="prtfl_link_additional_field" <?php if ( 1 == $prtfl_options['prtfl_link_additional_field'] ) echo 'checked="checked"'; ?> /> <label for="prtfl_link_additional_field" style="float:none;"><?php _e( 'Link', 'portfolio' ); ?></label> |
|
406 |
<input type="checkbox" name="prtfl_shrdescription_additional_field" value="1" id="prtfl_shrdescription_additional_field" <?php if ( 1 == $prtfl_options['prtfl_shrdescription_additional_field'] ) echo 'checked="checked"'; ?> /> <label for="prtfl_shrdescription_additional_field" style="float:none;"><?php _e( 'Short Description', 'portfolio' ); ?></label> |
|
407 |
<input type="checkbox" name="prtfl_description_additional_field" value="1" id="prtfl_description_additional_field" <?php if ( 1 == $prtfl_options['prtfl_description_additional_field'] ) echo 'checked="checked"'; ?> /> <label for="prtfl_description_additional_field" style="float:none;"><?php _e( 'Description', 'portfolio' ); ?></label> |
|
408 |
<input type="checkbox" name="prtfl_svn_additional_field" value="1" id="prtfl_svn_additional_field" <?php if ( 1 == $prtfl_options['prtfl_svn_additional_field'] ) echo 'checked="checked"'; ?> /> <label for="prtfl_svn_additional_field" style="float:none;"><?php _e( 'SVN', 'portfolio' ); ?></label> |
|
409 |
<input type="checkbox" name="prtfl_executor_additional_field" value="1" id="prtfl_executor_additional_field" <?php if ( 1 == $prtfl_options['prtfl_executor_additional_field'] ) echo 'checked="checked"'; ?> /> <label for="prtfl_executor_additional_field" style="float:none;"><?php _e( 'Executor', 'portfolio' ); ?></label> |
|
410 |
<input type="checkbox" name="prtfl_technologies_additional_field" value="1" id="prtfl_technologies_additional_field" <?php if ( 1 == $prtfl_options['prtfl_technologies_additional_field'] ) echo 'checked="checked"'; ?> /> <label for="prtfl_technologies_additional_field" style="float:none;"><?php _e( 'Technologies', 'portfolio' ); ?></label> |
|
411 |
</td> |
|
412 |
</tr> |
|
413 |
</table> |
|
414 |
<div class="bws_pro_version_bloc"> |
|
415 |
<div class="bws_pro_version_table_bloc"> |
|
416 |
<div class="bws_table_bg"></div> |
|
417 |
<table class="form-table bws_pro_version"> |
|
418 |
<tr valign="top"> |
|
419 |
<th scope="row"><?php _e( 'Display additional fields', 'portfolio' ); ?> </th> |
|
420 |
<td width="350"> |
|
421 |
<label><input type="checkbox" name="prtflpr_categories_additional_field" value="1" style="margin-left: -11px;" disabled="disabled" /> <?php _e( 'Categories', 'portfolio' ); ?></label> |
|
422 |
</td> |
|
423 |
</tr> |
|
424 |
<tr valign="top"> |
|
425 |
<th scope="row"><?php _e( 'Hide "More screenshots" block', 'portfolio' ); ?></th> |
|
426 |
<td width="350"> |
|
427 |
<input type="checkbox" name="prtflpr_disbable_screenshot_block" value="1" style="margin-left: -11px;" disabled="disabled" /> |
|
428 |
</td> |
|
429 |
</tr> |
|
430 |
<tr valign="top"> |
|
431 |
<th scope="row" colspan="2"> |
|
432 |
* <?php _e( 'If you upgrade to Pro version all your settings and portfolios will be saved.', 'portfolio' ); ?> |
|
433 |
</th> |
|
434 |
</tr> |
|
435 |
</table> |
|
436 |
</div> |
|
437 |
<div class="bws_pro_version_tooltip"> |
|
438 |
<div class="bws_info"> |
|
439 |
<?php _e( 'Unlock premium options by upgrading to a PRO version.', 'portfolio' ); ?> |
|
440 |
<a href="http://bestwebsoft.com/products/portfolio/?k=f047e20c92c972c398187a4f70240285&pn=74&v=<?php echo $prtfl_plugin_info["Version"]; ?>&wp_v=<?php echo $wp_version; ?>" target="_blank" title="Portfolio Pro"><?php _e( 'Learn More', 'portfolio' ); ?></a> |
|
441 |
</div> |
|
442 |
<a class="bws_button" href="http://bestwebsoft.com/products/portfolio/buy/?k=f047e20c92c972c398187a4f70240285&pn=74&v=<?php echo $prtfl_plugin_info["Version"]; ?>&wp_v=<?php echo $wp_version; ?>" target="_blank" title="Portfolio Pro"> |
|
443 |
<?php _e( 'Go', 'portfolio' ); ?> <strong>PRO</strong> |
|
444 |
</a> |
|
445 |
<div class="clear"></div> |
|
446 |
</div> |
|
447 |
</div> |
|
448 |
<table class="form-table"> |
|
449 |
<tr valign="top"> |
|
450 |
<th scope="row"><?php _e( 'Display the link field as a text for non-registered users', 'portfolio' ); ?></th> |
|
451 |
<td> |
|
452 |
<input type="checkbox" name="prtfl_link_additional_field_for_non_registered" value="1" id="prtfl_link_additional_field_for_non_registered" <?php if ( 1 == $prtfl_options['prtfl_link_additional_field_for_non_registered'] ) echo 'checked="checked"'; ?> /> |
|
453 |
</td> |
|
454 |
</tr> |
|
455 |
<tr valign="top"> |
|
456 |
<th scope="row"><?php _e( 'Text for additional fields', 'portfolio' ); ?> </th> |
|
457 |
<td> |
|
458 |
<label><?php _e( 'Date of completion:', 'portfolio' ); ?></label> <input type="text" name="prtfl_date_text_field" value="<?php echo $prtfl_options["prtfl_date_text_field"]; ?>" /><br /> |
|
459 |
<label><?php _e( 'Link:', 'portfolio' ); ?></label> <input type="text" name="prtfl_link_text_field" value="<?php echo $prtfl_options["prtfl_link_text_field"]; ?>" /><br /> |
|
460 |
<label><?php _e( 'Short description:', 'portfolio' ); ?></label> <input type="text" name="prtfl_shrdescription_text_field" value="<?php echo $prtfl_options["prtfl_shrdescription_text_field"]; ?>" /><br /> |
|
461 |
<label><?php _e( 'Description:', 'portfolio' ); ?></label> <input type="text" name="prtfl_description_text_field" value="<?php echo $prtfl_options["prtfl_description_text_field"]; ?>" /><br /> |
|
462 |
<label><?php _e( 'SVN:', 'portfolio' ); ?></label> <input type="text" name="prtfl_svn_text_field" value="<?php echo $prtfl_options["prtfl_svn_text_field"]; ?>" /><br /> |
|
463 |
<label><?php _e( 'Executor Profile:', 'portfolio' ); ?></label> <input type="text" name="prtfl_executor_text_field" value="<?php echo $prtfl_options["prtfl_executor_text_field"]; ?>" /><br /> |
|
464 |
<label><?php _e( 'More screenshots:', 'portfolio' ); ?></label> <input type="text" name="prtfl_screenshot_text_field" value="<?php echo $prtfl_options["prtfl_screenshot_text_field"]; ?>" /><br /> |
|
465 |
<label><?php _e( 'Technologies:', 'portfolio' ); ?></label> <input type="text" name="prtfl_technologies_text_field" value="<?php echo $prtfl_options["prtfl_technologies_text_field"]; ?>" /> |
|
466 |
</td> |
|
467 |
</tr> |
|
468 |
<tr valign="top"> |
|
469 |
<th scope="row"><?php _e( 'Slug for portfolio item', 'portfolio' ); ?></th> |
|
470 |
<td> |
|
471 |
<input type="text" name="prtfl_slug" value="<?php echo $prtfl_options["prtfl_slug"]; ?>" /> <span style="color: #888888;font-size: 10px;"><?php _e( 'for any structure of permalinks except the default structure', 'portfolio' ); ?></span> |
|
472 |
</td> |
|
473 |
</tr> |
|
474 |
<tr valign="top"> |
|
475 |
<th scope="row"><?php _e( 'Rewrite templates after update', 'portfolio' ); ?></th> |
|
476 |
<td> |
|
477 |
<input type="checkbox" name="prtfl_rewrite_template" value="1" <?php if ( 1 == $prtfl_options['prtfl_rewrite_template'] ) echo 'checked="checked"'; ?> /> <span style="color: #888888;font-size: 10px;"><?php _e( "Turn off the checkbox, if You edited the file 'portfolio.php' or 'portfolio-post.php' file in your theme folder and You don't want to rewrite them", 'portfolio' ); ?></span> |
|
478 |
</td> |
|
479 |
</tr> |
|
480 |
<tr valign="top"> |
|
481 |
<th scope="row"><?php _e( 'Rename uploaded images', 'portfolio' ); ?></th> |
|
482 |
<td> |
|
483 |
<input type="checkbox" name="prtfl_rename_file" value="1" <?php if ( 1 == $prtfl_options['prtfl_rename_file'] ) echo 'checked="checked"'; ?> /> <span style="color: #888888;font-size: 10px;"><?php _e( "To avoid conflicts, all the symbols will be excluded, except numbers, the Roman letters, _ and - symbols.", 'portfolio' ); ?></span> |
|
484 |
</td> |
|
485 |
</tr> |
|
486 |
<tr valign="top"> |
|
487 |
<th scope="row"><?php _e( 'Add portfolio to the search', 'portfolio' ); ?></th> |
|
488 |
<td> |
|
489 |
<?php if ( array_key_exists( 'custom-search-plugin/custom-search-plugin.php', $all_plugins ) || array_key_exists( 'custom-search-pro/custom-search-pro.php', $all_plugins ) ) { |
|
490 |
if ( is_plugin_active( 'custom-search-plugin/custom-search-plugin.php' ) || is_plugin_active( 'custom-search-pro/custom-search-pro.php' ) ) { ?> |
|
491 |
<input type="checkbox" name="prtfl_add_to_search" value="1" <?php if ( isset( $cstmsrch_options ) && in_array( 'portfolio', $cstmsrch_options ) ) echo 'checked="checked"'; ?> /> |
|
492 |
<span style="color: #888888;font-size: 10px;"> (<?php _e( 'Using Custom Search powered by', 'portfolio' ); ?> <a href="http://bestwebsoft.com/products/">bestwebsoft.com</a>)</span> |
|
493 |
<?php } else { ?> |
|
494 |
<input disabled="disabled" type="checkbox" name="prtfl_add_to_search" value="1" <?php if ( isset( $cstmsrch_options ) && in_array( 'portfolio', $cstmsrch_options ) ) echo 'checked="checked"'; ?> /> |
|
495 |
<span style="color: #888888;font-size: 10px;">(<?php _e( 'Using Custom Search powered by', 'portfolio' ); ?> <a href="http://bestwebsoft.com/products/">bestwebsoft.com</a>) <a href="<?php echo bloginfo("url"); ?>/wp-admin/plugins.php"><?php _e( 'Activate Custom Search', 'portfolio' ); ?></a></span> |
|
496 |
<?php } |
|
497 |
} else { ?> |
|
498 |
<input disabled="disabled" type="checkbox" name="prtfl_add_to_search" value="1" /> |
|
499 |
<span style="color: #888888;font-size: 10px;">(<?php _e( 'Using Custom Search powered by', 'portfolio' ); ?> <a href="http://bestwebsoft.com/products/">bestwebsoft.com</a>) <a href="http://bestwebsoft.com/products/custom-search/"><?php _e( 'Download Custom Search', 'portfolio' ); ?></a></span> |
|
500 |
<?php } ?> |
|
501 |
</td> |
|
502 |
</tr> |
|
503 |
</table> |
|
504 |
<input type="hidden" name="prtfl_form_submit" value="submit" /> |
|
505 |
<p class="submit"> |
|
506 |
<input type="submit" class="button-primary" value="<?php _e( 'Save Changes' ); ?>" /> |
|
507 |
</p> |
|
508 |
<?php wp_nonce_field( plugin_basename( __FILE__ ), 'prtfl_nonce_name' ); ?> |
|
509 |
</form> |
|
510 |
<?php bws_plugin_reviews_block( $prtfl_plugin_info['Name'], 'portfolio' ); |
|
511 |
} elseif ( 'go_pro' == $_GET['action'] ) { |
|
512 |
bws_go_pro_tab( $prtfl_plugin_info, $plugin_basename, 'portfolio.php', 'portfolio-pro.php', 'portfolio-pro/portfolio-pro.php', 'portfolio', 'f047e20c92c972c398187a4f70240285', '74', isset( $go_pro_result['pro_plugin_is_activated'] ) ); |
|
513 |
} ?> |
|
514 |
</div> |
|
515 |
<?php } |
|
516 |
} |
|
517 |
|
|
518 |
/* Create post type for portfolio */ |
0
|
519 |
if ( ! function_exists( 'prtfl_post_type_portfolio' ) ) { |
|
520 |
function prtfl_post_type_portfolio() { |
5
|
521 |
global $wpdb, $prtfl_options; |
|
522 |
|
|
523 |
$slug = isset( $prtfl_options['prtfl_slug'] ) && ! empty( $prtfl_options['prtfl_slug'] ) ? $prtfl_options['prtfl_slug'] : 'portfolio'; |
|
524 |
register_post_type( |
0
|
525 |
'portfolio', |
5
|
526 |
array( |
0
|
527 |
'labels' => array( |
5
|
528 |
'name' => __( 'Portfolio', 'portfolio' ), |
|
529 |
'singular_name' => __( 'Portfolio', 'portfolio' ), |
|
530 |
'add_new' => __( 'Add New', 'portfolio' ), |
|
531 |
'add_new_item' => __( 'Add New Portfolio', 'portfolio' ), |
|
532 |
'edit' => __( 'Edit', 'portfolio' ), |
|
533 |
'edit_item' => __( 'Edit Portfolio', 'portfolio' ), |
|
534 |
'new_item' => __( 'New Portfolio', 'portfolio' ), |
|
535 |
'view' => __( 'View Portfolio', 'portfolio' ), |
|
536 |
'view_item' => __( 'View Portfolio', 'portfolio' ), |
|
537 |
'search_items' => __( 'Search Portfolio', 'portfolio' ), |
|
538 |
'not_found' => __( 'No portfolio found', 'portfolio' ), |
|
539 |
'not_found_in_trash' => __( 'No portfolio found in Trash', 'portfolio' ), |
|
540 |
'parent' => __( 'Parent Portfolio', 'portfolio' ), |
0
|
541 |
), |
5
|
542 |
'description' => __( 'Create a portfolio item', 'portfolio' ), |
|
543 |
'public' => true, |
|
544 |
'show_ui' => true, |
|
545 |
'publicly_queryable' => true, |
|
546 |
'exclude_from_search' => true, |
|
547 |
'hierarchical' => true, |
|
548 |
'query_var' => true, |
|
549 |
'register_meta_box_cb' => 'prtfl_init_metaboxes', |
|
550 |
'rewrite' => array( 'slug' => $slug ), |
|
551 |
'supports' => array( |
|
552 |
'title', /* Text input field to create a post title. */ |
0
|
553 |
'editor', |
|
554 |
'custom-fields', |
5
|
555 |
'comments', /* Ability to turn on/off comments. */ |
|
556 |
'thumbnail', /* Displays a box for featured image. */ |
|
557 |
'author', |
|
558 |
'page-attributes' |
0
|
559 |
) |
|
560 |
) |
|
561 |
); |
|
562 |
} |
|
563 |
} |
|
564 |
|
5
|
565 |
/* Create taxonomy for portfolio - Technologies and Executors Profile */ |
0
|
566 |
if ( ! function_exists( 'prtfl_taxonomy_portfolio' ) ) { |
5
|
567 |
function prtfl_taxonomy_portfolio() { |
0
|
568 |
register_taxonomy( |
|
569 |
'portfolio_executor_profile', |
|
570 |
'portfolio', |
|
571 |
array( |
5
|
572 |
'hierarchical' => false, |
|
573 |
'update_count_callback' => '_update_post_term_count', |
|
574 |
'labels' => array( |
|
575 |
'name' => __( 'Executor Profiles', 'portfolio' ), |
|
576 |
'singular_name' => __( 'Executor Profile', 'portfolio' ), |
|
577 |
'search_items' => __( 'Search Executor Profiles', 'portfolio' ), |
|
578 |
'popular_items' => __( 'Popular Executor Profiles', 'portfolio' ), |
|
579 |
'all_items' => __( 'All Executor Profiles', 'portfolio' ), |
|
580 |
'parent_item' => __( 'Parent Executor Profile', 'portfolio' ), |
|
581 |
'parent_item_colon' => __( 'Parent Executor Profile:', 'portfolio' ), |
|
582 |
'edit_item' => __( 'Edit Executor Profile', 'portfolio' ), |
|
583 |
'update_item' => __( 'Update Executor Profile', 'portfolio' ), |
|
584 |
'add_new_item' => __( 'Add New Executor Profile', 'portfolio' ), |
|
585 |
'new_item_name' => __( 'New Executor Name', 'portfolio' ), |
|
586 |
'separate_items_with_commas' => __( 'Separate Executor Profiles with commas', 'portfolio' ), |
|
587 |
'add_or_remove_items' => __( 'Add or remove Executor Profile', 'portfolio' ), |
|
588 |
'choose_from_most_used' => __( 'Choose from the most used Executor Profiles', 'portfolio' ), |
|
589 |
'menu_name' => __( 'Executors', 'portfolio' ) |
0
|
590 |
), |
5
|
591 |
'sort' => true, |
|
592 |
'args' => array( 'orderby' => 'term_order' ), |
|
593 |
'rewrite' => array( 'slug' => 'executor_profile' ), |
|
594 |
'show_tagcloud' => false |
0
|
595 |
) |
|
596 |
); |
|
597 |
|
5
|
598 |
register_taxonomy( |
|
599 |
'portfolio_technologies', |
|
600 |
'portfolio', |
0
|
601 |
array( |
5
|
602 |
'hierarchical' => false, |
|
603 |
'update_count_callback' => '_update_post_term_count', |
|
604 |
'labels' => array( |
|
605 |
'name' => __( 'Technologies', 'portfolio' ), |
|
606 |
'singular_name' => __( 'Technology', 'portfolio'), |
|
607 |
'search_items' => __( 'Search Technologies', 'portfolio' ), |
|
608 |
'popular_items' => __( 'Popular Technologies', 'portfolio' ), |
|
609 |
'all_items' => __( 'All Technologies', 'portfolio' ), |
|
610 |
'parent_item' => __( 'Parent Technology', 'portfolio' ), |
|
611 |
'parent_item_colon' => __( 'Parent Technology:', 'portfolio' ), |
|
612 |
'edit_item' => __( 'Edit Technology', 'portfolio' ), |
|
613 |
'update_item' => __( 'Update Technology', 'portfolio' ), |
|
614 |
'add_new_item' => __( 'Add New Technology', 'portfolio' ), |
|
615 |
'new_item_name' => __( 'New Technology Name', 'portfolio' ), |
|
616 |
'separate_items_with_commas' => __( 'Separate Technologies with commas', 'portfolio' ), |
|
617 |
'add_or_remove_items' => __( 'Add or remove Technology', 'portfolio' ), |
|
618 |
'choose_from_most_used' => __( 'Choose from the most used technologies', 'portfolio' ), |
|
619 |
'menu_name' => __( 'Technologies', 'portfolio' ) |
0
|
620 |
), |
5
|
621 |
'query_var' => 'technologies', |
|
622 |
'rewrite' => array( 'slug' => 'technologies' ), |
|
623 |
'public' => true, |
|
624 |
'show_ui' => true, |
|
625 |
'_builtin' => true, |
|
626 |
'show_tagcloud' => false |
|
627 |
) |
0
|
628 |
); |
|
629 |
} |
|
630 |
} |
|
631 |
|
5
|
632 |
/* add query_var "post_type" in case we have another custom post type with query_var 'portfolio' (example: jetpack portfolio) */ |
|
633 |
if ( ! function_exists( 'prtfl_request_filter' ) ) { |
|
634 |
function prtfl_request_filter( $query_vars ) { |
|
635 |
if ( isset( $query_vars["post_type"] ) && $query_vars["post_type"] == 'jetpack-portfolio' ) { |
|
636 |
if ( ! get_posts( $query_vars ) ) |
|
637 |
$query_vars["post_type"] = 'portfolio'; |
|
638 |
} |
|
639 |
return $query_vars; |
|
640 |
} |
|
641 |
} |
|
642 |
|
0
|
643 |
if ( ! function_exists( 'prtfl_technologies_get_posts' ) ) { |
|
644 |
function prtfl_technologies_get_posts( $query ) { |
5
|
645 |
if ( ( isset( $query->query_vars["technologies"] ) || isset( $query->query_vars["portfolio_executor_profile"] ) ) && ( ! is_admin() ) ) |
0
|
646 |
$query->set( 'post_type', array( 'portfolio' ) ); |
|
647 |
return $query; |
|
648 |
} |
|
649 |
} |
|
650 |
|
5
|
651 |
/** |
|
652 |
* Class extends WP class WP_Widget, and create new widget |
|
653 |
*/ |
|
654 |
if ( ! class_exists( 'portfolio_technologies_widget' ) ) { |
|
655 |
class portfolio_technologies_widget extends WP_Widget { |
|
656 |
/* constructor of class */ |
|
657 |
function __construct() { |
|
658 |
parent::__construct( |
|
659 |
'portfolio_technologies_widget', |
|
660 |
__( 'Technologies', 'portfolio' ), |
|
661 |
array( 'description' => __( 'Your most used portfolio technologies as a tag cloud', 'portfolio' ) ) |
|
662 |
); |
|
663 |
} |
|
664 |
/* Function to displaying widget in front end */ |
|
665 |
function widget( $args, $instance ) { |
|
666 |
$widget_title = isset( $instance['widget_title'] ) ? $instance['widget_title'] : null; |
|
667 |
$widget_title = apply_filters( 'widget_title', $widget_title, '', 'portfolio_technologies_widget' ); |
|
668 |
echo $args['before_widget']; |
|
669 |
if ( $widget_title ) |
|
670 |
echo $args['before_title'] . $widget_title . $args['after_title']; |
|
671 |
echo '<div class="tagcloud">'; |
|
672 |
wp_tag_cloud( apply_filters( 'widget_tag_cloud_args', array( 'taxonomy' => 'portfolio_technologies', 'number' => 0 ) ) ); |
|
673 |
echo "</div>\n"; |
|
674 |
echo $args['after_widget']; |
|
675 |
} |
|
676 |
/* Function to save widget settings */ |
|
677 |
function update( $new_instance, $old_instance ) { |
|
678 |
$instance = array(); |
|
679 |
$instance['widget_title'] = ( ! empty( $new_instance['widget_title'] ) ) ? strip_tags( $new_instance['widget_title'] ) : null; |
|
680 |
return $instance; |
|
681 |
} |
|
682 |
/* Function to displaying widget settings in back end */ |
|
683 |
function form( $instance ) { |
|
684 |
$widget_title = isset( $instance['widget_title'] ) ? stripslashes( esc_html( $instance['widget_title'] ) ) : null; ?> |
|
685 |
<p> |
|
686 |
<label for="<?php echo $this->get_field_id( 'widget_title' ); ?>"><?php _e( 'Title', 'portfolio' ); ?>:</label> |
|
687 |
<input class="widefat" id="<?php echo $this->get_field_id( 'widget_title' ); ?>" name="<?php echo $this->get_field_name( 'widget_title' ); ?>" type="text" value="<?php echo esc_attr( $widget_title ); ?>"/> |
|
688 |
</p> |
|
689 |
<?php } |
0
|
690 |
} |
|
691 |
} |
5
|
692 |
if ( ! function_exists( 'prtfl_register_widget' ) ) { |
|
693 |
function prtfl_register_widget() { |
|
694 |
register_widget( 'portfolio_technologies_widget' ); |
0
|
695 |
} |
|
696 |
} |
|
697 |
|
5
|
698 |
/* Create custom permalinks for portfolio post type */ |
|
699 |
if ( ! function_exists( 'prtfl_custom_permalinks' ) ) { |
|
700 |
function prtfl_custom_permalinks( $rules ) { |
|
701 |
$newrules = array(); |
|
702 |
$newrules['portfolio/page/([^/]+)/?$'] = 'index.php?pagename=portfolio&paged=$matches[1]'; |
|
703 |
$newrules['portfolio/page/([^/]+)?$'] = 'index.php?pagename=portfolio&paged=$matches[1]'; |
|
704 |
/* return $newrules + $rules; */ |
|
705 |
if ( $rules ) |
|
706 |
return array_merge( $newrules, $rules ); |
0
|
707 |
} |
|
708 |
} |
|
709 |
|
5
|
710 |
/* flush_rules() if our rules are not yet included */ |
0
|
711 |
if ( ! function_exists( 'prtfl_flush_rules' ) ) { |
5
|
712 |
function prtfl_flush_rules() { |
0
|
713 |
$rules = get_option( 'rewrite_rules' ); |
|
714 |
if ( ! isset( $rules['portfolio/page/([^/]+)/?$'] ) ) { |
|
715 |
global $wp_rewrite; |
|
716 |
$wp_rewrite->flush_rules(); |
|
717 |
} |
|
718 |
} |
|
719 |
} |
|
720 |
|
5
|
721 |
/* Initialization of all metaboxes on the 'Add Portfolio' and Edit Portfolio pages */ |
0
|
722 |
if ( ! function_exists( 'prtfl_init_metaboxes' ) ) { |
|
723 |
function prtfl_init_metaboxes() { |
5
|
724 |
add_meta_box( 'Portfolio-Info', __( 'Portfolio Info', 'portfolio' ), 'prtfl_post_custom_box', 'portfolio', 'normal', 'high' ); /* Description metaboxe */ |
|
725 |
add_meta_box( 'prtfl_categories_meta_box', __( 'Categories', 'portfolio' ), 'prtfl_categories_meta_box', 'portfolio', 'side', 'low' ); |
|
726 |
if ( ! ( function_exists( 'rttchr_metabox_content_in_post' ) || function_exists( 'rttchrpr_metabox_content_in_post' ) ) ) { |
|
727 |
add_meta_box( 'prtfl_rttchr_metabox_ad', __( 'Already attached', 'portfolio' ), 'prtfl_rttchr_attach_box', 'portfolio', 'side', 'low' ); |
|
728 |
} |
|
729 |
|
0
|
730 |
} |
|
731 |
} |
|
732 |
|
5
|
733 |
/* Create custom meta box for portfolio post type */ |
0
|
734 |
if ( ! function_exists( 'prtfl_post_custom_box' ) ) { |
|
735 |
function prtfl_post_custom_box( $obj = '', $box = '' ) { |
|
736 |
global $prtfl_boxes; |
5
|
737 |
/* Generate box contents */ |
|
738 |
foreach ( $prtfl_boxes[ $box[ 'id' ] ] as $prtfl_box ) { |
0
|
739 |
echo prtfl_text_field( $prtfl_box ); |
|
740 |
} |
|
741 |
} |
|
742 |
} |
|
743 |
|
5
|
744 |
/* Create custom meta box for re-attacher ad in portfolio */ |
|
745 |
if ( ! function_exists( 'prtfl_rttchr_attach_box' ) ) { |
|
746 |
function prtfl_rttchr_attach_box() { |
|
747 |
global $prtfl_plugin_info, $wp_version; |
|
748 |
|
|
749 |
if ( ! function_exists( 'get_plugins' ) ) |
|
750 |
require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
|
751 |
$all_plugins = get_plugins(); |
|
752 |
if ( isset( $all_plugins['re-attacher/re-attacher.php'] ) || isset( $all_plugins['re-attacher-pro/re-attacher-pro.php'] ) ) { |
|
753 |
/* if re-attacher is installed */ |
|
754 |
$link = "plugins.php"; |
|
755 |
$text = __( 'Activate', 'portfolio' ); |
|
756 |
} else { |
|
757 |
if ( function_exists( 'is_multisite' ) ) |
|
758 |
$link = ( ! is_multisite() ) ? admin_url( '/' ) : network_admin_url( '/' ); |
|
759 |
else |
|
760 |
$link = admin_url( '/' ); |
|
761 |
$link = $link . 'plugin-install.php?tab=search&type=term&s=Re-attacher+BestWebSoft&plugin-search-input=Search+Plugins'; |
|
762 |
$text = __( 'Install now', 'portfolio' ); |
|
763 |
} ?> |
|
764 |
<p> |
|
765 |
<?php _e( "If you'd like to attach the files, which are already uploaded, please use Re-attacher plugin.", 'portfolio' ) ; |
|
766 |
if ( 3.5 > $wp_version ) { ?> |
|
767 |
<br /> |
|
768 |
<strong> |
|
769 |
<?php echo '($nbsp;' . __( 'Requires at least', 'portfolio' ) . ' WordPress 3.5 )'; ?> |
|
770 |
</strong> |
|
771 |
<?php } ?> |
|
772 |
</p> |
|
773 |
<p> |
|
774 |
<a target="_blank" class="button-secondary" href="http://bestwebsoft.com/products/re-attacher/?k=a9c95424ed55d41fd762ce8aad52a519&pn=74&v=<?php echo $prtfl_plugin_info["Version"] . '&wp_v=' . $wp_version ?>" style="margin:0px 5px 2px;"><?php _e( 'Learn more', 'portfolio' ); ?></a> |
|
775 |
<a class="button-primary" href="<?php echo $link; ?>" target="_blank" style="margin-right: 5px;"><?php echo $text; ?></a> |
|
776 |
</p> |
|
777 |
<?php } |
|
778 |
} |
|
779 |
|
|
780 |
/** |
|
781 |
* Banner on Portfolio Edit Page |
|
782 |
*/ |
|
783 |
if ( ! function_exists( 'prtfl_categories_meta_box' ) ) { |
|
784 |
function prtfl_categories_meta_box() { |
|
785 |
global $prtfl_plugin_info, $wp_version; ?> |
|
786 |
<div class="bws_pro_version_bloc"> |
|
787 |
<div class="bws_pro_version_table_bloc"> |
|
788 |
<div class="bws_table_bg" style="top: 0px;"></div> |
|
789 |
<div class="prtfl_portfolio_categoriesdiv"> |
|
790 |
<div class="inside"> |
|
791 |
<div class=""> |
|
792 |
<ul class="category-tabs"> |
|
793 |
<li class="tabs"><a href="#"><?php _e( 'All Categories', 'portfolio' ); ?></a></li> |
|
794 |
<li><a href="#"><?php _e( 'Most Used', 'portfolio' ); ?></a></li> |
|
795 |
</ul> |
|
796 |
<div class="tabs-panel" style="display: none;"> |
|
797 |
<ul class="categorychecklist form-no-clear"> |
|
798 |
<li class="popular-category"> |
|
799 |
<label class="selectit"><input checked="checked" disabled="disabled" value="236" type="checkbox" /><?php _e( 'Uncatgorized', 'portfolio' ); ?></label> |
|
800 |
</li> |
|
801 |
</ul> |
|
802 |
</div> |
|
803 |
<div class="tabs-panel"> |
|
804 |
<ul class="categorychecklist form-no-clear"> |
|
805 |
<li class="popular-category"><label class="selectit"><input value="236" name="tax_input[portfolio_categories][]" checked="checked" disabled="disabled" type="checkbox" /> <?php _e( 'Uncatgorized', 'portfolio' ); ?></label></li> |
|
806 |
</ul> |
|
807 |
</div> |
|
808 |
<div class="wp-hidden-children"> |
|
809 |
<h4><a href="#">+ <?php _e( 'Add New Category', 'portfolio' ); ?></a></h4> |
|
810 |
<p class="category-add wp-hidden-child"> |
|
811 |
<label class="screen-reader-text"><?php _e( 'Add New Category', 'portfolio' ); ?></label> |
|
812 |
<input name="newportfolio_categories" class="form-required form-input-tip" value="<?php _e( 'New Category Name', 'portfolio' ); ?>" type="text" disabled="disabled" /><label class="screen-reader-text"><?php _e( 'Parent Category', 'portfolio' ); ?>:</label> |
|
813 |
<select name="newportfolio_categories_parent" class="postform"> |
|
814 |
<option value="-1">— <?php _e( 'Parent Category', 'portfolio' ); ?> —</option> |
|
815 |
<option class="level-0" value="236"><?php _e( 'Uncatgorized', 'portfolio' ); ?></option> |
|
816 |
</select> |
|
817 |
<input class="button category-add-submit" value="<?php _e( 'Add New Category', 'portfolio' ); ?>" type="button" disabled="disabled" /> |
|
818 |
</p> |
|
819 |
</div> |
|
820 |
</div> |
|
821 |
</div> |
|
822 |
</div> |
|
823 |
<div class="bws_pro_version_tooltip"> |
|
824 |
<div class="bws_info"> |
|
825 |
<?php _e( 'Unlock premium options by upgrading to a PRO version.', 'portfolio' ); ?> |
|
826 |
<a href="http://bestwebsoft.com/products/portfolio/?k=f047e20c92c972c398187a4f70240285&pn=74&v=<?php echo $prtfl_plugin_info["Version"]; ?>&wp_v=<?php echo $wp_version; ?>" target="_blank" title="Portfolio Pro Plugin"><?php _e( 'Learn More', 'portfolio' ); ?></a> |
|
827 |
</div> |
|
828 |
<div class="bws_pro_links"> |
|
829 |
<a class="bws_button" href="http://bestwebsoft.com/products/portfolio/buy/?k=f047e20c92c972c398187a4f70240285&pn=74&v=<?php echo $prtfl_plugin_info["Version"]; ?>&wp_v=<?php echo $wp_version; ?>" target="_blank" title="Portfolio Pro Plugin"> |
|
830 |
<?php _e( 'Go', 'portfolio' ); ?> <strong>PRO</strong> |
|
831 |
</a> |
|
832 |
</div> |
|
833 |
<div class="clear"></div> |
|
834 |
</div> |
|
835 |
</div> |
|
836 |
</div> |
|
837 |
<?php } |
|
838 |
} |
|
839 |
|
|
840 |
/* This is the default text field meta box */ |
0
|
841 |
if ( ! function_exists( 'prtfl_text_field' ) ) { |
|
842 |
function prtfl_text_field( $args ) { |
|
843 |
global $post; |
5
|
844 |
$description = $args[2]; |
|
845 |
if ( '1' == get_option( 'prtfl_postmeta_update' ) ) { |
0
|
846 |
$post_meta = get_post_meta( $post->ID, 'prtfl_information', true); |
5
|
847 |
$args[2] = is_array( $post_meta ) ? esc_html( $post_meta[ $args[0] ] ) : "" ; |
0
|
848 |
} else { |
5
|
849 |
$args[2] = esc_html( get_post_meta( $post->ID, $args[0], true ) ); |
0
|
850 |
} |
|
851 |
$label_format = |
5
|
852 |
'<div class="portfolio_admin_box">' . |
|
853 |
'<p><label for="%1$s"><strong>%2$s</strong></label></p>' . |
|
854 |
'<p><input style="width: 80%%;" type="text" name="%1$s" id="%1$s" value="%3$s" /></p>' . |
|
855 |
'<p><em>' . $description .'</em></p>' . |
0
|
856 |
'</div>'; |
5
|
857 |
if ( '_prtfl_date_compl' == $args[0] ) |
0
|
858 |
echo '<script type="text/javascript">jQuery(document).ready(function(){jQuery("#_prtfl_date_compl").simpleDatepicker({ startdate: new Date().getFullYear()-3, enddate: new Date().getFullYear()+3 });});</script>'; |
|
859 |
return vsprintf( $label_format, $args ); |
|
860 |
} |
|
861 |
} |
|
862 |
|
|
863 |
/* When the post is saved, saves our custom data */ |
|
864 |
if ( ! function_exists ( 'prtfl_save_postdata' ) ) { |
|
865 |
function prtfl_save_postdata( $post_id, $post ) { |
|
866 |
global $prtfl_boxes; |
|
867 |
|
5
|
868 |
register_prtfl_settings(); |
|
869 |
|
|
870 |
if ( "portfolio" == $post->post_type && ! wp_is_post_revision( $post_id ) && ! empty( $_POST ) ) { /* Don't store custom data twice */ |
|
871 |
/* Verify this came from the our screen and with proper authorization, because save_post can be triggered at other times */ |
|
872 |
if ( ! current_user_can ( 'edit_page', $post->ID ) ) { |
0
|
873 |
return $post->ID; |
|
874 |
} |
|
875 |
|
5
|
876 |
/* We'll put it into an array to make it easier to loop though. The data is already in $prtfl_boxes, but we need to flatten it out. */ |
|
877 |
foreach ( $prtfl_boxes as $prtfl_boxe ) { |
|
878 |
foreach ( $prtfl_boxe as $prtfl_fields ) { |
|
879 |
if ( $prtfl_fields[0] == '_prtfl_link' || $prtfl_fields[0] == '_prtfl_svn' ) |
|
880 |
$my_data[ $prtfl_fields[0] ] = esc_url( $_POST[ $prtfl_fields[0] ] ); |
|
881 |
else |
|
882 |
$my_data[ $prtfl_fields[0] ] = stripslashes( esc_html( $_POST[ $prtfl_fields[0] ] ) ); |
0
|
883 |
} |
5
|
884 |
} |
|
885 |
/* Add values of $my_data as custom fields. Let's cycle through the $my_data array! */ |
|
886 |
if ( get_post_meta( $post->ID, 'prtfl_information', FALSE ) ) { |
|
887 |
/* Custom field has a value and this custom field exists in database */ |
|
888 |
update_post_meta( $post->ID, 'prtfl_information', $my_data ); |
|
889 |
} elseif ( $value ) { |
|
890 |
/* Custom field has a value, but this custom field does not exist in database */ |
|
891 |
add_post_meta( $post->ID, 'prtfl_information', $my_data ); |
0
|
892 |
} else { |
5
|
893 |
/* Custom field does not have a value, but this custom field exists in database */ |
|
894 |
update_post_meta( $post->ID, 'prtfl_information', $my_data ); |
0
|
895 |
} |
|
896 |
} |
|
897 |
} |
|
898 |
} |
|
899 |
|
5
|
900 |
/** |
|
901 |
* Replace shortcode [latest_portfolio_items] from portfolio content before portfolio saving |
|
902 |
*/ |
|
903 |
if ( ! function_exists ( 'prtfl_content_save_pre' ) ) { |
|
904 |
function prtfl_content_save_pre( $content ) { |
|
905 |
global $post; |
|
906 |
if ( isset( $post ) && "portfolio" == $post->post_type && ! wp_is_post_revision( $post->ID ) && ! empty( $_POST ) ) { |
|
907 |
/* remove shortcode */ |
|
908 |
$content = preg_replace( '/\[latest_portfolio_items count=[\d]*\]/', '', $content ); |
0
|
909 |
} |
5
|
910 |
return $content; |
0
|
911 |
} |
|
912 |
} |
|
913 |
|
|
914 |
if ( ! function_exists ( 'prtfl_register_plugin_links' ) ) { |
|
915 |
function prtfl_register_plugin_links( $links, $file ) { |
|
916 |
$base = plugin_basename(__FILE__); |
|
917 |
if ( $file == $base ) { |
5
|
918 |
if ( ! is_network_admin() ) |
|
919 |
$links[] = '<a href="admin.php?page=portfolio.php">' . __( 'Settings', 'portfolio' ) . '</a>'; |
|
920 |
$links[] = '<a href="http://wordpress.org/plugins/portfolio/faq/" target="_blank">' . __( 'FAQ', 'portfolio' ) . '</a>'; |
|
921 |
$links[] = '<a href="http://support.bestwebsoft.com">' . __( 'Support', 'portfolio' ) . '</a>'; |
|
922 |
} |
|
923 |
return $links; |
|
924 |
} |
|
925 |
} |
|
926 |
|
|
927 |
if ( ! function_exists ( 'prtfl_plugin_action_links' ) ) { |
|
928 |
function prtfl_plugin_action_links( $links, $file ) { |
|
929 |
if ( ! is_network_admin() ) { |
|
930 |
/* Static so we don't call plugin_basename on every plugin row. */ |
|
931 |
static $this_plugin; |
|
932 |
if ( ! $this_plugin ) $this_plugin = plugin_basename( __FILE__ ); |
|
933 |
|
|
934 |
if ( $file == $this_plugin ) { |
|
935 |
$settings_link = '<a href="admin.php?page=portfolio.php">' . __( 'Settings', 'portfolio' ) . '</a>'; |
|
936 |
array_unshift( $links, $settings_link ); |
|
937 |
} |
0
|
938 |
} |
|
939 |
return $links; |
|
940 |
} |
|
941 |
} |
|
942 |
|
5
|
943 |
|
|
944 |
if ( ! function_exists( 'prtfl_template_redirect' ) ) { |
|
945 |
function prtfl_template_redirect() { |
|
946 |
global $wp_query, $post, $posts, $prtfl_filenames, $prtfl_themepath; |
|
947 |
if ( 'portfolio' == get_post_type() && "" == $wp_query->query_vars["s"] && ! isset( $wp_query->query_vars["technologies"] ) && ! isset( $wp_query->query_vars["portfolio_executor_profile"] ) ) { |
|
948 |
$file_exists_flag = true; |
|
949 |
foreach ( $prtfl_filenames as $filename ) { |
|
950 |
if ( ! file_exists( $prtfl_themepath . $filename ) ) |
|
951 |
$file_exists_flag = false; |
0
|
952 |
} |
5
|
953 |
if ( $file_exists_flag ) { |
|
954 |
include( get_stylesheet_directory() . '/portfolio-post.php' ); |
|
955 |
exit(); |
0
|
956 |
} |
5
|
957 |
} elseif ( 'portfolio' == get_post_type() && ( isset( $wp_query->query_vars["technologies"] ) || isset( $wp_query->query_vars["portfolio_executor_profile"] ) ) ) { |
|
958 |
$file_exists_flag = true; |
|
959 |
foreach ( $prtfl_filenames as $filename ) { |
|
960 |
if ( ! file_exists( $prtfl_themepath . $filename ) ) |
|
961 |
$file_exists_flag = false; |
|
962 |
} |
|
963 |
if ( $file_exists_flag ) { |
|
964 |
include( get_stylesheet_directory() . '/portfolio.php' ); |
|
965 |
exit(); |
|
966 |
} |
0
|
967 |
} |
|
968 |
} |
|
969 |
} |
|
970 |
|
|
971 |
if ( ! function_exists( 'prtfl_add_portfolio_ancestor_to_menu' ) ) { |
5
|
972 |
function prtfl_add_portfolio_ancestor_to_menu( $classes, $item ) { |
0
|
973 |
if ( is_singular( 'portfolio' ) ) { |
|
974 |
global $wpdb, $post; |
5
|
975 |
$parent = $wpdb->get_var( "SELECT $wpdb->posts.post_name FROM $wpdb->posts, $wpdb->postmeta WHERE meta_key = '_wp_page_template' AND meta_value = 'portfolio.php' AND (post_status = 'publish' OR post_status = 'private') AND $wpdb->posts.ID = $wpdb->postmeta.post_id" ); |
|
976 |
|
|
977 |
if ( in_array( 'menu-item-' . $item->ID, $classes ) && $parent == strtolower( $item->title ) ) |
0
|
978 |
$classes[] = 'current-page-ancestor'; |
|
979 |
} |
|
980 |
return $classes; |
|
981 |
} |
|
982 |
} |
|
983 |
|
|
984 |
if ( ! function_exists( 'prtfl_latest_items' ) ) { |
|
985 |
function prtfl_latest_items( $atts ) { |
5
|
986 |
$content = '<div class="prtfl_portfolio_block">'; |
|
987 |
if ( empty( $atts['count'] ) ) |
|
988 |
$atts['count'] = 3; |
|
989 |
$args = array( |
|
990 |
'post_type' => 'portfolio', |
|
991 |
'post_status' => 'publish', |
|
992 |
'orderby' => 'date', |
|
993 |
'order' => 'DESC', |
|
994 |
'posts_per_page' => $atts['count'], |
0
|
995 |
); |
|
996 |
query_posts( $args ); |
5
|
997 |
|
|
998 |
while ( have_posts() ) : the_post(); |
0
|
999 |
$content .= ' |
|
1000 |
<div class="portfolio_content"> |
|
1001 |
<div class="entry">'; |
|
1002 |
global $post; |
5
|
1003 |
$meta_values = get_post_custom($post->ID); |
|
1004 |
$post_thumbnail_id = get_post_thumbnail_id( $post->ID ); |
0
|
1005 |
if( empty ( $post_thumbnail_id ) ) { |
|
1006 |
$args = array( |
5
|
1007 |
'post_parent' => $post->ID, |
|
1008 |
'post_type' => 'attachment', |
|
1009 |
'post_mime_type' => 'image', |
|
1010 |
'numberposts' => 1 |
0
|
1011 |
); |
5
|
1012 |
$attachments = get_children( $args ); |
|
1013 |
$post_thumbnail_id = key($attachments); |
0
|
1014 |
} |
5
|
1015 |
$image = wp_get_attachment_image_src( $post_thumbnail_id, 'portfolio-thumb' ); |
|
1016 |
$image_alt = get_post_meta( $post_thumbnail_id, '_wp_attachment_image_alt', true ); |
|
1017 |
$image_desc = get_post( $post_thumbnail_id ); |
|
1018 |
$image_desc = $image_desc->post_content; |
|
1019 |
$post_meta = get_post_meta( $post->ID, 'prtfl_information', true); |
|
1020 |
$date_compl = isset( $post_meta['_prtfl_date_compl'] ) ? $post_meta['_prtfl_date_compl'] : ''; |
|
1021 |
if ( ! empty( $date_compl ) && 'in progress' != $date_compl ) { |
|
1022 |
$date_compl = explode( "/", $date_compl ); |
|
1023 |
$date_compl = date( get_option( 'date_format' ), strtotime( $date_compl[1]."-".$date_compl[0].'-'.$date_compl[2] ) ); |
|
1024 |
} |
|
1025 |
$link = isset( $post_meta['_prtfl_link'] ) ? $post_meta['_prtfl_link'] : ''; |
|
1026 |
$short_descr = isset( $post_meta['_prtfl_short_descr'] ) ? $post_meta['_prtfl_short_descr'] : ''; |
|
1027 |
if ( empty( $short_descr ) ) |
|
1028 |
$short_descr = get_the_excerpt(); |
|
1029 |
$title = get_the_title(); |
|
1030 |
if ( empty( $title ) ) |
|
1031 |
$title = '(' . __( 'No title', 'portfolio-pro' ) . ')'; |
|
1032 |
$permalink = get_permalink(); |
|
1033 |
|
0
|
1034 |
$content .= '<div class="portfolio_thumb" style="width:165px"> |
5
|
1035 |
<img src="' . $image[0] . '" width="' . $image[1] . '" alt="' . $image_alt . '" /> |
0
|
1036 |
</div> |
|
1037 |
<div class="portfolio_short_content"> |
|
1038 |
<div class="item_title"> |
|
1039 |
<p> |
5
|
1040 |
<a href="' . $permalink . '" rel="bookmark">' . $title . '</a> |
0
|
1041 |
</p> |
|
1042 |
</div> <!-- .item_title -->'; |
5
|
1043 |
$content .= '<p>' . $short_descr . '</p> |
0
|
1044 |
</div> <!-- .portfolio_short_content --> |
|
1045 |
</div> <!-- .entry --> |
|
1046 |
<div class="read_more"> |
5
|
1047 |
<a href="' . $permalink . '" rel="bookmark">' . __( 'Read more', 'portfolio' ) . '</a> |
0
|
1048 |
</div> <!-- .read_more --> |
|
1049 |
<div class="portfolio_terms">'; |
5
|
1050 |
$terms = wp_get_object_terms( $post->ID, 'portfolio_technologies' ); |
|
1051 |
if ( is_array( $terms ) && 0 < count( $terms ) ) { |
|
1052 |
$content .= __( 'Technologies', 'portfolio' ) . ':'; |
0
|
1053 |
$count = 0; |
|
1054 |
foreach ( $terms as $term ) { |
5
|
1055 |
if ( $count > 0 ) |
|
1056 |
$content .= ', '; |
|
1057 |
$content .= '<a href="' . get_term_link( $term->slug, 'portfolio_technologies') . '" title="' . sprintf( __( "View all posts in %s" ), $term->name ) . '" ' . '>' . $term->name . '</a>'; |
0
|
1058 |
$count++; |
|
1059 |
} |
|
1060 |
} else { |
|
1061 |
$content .= ' '; |
|
1062 |
} |
|
1063 |
$content .= '</div><!-- .portfolio_terms -->'; |
|
1064 |
$content .= '<div class="prtfl_clear"></div></div> <!-- .portfolio_content -->'; |
5
|
1065 |
endwhile; |
0
|
1066 |
$content .= '</div> <!-- .prtfl_portfolio_block -->'; |
|
1067 |
wp_reset_query(); |
|
1068 |
return $content; |
|
1069 |
} |
|
1070 |
} |
|
1071 |
|
|
1072 |
/* Register style and script files */ |
|
1073 |
if ( ! function_exists ( 'prtfl_admin_head' ) ) { |
|
1074 |
function prtfl_admin_head() { |
5
|
1075 |
global $wp_version, $prtfl_plugin_info, $post_type; |
|
1076 |
if ( $wp_version < 3.8 ) |
|
1077 |
wp_enqueue_style( 'prtfl_stylesheet', plugins_url( 'css/style_wp_before_3.8.css', __FILE__ ) ); |
|
1078 |
else |
|
1079 |
wp_enqueue_style( 'prtfl_stylesheet', plugins_url( 'css/style.css', __FILE__ ) ); |
|
1080 |
wp_enqueue_style( 'prtfl_datepicker_stylesheet', plugins_url( 'datepicker/datepicker.css', __FILE__ ) ); |
0
|
1081 |
|
5
|
1082 |
if ( isset( $_GET['page'] ) && "portfolio.php" == $_GET['page'] ) { |
|
1083 |
wp_enqueue_script( 'prtfl_script', plugins_url( 'js/script.js', __FILE__ ) ); |
|
1084 |
wp_localize_script( 'prtfl_script', 'prtfl_var', array( |
|
1085 |
'prtfl_nonce' => wp_create_nonce( plugin_basename( __FILE__ ), 'prtfl_ajax_nonce_field' ), |
|
1086 |
'update_img_message' => __( 'Updating images...', 'portfolio' ), |
|
1087 |
'not_found_img_info' => __( 'No image found', 'portfolio'), |
|
1088 |
'img_success' => __( 'All images are updated', 'portfolio' ), |
|
1089 |
'img_error' => __( 'Error.', 'portfolio' ) ) ); |
|
1090 |
} |
|
1091 |
wp_enqueue_script( 'prtfl_datepicker_script', plugins_url( 'datepicker/datepicker.js', __FILE__ ) ); |
0
|
1092 |
} |
|
1093 |
} |
|
1094 |
|
|
1095 |
if ( ! function_exists ( 'prtfl_wp_head' ) ) { |
|
1096 |
function prtfl_wp_head() { |
5
|
1097 |
wp_enqueue_style( 'prtfl_stylesheet', plugins_url( 'css/style.css', __FILE__ ) ); |
|
1098 |
|
|
1099 |
if ( ! function_exists( 'is_plugin_active' ) ) |
|
1100 |
require_once( ABSPATH . '/wp-admin/includes/plugin.php' ); |
|
1101 |
|
|
1102 |
$all_plugins = get_plugins(); |
|
1103 |
|
|
1104 |
if ( ! is_plugin_active( 'gallery-plugin-pro/gallery-plugin-pro.php' ) || ( isset( $all_plugins["gallery-plugin-pro/gallery-plugin-pro.php"]["Version"] ) && "1.3.0" >= $all_plugins["gallery-plugin-pro/gallery-plugin-pro.php"]["Version"] ) ) { |
|
1105 |
wp_enqueue_style( 'prtfl_lightbox_stylesheet', plugins_url( 'fancybox/jquery.fancybox-1.3.4.css', __FILE__ ) ); |
|
1106 |
wp_enqueue_script( 'prtfl_fancybox_mousewheelJs', plugins_url( 'fancybox/jquery.mousewheel-3.0.4.pack.js', __FILE__ ), array( 'jquery' ) ); |
|
1107 |
wp_enqueue_script( 'prtfl_fancyboxJs', plugins_url( 'fancybox/jquery.fancybox-1.3.4.pack.js', __FILE__ ), array( 'jquery' ) ); |
0
|
1108 |
} |
|
1109 |
} |
|
1110 |
} |
|
1111 |
|
|
1112 |
if ( ! function_exists ( 'prtfl_update_image' ) ) { |
5
|
1113 |
function prtfl_update_image() { |
0
|
1114 |
global $wpdb; |
5
|
1115 |
check_ajax_referer( plugin_basename( __FILE__ ), 'prtfl_ajax_nonce_field' ); |
|
1116 |
$action = isset( $_REQUEST['action1'] ) ? $_REQUEST['action1'] : ""; |
|
1117 |
$id = isset( $_REQUEST['id'] ) ? $_REQUEST['id'] : ""; |
|
1118 |
switch ( $action ) { |
0
|
1119 |
case 'get_all_attachment': |
5
|
1120 |
$result_parent_id = $wpdb->get_results( $wpdb->prepare( "SELECT ID FROM " . $wpdb->posts . " WHERE post_type = %s", 'portfolio' ) , ARRAY_N ); |
|
1121 |
$array_parent_id = array(); |
|
1122 |
|
|
1123 |
while ( list( $key, $val ) = each( $result_parent_id ) ) |
0
|
1124 |
$array_parent_id[] = $val[0]; |
|
1125 |
|
|
1126 |
$string_parent_id = implode( ",", $array_parent_id ); |
5
|
1127 |
|
|
1128 |
$result_attachment_id = $wpdb->get_results( "SELECT ID FROM " . $wpdb->posts . " WHERE post_type = 'attachment' AND post_mime_type LIKE 'image%' AND post_parent IN (" . $string_parent_id . ")" ); |
0
|
1129 |
echo json_encode( $result_attachment_id ); |
|
1130 |
break; |
|
1131 |
case 'update_image': |
5
|
1132 |
$metadata = wp_get_attachment_metadata( $id ); |
|
1133 |
$uploads = wp_upload_dir(); |
|
1134 |
$path = $uploads['basedir'] . "/" . $metadata['file']; |
0
|
1135 |
require_once( ABSPATH . 'wp-admin/includes/image.php' ); |
|
1136 |
$metadata_new = prtfl_wp_generate_attachment_metadata( $id, $path, $metadata ); |
5
|
1137 |
wp_update_attachment_metadata( $id, array_merge( $metadata, $metadata_new ) ); |
0
|
1138 |
break; |
|
1139 |
case 'update_options': |
|
1140 |
add_option( 'prtfl_images_update', '1', '', 'no' ); |
|
1141 |
break; |
|
1142 |
} |
|
1143 |
die(); |
|
1144 |
} |
|
1145 |
} |
|
1146 |
|
|
1147 |
if ( ! function_exists ( 'prtfl_wp_generate_attachment_metadata' ) ) { |
|
1148 |
function prtfl_wp_generate_attachment_metadata( $attachment_id, $file, $metadata ) { |
5
|
1149 |
global $prtfl_options; |
|
1150 |
$attachment = get_post( $attachment_id ); |
0
|
1151 |
add_image_size( 'portfolio-thumb', $prtfl_options['prtfl_custom_size_px'][0][0], $prtfl_options['prtfl_custom_size_px'][0][1], true ); |
|
1152 |
add_image_size( 'portfolio-photo-thumb', $prtfl_options['prtfl_custom_size_px'][1][0], $prtfl_options['prtfl_custom_size_px'][1][1], true ); |
|
1153 |
|
|
1154 |
$metadata = array(); |
5
|
1155 |
if ( preg_match('!^image/!', get_post_mime_type( $attachment ) ) && file_is_displayable_image( $file ) ) { |
|
1156 |
$imagesize = getimagesize( $file ); |
|
1157 |
$metadata['width'] = $imagesize[0]; |
|
1158 |
$metadata['height'] = $imagesize[1]; |
|
1159 |
list($uwidth, $uheight) = wp_constrain_dimensions( $metadata['width'], $metadata['height'], 128, 96 ); |
|
1160 |
$metadata['hwstring_small'] = "height='$uheight' width='$uwidth'"; |
0
|
1161 |
|
5
|
1162 |
/* Make the file path relative to the upload dir */ |
|
1163 |
$metadata['file']= _wp_relative_upload_path( $file ); |
0
|
1164 |
|
5
|
1165 |
/* Make thumbnails and other intermediate sizes */ |
0
|
1166 |
global $_wp_additional_image_sizes; |
5
|
1167 |
|
|
1168 |
$image_size = array( 'portfolio-thumb', 'portfolio-photo-thumb' );/* get_intermediate_image_sizes(); */ |
|
1169 |
|
0
|
1170 |
foreach ( $image_size as $s ) { |
5
|
1171 |
$sizes[ $s ] = array( 'width' => '', 'height' => '', 'crop' => FALSE ); |
|
1172 |
if ( isset( $_wp_additional_image_sizes[ $s ]['width'] ) ) |
|
1173 |
$sizes[ $s]['width'] = intval( $_wp_additional_image_sizes[$s]['width'] ); /* For theme-added sizes */ |
0
|
1174 |
else |
5
|
1175 |
$sizes[ $s ]['width'] = get_option( "{$s}_size_w" ); /* For default sizes set in options */ |
0
|
1176 |
if ( isset( $_wp_additional_image_sizes[$s]['height'] ) ) |
5
|
1177 |
$sizes[ $s ]['height'] = intval( $_wp_additional_image_sizes[$s]['height'] ); /* For theme-added sizes */ |
0
|
1178 |
else |
5
|
1179 |
$sizes[ $s ]['height'] = get_option( "{$s}_size_h" ); /* For default sizes set in options */ |
0
|
1180 |
if ( isset( $_wp_additional_image_sizes[$s]['crop'] ) ) |
5
|
1181 |
$sizes[ $s ]['crop'] = intval( $_wp_additional_image_sizes[$s]['crop'] ); /* For theme-added sizes */ |
0
|
1182 |
else |
5
|
1183 |
$sizes[ $s ]['crop'] = get_option( "{$s}_crop" ); /* For default sizes set in options */ |
0
|
1184 |
} |
|
1185 |
|
|
1186 |
$sizes = apply_filters( 'intermediate_image_sizes_advanced', $sizes ); |
5
|
1187 |
foreach ( $sizes as $size => $size_data ) { |
0
|
1188 |
$resized = prtfl_image_make_intermediate_size( $file, $size_data['width'], $size_data['height'], $size_data['crop'] ); |
|
1189 |
if ( $resized ) |
|
1190 |
$metadata['sizes'][$size] = $resized; |
|
1191 |
} |
|
1192 |
|
5
|
1193 |
/* Fetch additional metadata from exif/iptc */ |
0
|
1194 |
$image_meta = wp_read_image_metadata( $file ); |
|
1195 |
if ( $image_meta ) |
|
1196 |
$metadata['image_meta'] = $image_meta; |
|
1197 |
} |
|
1198 |
return apply_filters( 'wp_generate_attachment_metadata', $metadata, $attachment_id ); |
|
1199 |
} |
|
1200 |
} |
|
1201 |
|
|
1202 |
if ( ! function_exists ( 'prtfl_image_make_intermediate_size' ) ) { |
|
1203 |
function prtfl_image_make_intermediate_size( $file, $width, $height, $crop=false ) { |
|
1204 |
if ( $width || $height ) { |
|
1205 |
$resized_file = prtfl_image_resize( $file, $width, $height, $crop ); |
5
|
1206 |
if ( ! is_wp_error( $resized_file ) && $resized_file && $info = getimagesize( $resized_file ) ) { |
|
1207 |
$resized_file = apply_filters( 'image_make_intermediate_size', $resized_file ); |
0
|
1208 |
return array( |
5
|
1209 |
'file' => wp_basename( $resized_file ), |
|
1210 |
'width' => $info[0], |
|
1211 |
'height' => $info[1], |
0
|
1212 |
); |
|
1213 |
} |
|
1214 |
} |
|
1215 |
return false; |
|
1216 |
} |
|
1217 |
} |
|
1218 |
|
|
1219 |
if ( ! function_exists ( 'prtfl_image_resize' ) ) { |
|
1220 |
function prtfl_image_resize( $file, $max_w, $max_h, $crop = false, $suffix = null, $dest_path = null, $jpeg_quality = 90 ) { |
|
1221 |
$size = @getimagesize( $file ); |
5
|
1222 |
if ( !$size ) |
|
1223 |
return new WP_Error( 'invalid_image', __( 'Image size not defined', 'portfolio' ), $file ); |
|
1224 |
$type = $size[2]; |
0
|
1225 |
|
5
|
1226 |
if ( 3 == $type ) |
|
1227 |
$image = imagecreatefrompng( $file ); |
|
1228 |
else if ( 2 == $type ) |
|
1229 |
$image = imagecreatefromjpeg( $file ); |
|
1230 |
else if ( 1 == $type ) |
|
1231 |
$image = imagecreatefromgif( $file ); |
|
1232 |
else if ( 15 == $type ) |
|
1233 |
$image = imagecreatefromwbmp( $file ); |
|
1234 |
else if ( 16 == $type ) |
|
1235 |
$image = imagecreatefromxbm( $file ); |
|
1236 |
else |
|
1237 |
return new WP_Error( 'invalid_image', __( 'We can update only PNG, JPEG, GIF, WPMP or XBM filetype. For other, please, manually reload image.', 'portfolio' ), $file ); |
0
|
1238 |
|
5
|
1239 |
if ( ! is_resource( $image ) ) |
|
1240 |
return new WP_Error( 'error_loading_image', $image, $file ); |
0
|
1241 |
|
5
|
1242 |
/* $size = @getimagesize( $file ); */ |
|
1243 |
list( $orig_w, $orig_h, $orig_type ) = $size; |
0
|
1244 |
$dims = prtfl_image_resize_dimensions($orig_w, $orig_h, $max_w, $max_h, $crop); |
|
1245 |
|
5
|
1246 |
if ( ! $dims ) |
|
1247 |
return new WP_Error( 'error_getting_dimensions', __( 'Image size changes not defined', 'portfolio' ) ); |
0
|
1248 |
list( $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h ) = $dims; |
|
1249 |
$newimage = wp_imagecreatetruecolor( $dst_w, $dst_h ); |
5
|
1250 |
imagecopyresampled( $newimage, $image, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h ); |
|
1251 |
/* Convert from full colors to index colors, like original PNG. */ |
|
1252 |
if ( IMAGETYPE_PNG == $orig_type && function_exists( 'imageistruecolor' ) && ! imageistruecolor( $image ) ) |
0
|
1253 |
imagetruecolortopalette( $newimage, false, imagecolorstotal( $image ) ); |
5
|
1254 |
/* We don't need the original in memory anymore */ |
0
|
1255 |
imagedestroy( $image ); |
|
1256 |
|
5
|
1257 |
/* $suffix will be appended to the destination filename, just before the extension */ |
|
1258 |
if ( ! $suffix ) |
0
|
1259 |
$suffix = "{$dst_w}x{$dst_h}"; |
|
1260 |
|
5
|
1261 |
$info = pathinfo( $file ); |
|
1262 |
$dir = $info['dirname']; |
|
1263 |
$ext = $info['extension']; |
|
1264 |
$name = wp_basename( $file, ".$ext" ); |
0
|
1265 |
|
5
|
1266 |
if ( ! is_null( $dest_path ) and $_dest_path = realpath( $dest_path ) ) |
0
|
1267 |
$dir = $_dest_path; |
|
1268 |
$destfilename = "{$dir}/{$name}-{$suffix}.{$ext}"; |
|
1269 |
|
|
1270 |
if ( IMAGETYPE_GIF == $orig_type ) { |
5
|
1271 |
if ( ! imagegif( $newimage, $destfilename ) ) |
|
1272 |
return new WP_Error( 'resize_path_invalid', __( 'Invalid path', 'portfolio' ) ); |
0
|
1273 |
} elseif ( IMAGETYPE_PNG == $orig_type ) { |
5
|
1274 |
if ( ! imagepng( $newimage, $destfilename ) ) |
|
1275 |
return new WP_Error( 'resize_path_invalid', __( 'Invalid path', 'portfolio' ) ); |
0
|
1276 |
} else { |
5
|
1277 |
/* All other formats are converted to jpg */ |
0
|
1278 |
$destfilename = "{$dir}/{$name}-{$suffix}.jpg"; |
5
|
1279 |
if ( ! imagejpeg( $newimage, $destfilename, apply_filters( 'jpeg_quality', $jpeg_quality, 'image_resize' ) ) ) |
|
1280 |
return new WP_Error( 'resize_path_invalid', __( 'Invalid path', 'portfolio' ) ); |
0
|
1281 |
} |
|
1282 |
|
|
1283 |
imagedestroy( $newimage ); |
5
|
1284 |
/* Set correct file permissions */ |
|
1285 |
$stat = stat( dirname( $destfilename ) ); |
|
1286 |
$perms = $stat['mode'] & 0000666; /* Same permissions as parent folder, strip off the executable bits */ |
|
1287 |
@chmod( $destfilename, $perms ); |
0
|
1288 |
return $destfilename; |
|
1289 |
} |
|
1290 |
} |
|
1291 |
|
|
1292 |
if ( ! function_exists ( 'prtfl_image_resize_dimensions' ) ) { |
|
1293 |
function prtfl_image_resize_dimensions( $orig_w, $orig_h, $dest_w, $dest_h, $crop = false ) { |
|
1294 |
|
5
|
1295 |
if ( 0 >= $orig_w || 0 >= $orig_h ) |
0
|
1296 |
return false; |
5
|
1297 |
/* At least one of dest_w or dest_h must be specific */ |
|
1298 |
if ( 0 >= $dest_w && 0 >= $dest_h ) |
0
|
1299 |
return false; |
|
1300 |
|
|
1301 |
if ( $crop ) { |
5
|
1302 |
/* Crop the largest possible portion of the original image that we can size to $dest_w x $dest_h */ |
|
1303 |
$aspect_ratio = $orig_w / $orig_h; |
|
1304 |
$new_w = min( $dest_w, $orig_w ); |
|
1305 |
$new_h = min( $dest_h, $orig_h ); |
0
|
1306 |
|
5
|
1307 |
if ( ! $new_w ) { |
|
1308 |
$new_w = intval( $new_h * $aspect_ratio ); |
0
|
1309 |
} |
|
1310 |
|
5
|
1311 |
if ( ! $new_h ) { |
|
1312 |
$new_h = intval( $new_w / $aspect_ratio ); |
|
1313 |
} |
0
|
1314 |
|
5
|
1315 |
$size_ratio = max( $new_w / $orig_w, $new_h / $orig_h ); |
|
1316 |
$crop_w = round( $new_w / $size_ratio ); |
|
1317 |
$crop_h = round( $new_h / $size_ratio ); |
|
1318 |
$s_x = floor( ( $orig_w - $crop_w ) / 2 ); |
|
1319 |
$s_y = 0; |
0
|
1320 |
} else { |
5
|
1321 |
/* Don't crop, just resize using $dest_w x $dest_h as a maximum bounding box */ |
|
1322 |
$crop_w = $orig_w; |
|
1323 |
$crop_h = $orig_h; |
|
1324 |
$s_x = 0; |
|
1325 |
$s_y = 0; |
0
|
1326 |
list( $new_w, $new_h ) = wp_constrain_dimensions( $orig_w, $orig_h, $dest_w, $dest_h ); |
|
1327 |
} |
|
1328 |
|
5
|
1329 |
/* If the resulting image would be the same size or larger we don't want to resize it */ |
0
|
1330 |
if ( $new_w >= $orig_w && $new_h >= $orig_h ) |
|
1331 |
return false; |
5
|
1332 |
/* The return array matches the parameters to imagecopyresampled() */ |
|
1333 |
/* Int dst_x, int dst_y, int src_x, int src_y, int dst_w, int dst_h, int src_w, int src_h */ |
0
|
1334 |
return array( 0, 0, (int) $s_x, (int) $s_y, (int) $new_w, (int) $new_h, (int) $crop_w, (int) $crop_h ); |
|
1335 |
} |
|
1336 |
} |
|
1337 |
|
5
|
1338 |
|
|
1339 |
if ( ! function_exists( 'prtfl_sanitize_file_name' ) ) { |
|
1340 |
function prtfl_sanitize_file_name( $file_name ) { |
|
1341 |
global $prtfl_options; |
|
1342 |
if ( isset( $_REQUEST['post_id'] ) && 'portfolio' == get_post_type( $_REQUEST['post_id'] ) |
|
1343 |
&& isset( $prtfl_options['prtfl_rename_file'] ) && $prtfl_options['prtfl_rename_file'] == 1 ) { |
|
1344 |
$file_name_old = explode( '.', $file_name ); |
|
1345 |
$file_name_new = preg_replace( '/--+/', '-', preg_replace( '/[^a-zA-Z0-9_-]/', '', $file_name_old[0] ) ); |
0
|
1346 |
|
5
|
1347 |
if ( $file_name_new == '' || $file_name_new == '-' ) { |
|
1348 |
$slug = isset( $prtfl_options['prtfl_slug'] ) && ! empty( $prtfl_options['prtfl_slug'] ) ? $prtfl_options['prtfl_slug'] : 'portfolio'; |
|
1349 |
$file_name_new = $slug . '-' . time(); |
|
1350 |
} |
|
1351 |
$file_name = $file_name_new . '.' . $file_name_old[1]; |
|
1352 |
} |
|
1353 |
return $file_name; |
|
1354 |
} |
|
1355 |
} |
0
|
1356 |
|
5
|
1357 |
if ( ! function_exists( 'prtfl_filter_image_sizes' ) ) { |
|
1358 |
function prtfl_filter_image_sizes( $sizes ) { |
|
1359 |
if ( isset( $_REQUEST['post_id'] ) && 'portfolio' == get_post_type( $_REQUEST['post_id'] ) ) { |
|
1360 |
$prtfl_image_size = array( 'portfolio-thumb', 'portfolio-photo-thumb', 'large' ); |
|
1361 |
foreach ( $sizes as $key => $value ) { |
|
1362 |
if ( ! in_array( $key, $prtfl_image_size ) ) { |
|
1363 |
unset( $sizes[ $key ] ); |
|
1364 |
} |
|
1365 |
} |
|
1366 |
} |
|
1367 |
return $sizes; |
|
1368 |
} |
|
1369 |
} |
0
|
1370 |
|
5
|
1371 |
if ( ! function_exists ( 'prtfl_theme_body_classes' ) ) { |
|
1372 |
function prtfl_theme_body_classes( $classes ) { |
|
1373 |
if ( function_exists( 'wp_get_theme' ) ) { |
|
1374 |
$current_theme = wp_get_theme(); |
|
1375 |
$classes[] = 'prtfl_' . basename( $current_theme->get( 'ThemeURI' ) ); |
|
1376 |
} |
|
1377 |
return $classes; |
|
1378 |
} |
|
1379 |
} |
0
|
1380 |
|
5
|
1381 |
if ( ! function_exists ( 'prtfl_admin_notices' ) ) { |
|
1382 |
function prtfl_admin_notices() { |
|
1383 |
global $hook_suffix, $prtfl_plugin_info, $prtfl_options; |
|
1384 |
|
|
1385 |
if ( 'plugins.php' == $hook_suffix ) { |
|
1386 |
bws_plugin_banner( $prtfl_plugin_info, 'prtfl', 'portfolio', '56e6c97d1bca3199fb16cb817793a8f6', '74', '//ps.w.org/portfolio/assets/icon-128x128.png' ); |
|
1387 |
|
|
1388 |
/* Get options from the database */ |
|
1389 |
if ( ! $prtfl_options ) |
|
1390 |
$prtfl_options = get_option( 'prtfl_options' ); |
0
|
1391 |
|
5
|
1392 |
if ( $prtfl_options['widget_updated'] == 0 ) { |
|
1393 |
/* Save data for settings page */ |
|
1394 |
if ( isset( $_REQUEST['prtfl_form_submit'] ) && check_admin_referer( plugin_basename(__FILE__), 'prtfl_nonce_name' ) ) { |
|
1395 |
$prtfl_options['widget_updated'] = 1; |
|
1396 |
update_option( 'prtfl_options', $prtfl_options ); |
|
1397 |
} else { ?> |
|
1398 |
<div class="updated" style="padding: 0; margin: 0; border: none; background: none;"> |
|
1399 |
<div class="prtfl_admin_notices bws_banner_on_plugin_page"> |
|
1400 |
<form method="post" action="<?php echo $hook_suffix; ?>"> |
|
1401 |
<div class="text"> |
|
1402 |
<p> |
|
1403 |
<strong><?php _e( "ATTENTION!", 'portfolio' ); ?></strong> |
|
1404 |
<?php _e( "In the current version of Portfolio plugin we updated the Technologies widget. If it was added to the sidebar, it will disappear and you will have to add it again.", 'portfolio' ); ?> |
|
1405 |
</p> |
|
1406 |
<input type="hidden" name="prtfl_form_submit" value="submit" /> |
|
1407 |
<p class="submit"> |
|
1408 |
<input type="submit" class="button-primary" value="<?php _e( 'Read and Understood' ); ?>" /> |
|
1409 |
</p> |
|
1410 |
<?php wp_nonce_field( plugin_basename( __FILE__ ), 'prtfl_nonce_name' ); ?> |
|
1411 |
</div> |
|
1412 |
</form> |
|
1413 |
</div> |
|
1414 |
</div> |
|
1415 |
<?php } |
|
1416 |
} |
|
1417 |
} |
|
1418 |
} |
|
1419 |
} |
|
1420 |
|
0
|
1421 |
|
5
|
1422 |
if ( ! function_exists( 'prtfl_plugin_uninstall' ) ) { |
|
1423 |
function prtfl_plugin_uninstall() { |
|
1424 |
require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
|
1425 |
|
|
1426 |
if ( file_exists( get_stylesheet_directory() . '/portfolio.php' ) && ! unlink( get_stylesheet_directory() . '/portfolio.php' ) ) |
|
1427 |
add_action( 'admin_notices', create_function( '', ' return "Error delete template file";' ) ); |
|
1428 |
if ( file_exists( get_stylesheet_directory() . '/portfolio-post.php' ) && ! unlink( get_stylesheet_directory() . '/portfolio-post.php' ) ) |
|
1429 |
add_action( 'admin_notices', create_function( '', ' return "Error delete template file";' ) ); |
0
|
1430 |
|
5
|
1431 |
delete_option( 'prtfl_options' ); |
|
1432 |
delete_option( 'prtfl_tag_update' ); |
|
1433 |
$plugins_list = get_plugins(); |
|
1434 |
if ( ! array_key_exists( 'portfolio-pro/portfolio-pro.php', $plugins_list ) ) |
|
1435 |
delete_option( 'widget-portfolio_technologies_widget' ); |
|
1436 |
} |
|
1437 |
} |
0
|
1438 |
|
5
|
1439 |
register_activation_hook( __FILE__, 'prtfl_plugin_install' ); /* Activate plugin */ |
|
1440 |
/* Add portfolio settings page in admin menu */ |
|
1441 |
add_action( 'admin_menu', 'add_prtfl_admin_menu' ); |
|
1442 |
add_action( 'admin_init', 'prtfl_admin_init' ); |
|
1443 |
add_action( 'init', 'prtfl_init' ); |
|
1444 |
add_action( 'wp_loaded', 'prtfl_flush_rules' ); |
|
1445 |
/* Save custom data from admin */ |
|
1446 |
add_action( 'save_post', 'prtfl_save_postdata', 1, 2 ); |
|
1447 |
add_filter( 'content_save_pre', 'prtfl_content_save_pre', 10, 1 ); |
|
1448 |
|
|
1449 |
/* Add template for single portfolio page */ |
|
1450 |
add_action( 'template_redirect', 'prtfl_template_redirect' ); |
|
1451 |
/* Add template in theme after activate new theme */ |
|
1452 |
add_action( 'after_switch_theme', 'prtfl_after_switch_theme', 10, 2 ); |
0
|
1453 |
|
|
1454 |
add_action( 'admin_enqueue_scripts', 'prtfl_admin_head' ); |
|
1455 |
add_action( 'wp_enqueue_scripts', 'prtfl_wp_head' ); |
|
1456 |
|
5
|
1457 |
/* add theme name as class to body tag */ |
|
1458 |
add_filter( 'body_class', 'prtfl_theme_body_classes' ); |
|
1459 |
|
|
1460 |
/* Add widget for portfolio technologies */ |
|
1461 |
add_action( 'widgets_init', 'prtfl_register_widget' ); |
|
1462 |
|
0
|
1463 |
add_action( 'wp_ajax_prtfl_update_image', 'prtfl_update_image' ); |
5
|
1464 |
|
|
1465 |
add_shortcode( 'latest_portfolio_items', 'prtfl_latest_items' ); |
|
1466 |
|
|
1467 |
add_filter( 'request', 'prtfl_request_filter' ); |
|
1468 |
/* Display tachnologies taxonomy */ |
|
1469 |
add_filter( 'pre_get_posts', 'prtfl_technologies_get_posts' ); |
|
1470 |
add_filter( 'rewrite_rules_array', 'prtfl_custom_permalinks' ); |
|
1471 |
/* Additional links on the plugin page */ |
|
1472 |
add_filter( 'plugin_row_meta', 'prtfl_register_plugin_links', 10, 2 ); |
|
1473 |
add_filter( 'plugin_action_links', 'prtfl_plugin_action_links', 10, 2 ); |
|
1474 |
|
|
1475 |
add_filter( 'nav_menu_css_class', 'prtfl_add_portfolio_ancestor_to_menu', 10, 2 ); |
|
1476 |
|
|
1477 |
add_filter( 'sanitize_file_name', 'prtfl_sanitize_file_name' ); |
|
1478 |
add_filter( 'intermediate_image_sizes_advanced', 'prtfl_filter_image_sizes' ); |
|
1479 |
|
|
1480 |
add_action( 'admin_notices', 'prtfl_admin_notices'); |
|
1481 |
|
|
1482 |
register_uninstall_hook( __FILE__, 'prtfl_plugin_uninstall' ); /* Deactivate plugin */ |
0
|
1483 |
?> |