diff -r bf1778c34b9a -r d8a8807227e4 wp/wp-content/plugins/portfolio/portfolio.php --- a/wp/wp-content/plugins/portfolio/portfolio.php Mon Oct 14 18:35:50 2019 +0200 +++ b/wp/wp-content/plugins/portfolio/portfolio.php Tue Oct 15 11:56:20 2019 +0200 @@ -6,13 +6,13 @@ Author: BestWebSoft Text Domain: portfolio Domain Path: /languages -Version: 2.46 +Version: 2.51 Author URI: https://bestwebsoft.com/ License: GPLv2 or later */ /* - @ Copyright 2017 BestWebSoft ( https://support.bestwebsoft.com ) + @ Copyright 2019 BestWebSoft ( https://support.bestwebsoft.com ) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2, as @@ -219,6 +219,7 @@ 'order_by' => 'date', 'order' => 'DESC', 'custom_image_row_count' => 3, + 'custom_portfolio_row_count' => 1, 'date_additional_field' => 1, 'link_additional_field' => 1, 'shrdescription_additional_field' => 1, @@ -1089,10 +1090,26 @@ /* forming content for portfolio items */ if ( ! function_exists( 'prtfl_latest_items' ) ) { - function prtfl_latest_items( $atts ) { + function prtfl_latest_items( $atts, $widget = false ) { global $prtfl_options, $wp_query; $old_wp_query = $wp_query; + $count_portfolio_row_block = 0; + if ( $widget == false) { + $custom_portfolio_row_count = $prtfl_options['custom_portfolio_row_count']; + } else { + $custom_portfolio_row_count = $widget; + } + $prtfl_widht = 100 / $custom_portfolio_row_count; + + if( 1 < $custom_portfolio_row_count ) { + $prtfl_read_more = 'style="float:left"'; + $prtfl_img_width = ''; + }else{ + $prtfl_read_more = ""; + $prtfl_img_width = 'style="width:165px"'; + } + $content = '
'; if ( empty( $atts['count'] ) ) { $atts['count'] = 3; @@ -1101,7 +1118,7 @@ 'post_type' => $prtfl_options['post_type_name'], 'post_status' => 'publish', 'orderby' => 'date', - 'order' => 'DESC', + 'order' => $prtfl_options['order'], 'posts_per_page' => $atts['count'], ); $second_query = new WP_Query( $args ); @@ -1110,7 +1127,10 @@ if ( $second_query->have_posts() ) { while ( $second_query->have_posts() ) { $second_query->the_post(); - $content .= ' + if ( $count_portfolio_row_block % $custom_portfolio_row_count == 0 ) { + $content .= '
'; + } + $content .= '
'; global $post; @@ -1144,7 +1164,7 @@ } $permalink = get_permalink(); - $content .= '
+ $content .= '
' . $image_alt . '
@@ -1158,7 +1178,7 @@ } $content .= '
-
+
'; @@ -1179,10 +1199,15 @@ } } $content .= '
'; - $content .= '
'; + $content .= '
'; + if ( ( $count_portfolio_row_block % $custom_portfolio_row_count ) == ( $custom_portfolio_row_count - 1 ) ) { + $content .= '
+
'; + } + $count_portfolio_row_block = $count_portfolio_row_block + 1; } } - $content .= '
'; + $content .= '
'; wp_reset_query(); $wp_query = $old_wp_query; return $content; @@ -1295,11 +1320,28 @@ $id = isset( $_REQUEST['id'] ) ? $_REQUEST['id'] : ""; switch ( $action ) { case 'get_all_attachment': - $array_parent_id = $wpdb->get_col( "SELECT `ID` FROM $wpdb->posts WHERE `post_type` = {$prtfl_options['post_type_name']}" ); + + $array_parent_id = $wpdb->get_col( $wpdb->prepare( " + SELECT + ID + FROM + {$wpdb->posts} + WHERE + post_type = %s + ", $prtfl_options['post_type_name'] ) ); + if ( ! empty( $array_parent_id ) ) { $string_parent_id = implode( ",", $array_parent_id ); - $metas = $wpdb->get_results( "SELECT `meta_value` FROM $wpdb->postmeta WHERE `meta_key` = '_prtfl_images' AND `post_id` IN (" . $string_parent_id . ")", ARRAY_A ); + $metas = $wpdb->get_results( " + SELECT + meta_value + FROM + {$wpdb->postmeta} + WHERE + meta_key = '_prtfl_images' AND + post_id IN (" . $string_parent_id . ") + ", ARRAY_A ); $result_attachment_id = ''; foreach ( $metas as $key => $value ) { @@ -1309,7 +1351,17 @@ } $result_attachment_id_array = explode( ",", rtrim( $result_attachment_id, ',' ) ); - $attached_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 . ")", ARRAY_A ); + $attached_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 . ") + ", ARRAY_A ); + foreach ( $attached_id as $key => $value ) { $result_attachment_id_array[] = $value['ID']; } @@ -1680,7 +1732,7 @@ */ if ( ! function_exists( 'prtfl_get_query_args' ) ) { function prtfl_get_query_args() { - global $prtfl_options; + global $prtfl_options, $wp_query; $count = 0; if ( get_query_var( 'paged' ) ) { $paged = get_query_var( 'paged' ); @@ -1751,6 +1803,14 @@ global $post, $prtfl_options; $request = $second_query->request; + $count_portfolio_row_block = 0; + $prtfl_widht = 99 / $prtfl_options['custom_portfolio_row_count']; + + if( 1 < $prtfl_options['custom_portfolio_row_count'] ){ + $prtfl_read_more = 'style="float:left"'; + }else{ + $prtfl_read_more = ""; + } if ( ! empty( $post ) && ! empty( $post->post_content ) ) { $page_content = $post->post_content; @@ -1785,7 +1845,11 @@ if ( $second_query->have_posts() ) { while ( $second_query->have_posts() ) { - $second_query->the_post(); ?> + $second_query->the_post(); + if ( $count_portfolio_row_block % $prtfl_options['custom_portfolio_row_count'] == 0 ) {?> +
+
ID ); @@ -1850,7 +1914,7 @@
- + +
+
+
'bws-portfolio', + 'include' => $prtfl_id_list ) : array( 'post_type' => 'bws-portfolio'); + $prtfl_posts = get_posts( $args ); + + } else if ( is_int( $prtfl_id ) || is_string( $prtfl_id ) ) { + + $prtfl_int_id = is_int( $prtfl_id ) ? $prtfl_id : intval( $prtfl_id ); + $prtfl_posts = get_post( $prtfl_int_id ); + + } + + $prtfl_posts_end = array(); + foreach ( (array)$prtfl_posts as $key => $prtfl_post ) { + + $prtfl_meta = get_post_meta( $prtfl_post->ID, '' ); + unset($prtfl_meta['_edit_lock']); + unset($prtfl_meta['_edit_last']); + + foreach ( $prtfl_meta['prtfl_information'] as $key => $prtfl_information ) { + + $prtfl_information = isset( $prtfl_information ) ? unserialize( $prtfl_information ) : ""; + $prtfl_meta['prtfl_information'][$key] = $prtfl_information; + } + + foreach ( $prtfl_meta['_prtfl_images'] as $key => $prtfl_images ) { + + $prtfl_images_all = isset( $prtfl_images ) ? explode( ',' , $prtfl_images ) : ""; + $args = array( 'post_type' => 'attachment','include' => $prtfl_images_all ) ; + $prtfl_images = ! empty( $prtfl_images_all ) ? get_posts( $args ) : ""; + $prtfl_meta['_prtfl_images'][$key] = $prtfl_images; + } + + $prtfl_posts[$key]->prtfl_post_meta = $prtfl_meta; + } + + return $prtfl_posts; + } +} + + +if ( ! function_exists( 'prtfl_widgets_init' ) ) { + function prtfl_widgets_init() { + register_widget( "Prtfl_Widget" ); + } +} + +/** + * Class extends WP class WP_Widget, and create new widget + * + */ +if ( ! class_exists( 'Prtfl_Widget' ) ) { + class Prtfl_Widget extends WP_Widget { + /** + * constructor of class + */ + public function __construct() { + parent::__construct( + 'prtfl_widget', + __( 'Latest Portfolio Items', 'portfolio' ), + array( 'description' => __( 'Displays the latest Portfolio projects.', 'portfolio' ) ) + ); + } + /** + * Function to displaying widget in front end + * @param array() $args array with sidebar settings + * @param array() $instance array with widget settings + * @return void + */ + public function widget( $args, $instance ) { + + $widget_title = ( ! empty( $instance['widget_title'] ) ) ? apply_filters( 'widget_title', $instance['widget_title'], $instance, $this->id_base ) : ''; + $widget_count_posts = ( ! empty( $instance['widget_count_posts'] ) ) ? $instance['widget_count_posts']: ''; + $widget_count_colums = ( ! empty( $instance['widget_count_colums'] ) ) ? $instance['widget_count_colums']: ''; + + $atts['count'] = $widget_count_posts; + $content = prtfl_latest_items( $atts, $widget_count_colums ); + echo $args['before_widget'] . $args['before_title'] . $widget_title . $args['after_title'] . $content; + } + + public function form( $instance ) { + global $sbscrbr_options; + + $widget_title = isset( $instance['widget_title'] ) ? stripslashes( esc_html( $instance['widget_title'] ) ) : null; + $widget_count_posts = isset( $instance['widget_count_posts'] ) ? stripslashes( esc_html( $instance['widget_count_posts'] ) ) : null; + $widget_count_colums = isset( $instance['widget_count_colums'] ) ? stripslashes( esc_html( $instance['widget_count_colums'] ) ) : null; + ?> +

+ +

+

+ +

+

+ +

+