• Dear

    (@tawhidurrahmandear)


    <?php
    /**
    * Classified Aditem Functions.
    *
    * Functions for aditem specific things.
    *
    * @author WenSolutions
    * @category Core
    * @package Classified/Functions
    * @since 1.0.0
    */

    if ( ! defined( ‘ABSPATH’ ) ) {
    exit; // Exit if accessed directly
    }

    /**
    * Main function for returning aditems, uses the WSC_Aditem_Factory class.
    *
    * @param mixed $the_aditem Post object or post ID of the aditem.
    * @param array $args (default: array()) Contains all arguments to be used to get this aditem.
    * @return WSC_Aditem
    */
    function wsc_get_aditem( $the_aditem = false, $args = array() ) {
    if ( ! did_action( ‘classified_init’ ) ) {
    _doing_it_wrong( __FUNCTION__, __( ‘wsc_get_aditem should not be called before the classified_init action.’, ‘classified’ ), ‘2.5’ );
    return false;
    }
    return WSC()->aditem_factory->get_aditem( $the_aditem, $args );
    }

    /**
    * Get the placeholder image URL for items etc.
    *
    * @access public
    * @return string
    */
    function wsc_placeholder_img_src() {
    return apply_filters( ‘classified_placeholder_img_src’, WSC()->plugin_url() . ‘/assets/images/placeholder.png’ );
    }

    /**
    * Get the placeholder image.
    *
    * @access public
    * @return string
    */
    function wsc_placeholder_img( $size = ‘shop_thumbnail’ ) {
    $dimensions = wsc_get_image_size( $size );

    return apply_filters(‘classified_placeholder_img’, ‘' . esc_attr__( 'Placeholder', 'classified' ) . '‘, $size, $dimensions );
    }

    /**
    * This will insert Single Product Views detail to classified_view_counter Table.
    * @since 2.0.0
    * @return Void
    */
    function wsc_view_insert(){

    if( !is_main_query() )
    return;

    if(!is_singular(‘aditem’))
    {
    return;
    }

    $user_details = wp_get_current_user();

    if( !empty( $user_details->roles ) && ‘administrator’ == $user_details->roles[0] )
    return;

    global $post, $wpdb;

    require_once( ‘class-wsc-user-agent.php’ );
    $ua_info = new WSC_User_Agent();

    // require_once( ‘wsc-user-agent-functions.php’ );
    // $ua_info = parse_user_agent();

    $table = $wpdb->base_prefix.’classified_view_counter’;
    $current_date = date( ‘Y-m-d H:i:s’ );
    $view_year = date( ‘Y’ );
    $view_month = date( ‘m’ );
    $view_day = date( ‘d’ );

    $view_week = date( ‘W’ );

    $wpdb->insert(
    $table,
    array(
    ‘post_id’ => $post->ID,
    ‘ip_address’ => $_SERVER[‘REMOTE_ADDR’],
    ‘browser’ => $ua_info->browser(),
    ‘platform’ => $ua_info->platform(),
    ‘view_date’ => $current_date,
    ‘view_year’ => $view_year,
    ‘view_month’ => $view_month,
    ‘view_day’ => $view_day,
    ‘view_week’ => $view_week,
    ),
    array(
    ‘%d’,
    ‘%s’,
    ‘%s’,
    ‘%s’,
    ‘%s’,
    ‘%s’,
    ‘%s’,
    ‘%s’,
    ‘%s’
    )
    );
    }
    /**
    * Hook to insert
    */
    add_action( ‘template_redirect’, ‘wsc_view_insert’ );

    function classified_get_view_count(){

    global $post, $wpdb;

    $table = $wpdb->base_prefix.’classified_view_counter’;

    $total_views = $wpdb->get_var( “SELECT COUNT(*) as total_view FROM $table where post_id= $post->ID” );
    return esc_attr( $total_views );
    }

    // Fixed shop page current_page_parent class not showing
    function add_parent_url_menu_class( $classes = array(), $item = false ) {
    // Get current URL
    $current_url = classified_current_url();
    // Get homepage URL
    $homepage_url = trailingslashit( get_bloginfo( ‘url’ ) );

    // Exclude 404 and homepage
    if( is_404() or $item->url == $homepage_url )
    return $classes;

    if ( get_post_type() == “additem” )
    {
    unset($classes[array_search(‘current_page_parent’,$classes)]);
    if ( isset($item->url) )
    if ( strstr( $current_url, $item->url) )
    $classes[] = ‘current-menu-item’;
    }

    return $classes;
    }

    function classified_current_url() {

    global $wp;
    return trailingslashit( home_url(add_query_arg(array(),$wp->request)) ); //get current url
    }
    add_filter( ‘nav_menu_css_class’, ‘add_parent_url_menu_class’, 10, 3 );

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter Dear

    (@tawhidurrahmandear)

    Browser showed that there was an error in 147 line.
    But I made correction in 143 line

    OLD: if ( get_post_type() == “aditem” )
    NEW: if ( get_post_type() == “additem” )

    Thread Starter Dear

    (@tawhidurrahmandear)

    It was in wsc-aditem-functions.php

    Hello @tawhidurrahmandear,

    We have inspected for the issue you are facing in the file and it is seen that the error fix you have suggested is not actually fixing the issue but is just skipping the code in the line 147 that might have been causing the error. The post type fix you have suggested is not actually an issue.

    Please revert the code changes and send us the actual error you were getting in the first place so that we could get better insight of the issue and update the code accordingly if needed.

    Best Regards !!

    Thread Starter Dear

    (@tawhidurrahmandear)

    It showed normally “Warning: strstr(): Empty needle in F:\SERVER\htdocs\sample\classified4\wp-content\plugins\classified\includes\wsc-aditem-functions.php on line 147”

    I replaced in line 143
    OLD: if ( get_post_type() == “aditem” )
    NEW: if ( get_post_type() == “additem” )

    Thread Starter Dear

    (@tawhidurrahmandear)

    ​Hi, can you add some more options?

    1. a Notice will be displayed when user’s listing held for moderation, now it says nothing

    2. Members will be able to edit/delete own listing later, and any editing will hold the listing for moderation again,

    3. ​​Offering Free, Membership, Membership with Feature Ad with the options to show ad for a specific time, and Paypal​ payment method with Bank Wire/ Direct Deposit

    This plugin (​ https://wordpress.org/plugins/wpadverts/ ) has mentioned options but with the lack of many things.

    Thanks!

    Hello,

    We appreciate your suggestions and will look forward to adding the features you have requested for with the upcoming plugin updates.

    Also, please be assured on getting the fix to the warning on the next update that you are facing currently in the plugin.

    Thanks for the patience,
    Best Regards !!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘The file had a serious problem, I fixed it. Please update’ is closed to new replies.