Error Functions Wordpress - Parse error: syntax error, unexpected

0

I'm trying to install a theme and when active, the following error appears.

Parse error: syntax error, unexpected '[' in /.../teste-template/wp-content/themes/hello-friday/functions.php on line 267

I tried to fix it in different ways and I could not.

Below is how my functions.php is

<?php


if ( ! defined( 'HEROTHEME_FRAMEWORK_DIR' ) ) {

    define('HEROTHEME_FRAMEWORK_DIR', get_template_directory_uri() . '/htheme/');

}


include get_template_directory() . '/installer/loader.php';

WP_Installer_Setup($wp_installer_instance,

    array(

        'plugins_install_tab' => 1, // optional, default value: 0

        'affiliate_id:wpml' => '146518', // optional, default value: empty

        'affiliate_key:wpml' => 'djYvyztoGbnC', // optional, default value: empty

        'src_name' => 'inVogue', // optional, default value: empty, needed for coupons

        'src_author' => '',// optional, default value: empty, needed for coupons

        'repositories_include' => array('wpml') // optional, default to empty (show all)

    )

);



#CLASSES

require_once(get_template_directory() . '/htheme/classes/class.tgm.php');

require_once(get_template_directory() . '/htheme/classes/class.options.php');

require_once(get_template_directory() . '/htheme/classes/class.settings.php');

require_once(get_template_directory() . '/htheme/classes/class.check.php');

require_once(get_template_directory() . '/htheme/classes/class.forms.php');



#CLASSES

require_once(get_template_directory() . '/htheme/classes/class.get.content.php');

require_once(get_template_directory() . '/htheme/classes/class.backend.php');

require_once(get_template_directory() . '/htheme/classes/class.ajax.php');

require_once(get_template_directory() . '/htheme/classes/class.css.php');

require_once(get_template_directory() . '/htheme/classes/class.js.php');

require_once(get_template_directory() . '/htheme/classes/functions.setup.php');

require_once(get_template_directory() . '/htheme/classes/class.frontend.php');

require_once(get_template_directory() . '/htheme/classes/class.meta.php');



#WIDGETS

require_once(get_template_directory() . '/htheme/classes/class.widgets.php');

require_once(get_template_directory() . '/htheme/classes/class.widgets.instagram.php');

require_once(get_template_directory() . '/htheme/classes/class.widgets.follow.php');

require_once(get_template_directory() . '/htheme/classes/class.widgets.recent.php');

require_once(get_template_directory() . '/htheme/classes/class.widgets.banner.php');



#THEME INCLUDES

require_once(get_template_directory() . '/htheme/classes/helper/check.helper.php');

require_once(get_template_directory() . '/htheme/classes/management/activate_theme.class.php');

require_once(get_template_directory() . '/htheme/classes/management/update_theme.class.php');

require_once(get_template_directory() . '/htheme/classes/core/checkin.class.php');

require_once(get_template_directory() . '/htheme/classes/core/update_object.class.php');



#THEME ROOT HELLO FRIDAY

class htheme_start{



    #THEME CONFIG

    private $theme_name = 'hello-friday';

    private $theme_slug = 'hello-friday';

    private $theme_friendly_name = 'Hello Friday';

    private $theme_version = '1.2.11';

    private $api_version = '1.0.0';



    #CLASS VARS

    private $theme_old_version = NULL;

    private $theme_uuid;



    #CONSTRUCT

    public function __construct(){



        #INSTANTIATE

        global $htheme_helper;

        $htheme_helper = new htheme_helper();



        #DETECT IF UPDATE IS REQUIRED

        global $wpdb;

        if($wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE %s", $wpdb->base_prefix."htheme_root")) == $wpdb->base_prefix ."htheme_root") {

            if($this->theme_old_version == NULL){

                $theme_lookup = $wpdb->get_results($wpdb->prepare("SELECT * FROM '". $wpdb->base_prefix ."htheme_root' WHERE 'theme_name' = %s;", $this->theme_name));

                if($theme_lookup){

                    $this->theme_old_version = $theme_lookup[0]->theme_version;

                    $this->theme_uuid = $theme_lookup[0]->theme_uuid; //define theme uuid for check-in

                }

                if(version_compare($this->theme_old_version,$this->theme_version,'<')){

                    $update = new htheme_update_theme($this->theme_name,$this->theme_version,$this->theme_old_version);

                    $update->htheme_update_theme();

                }

            }

        }

        //queue update check

        $checkin = new htheme_checkin($this->theme_slug, $this->theme_name,$this->theme_friendly_name,$this->api_version);

        add_filter('pre_set_site_transient_update_themes', array(&$checkin, 'htheme_check_in'));

    }



    //activate theme

    public function htheme_activate_theme(){

        $activate = new htheme_activate($this->theme_name, $this->theme_version);

        $activate->htheme_setup_theme();

    }



}



#THEME SETUP

$htheme_options = new htheme_options();

$htheme_settings = new htheme_settings();

$htheme_check = new htheme_check();

$htheme_forms = new htheme_forms();

$htheme_backend = new htheme_backend(); //this instance can be used by WP for ajax implementations

$htheme_ajax = new htheme_ajax($htheme_backend, $htheme_forms);

$htheme_frontend = new htheme_frontend();

$htheme_meta = new htheme_meta();



#INITIALISE HELLO FRIDAY CORE

$htheme = new htheme_start();



#INITIALISE ACTIVATION HOOK

add_action('after_switch_theme', array(&$htheme, 'htheme_activate_theme'));



/**

 * TGM ACTIVATION

 */



add_action( 'tgmpa_register', 'htheme_register_required_plugins' );



function htheme_register_required_plugins() {

    /*

     * Array of plugin arrays. Required keys are name and slug.

     * If the source is NOT from the .org repo, then source is also required.

     */

    $plugins = array(

        array(

            'name'               => esc_html__('Hello Friday Utility Plugin', 'hello-friday'), // The plugin name.

            'slug'               => 'hfriday', // The plugin slug (typically the folder name).

            'source'             => get_template_directory() . '/htheme/plugins/hfriday.zip', // The plugin source.

            'required'           => true, // If false, the plugin is only 'recommended' instead of required.

            'version'            => '0.0.4', // E.g. 1.0.0. If set, the active plugin must be this version or higher. If the plugin version is higher than the plugin version installed, the user will be notified to update the plugin.

            'force_activation'   => false, // If true, plugin is activated upon theme activation and cannot be deactivated until theme switch.

            'force_deactivation' => false, // If true, plugin is deactivated upon theme switch, useful for theme-specific plugins.

            'external_url'       => '', // If set, overrides default API URL and points to an external URL.

            'is_callable'        => '', // If set, this callable will be be checked for availability to determine if a plugin is active.

        ),

        array(

            'name'      =>  esc_html__('Contact Form 7', 'hello-friday'),

            'slug'      => 'contact-form-7',

            'required'  => true,

        ),

        array(

            'name'      => esc_html__('Woocommerce', 'hello-friday'),

            'slug'      => 'woocommerce',

            'required'  => false,

        ),

    );

    /*

     * Array of configuration settings. Amend each line as needed.

     *

     * TGMPA will start providing localized text strings soon. If you already have translations of our standard

     * strings available, please help us make TGMPA even better by giving us access to these translations or by

     * sending in a pull-request with .po file(s) with the translations.

     *

     * Only uncomment the strings in the config array if you want to customize the strings.

     */

    $config = array(

        'id'           => 'tgmpa',                 // Unique ID for hashing notices for multiple instances of TGMPA.

        'default_path' => '',                      // Default absolute path to bundled plugins.

        'menu'         => 'tgmpa-install-plugins', // Menu slug.

        'parent_slug'  => 'themes.php',            // Parent menu slug.

        'capability'   => 'edit_theme_options',    // Capability needed to view plugin install page, should be a capability associated with the parent menu used.

        'has_notices'  => true,                    // Show admin notices or not.

        'dismissable'  => true,                    // If false, a user cannot dismiss the nag message.

        'dismiss_msg'  => '',                      // If 'dismissable' is false, this message will be output at top of nag.

        'is_automatic' => false,                   // Automatically activate plugins after installation or not.

        'message'      => '',                      // Message to output right before the plugins table.

    );

    tgmpa( $plugins, $config );

}



/**

 * ALTER POST THUMBNAIL OUTPUT





function htheme_modify_post_thumbnail_html() {



    $id = get_post_thumbnail_id(); // gets the id of the current post_thumbnail (in the loop)

    $src = wp_get_attachment_image_src($id, 'large'); // gets the image url specific to the passed in size (aka. custom image size)

    return $src[0];



}



if(!isset($_GET['post_type'])){

    add_filter('post_thumbnail_html', 'htheme_modify_post_thumbnail_html', 99, 3);

}*/



/**

 * POST EXCERPT

 */



function htheme_new_excerpt_more($more) {

    return '...';

}



add_filter('excerpt_more', 'htheme_new_excerpt_more', 21 );



/**

 * ADD CLASS TO BODY CLASS

 */



function htheme_add_classes($classes){



    $classes[] = esc_attr( 'htheme_basic_class' );



    return $classes;



}



add_filter( 'body_class', 'htheme_add_classes' );



/**

 * REGISTER WIDGET

 */



add_action( 'widgets_init', 'htheme_register_widget' );

function htheme_register_widget() {

    register_widget( 'htheme_widgets' );

    register_widget( 'htheme_widgets_instagram' );

    register_widget( 'htheme_widgets_follow' );

    register_widget( 'htheme_widgets_recent' );

    register_widget( 'htheme_widgets_banner' );

}



/*

 * SET GLOBALS

 */



add_action( 'parse_query', 'htheme_set_globals' );

function htheme_set_globals(){



    global $htheme_global_object, $htheme_frontend, $htheme_is_front_page;



    #SET GLOBAL DATA

    $htheme_global_object = $htheme_frontend->htheme_get_options();



}



add_action( 'wp_head', 'htheme_add_globals' );

function htheme_add_globals(){



    global $post, $htheme_global_archive_page, $htheme_global_home_page, $htheme_global_category_page, $htheme_global_post_ids;

    setup_postdata( $post );



    #SET GLOBAL IS FRONT PAGE VALUE

    if(is_front_page()):

        $htheme_global_home_page = 'htheme_is_home';

    endif;



    if(is_archive()):

        $htheme_global_archive_page = 'htheme_is_archive';

    endif;



    if(is_category()):

        $htheme_global_category_page = 'htheme_is_category';

    endif;



    #GLOBAL IDS

    $GLOBALS['htheme_global_post_ids'] = [];



}



#CUSTOM COMMENTS

function htheme_format_comment($comment, $args, $depth){



    $image =  get_avatar_url( $comment, 'small' );



    ?>



    <li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">

        <div class="htheme_comment_image" style="background-image:url(<?php echo esc_url($image); ?>);"></div>

        <div class="htheme_comment_content">

            <h5 class="htheme_comment_name"><?php printf(esc_html__('%s', 'hello-friday'), get_comment_author_link()) ?></h5>

            <span class="htheme_comment_date"><a class="comment-permalink" href="<?php echo esc_url( htmlspecialchars ( get_comment_link( $comment->comment_ID ) ) ); ?>"><?php printf(esc_html__('%1$s', 'hello-friday'), get_comment_date(), get_comment_time()) ?></a></span>

            <?php if ($comment->comment_approved == '0') : ?>

                <em><?php esc_html_e('Your comment is awaiting moderation.', 'hello-friday') ?></em><br />

            <?php endif; ?>

            <div class="htheme_default_content"><?php comment_text(); ?></div>

            <div class="reply">

                <?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>

            </div>

        </div>

    </li>



    <?php

}



#ALTER TITLES

add_filter( 'get_the_archive_title', function ($title) {

    if ( is_post_type_archive() ) {

         $title = sprintf( esc_html__( '%s', 'hello-friday' ), post_type_archive_title( '', false ) );

    }

    return $title;

});



#WPML POST TRANSLATIONS

function htheme_show_lang_available(){

    if ( function_exists('icl_object_id') ) {

        $languages = icl_get_languages('skip_missing=1');

        if(1 < count($languages)){

        echo '<div class="htheme_post_languages">';

            echo esc_html__('This post is also available in: ', 'hello-friday');

            foreach($languages as $l){

                if(!$l['active']) $langs[] = '<a href="'.esc_url($l['url']).'">'.esc_html($l['translated_name']).'</a>';

            }

            echo join(', ', $langs);

        echo '</div>';

        }

    }

}



#ENABLE EXCERPT

add_action('icl_post_languages', 'htheme_show_lang_available', 10, 3);



#CUSTOM IMAGE UPLOAD FOR CATEGORY

function htheme_add_category_image($tag){

    $htheme_tag_id = $tag->term_id;

    $htheme_cat_meta = get_option( "category_$htheme_tag_id");

    ?>

    <tr class="form-field">

        <th scope="row" valign="top"><label for="cat_Image_url"><?php _e('Category Image Url', 'hello-friday'); ?></label></th>

        <td>

            <input type="text" name="htheme_category_img" id="htheme_category_img" size="3" style="width:60%;" value="<?php echo esc_attr($htheme_cat_meta); ?>"><br />

            <div class="button button-primary htheme_media_uploader" data-connect="htheme_category_img" data-multiple="false" data-size="large"><?php esc_html_e('Upload', 'hello-friday'); ?></div>

        </td>

    </tr>

    <?php

}



#CUSTOM IMAGE ACTION

add_action ( 'edit_category_form_fields', 'htheme_add_category_image');



#SAVE CUSTOM FIELDS FOR CATEGORY

function htheme_save_extra_category_fileds( $term_id ) {

    if ( isset( $_POST['htheme_category_img'] ) ) {

        $htheme_tag_id = $term_id;

        $htheme_cat_meta = get_option( "category_$htheme_tag_id");

        if (isset($_POST['htheme_category_img'])){

            $htheme_cat_meta = $_POST['htheme_category_img'];

        }

        //save the option array

        update_option( "category_$htheme_tag_id", $htheme_cat_meta );

    }

}



add_action ( 'edited_category', 'htheme_save_extra_category_fileds');



#################################

#### WOOCOMMERCE

#################################



remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 ); #REMOVE OPENING DIVS

remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 ); #REMOVE CLOSING DIVS

remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10 ); #REMOVE STANDARD PRODUCT IMAGE

remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20 ); #REMOVE STANDARD PRODUCT IMAGE

remove_action( 'woocommerce_before_subcategory_title', 'woocommerce_subcategory_thumbnail', 10);



function htheme_product_thumbnail_with_all_content(){



    #GLOBALS

    global $product;





    $id = get_post_thumbnail_id(); // gets the id of the current post_thumbnail (in the loop)

    $src = wp_get_attachment_image_src($id, 'large'); // gets the image url specific to the passed in size (aka. custom image size)



    ?>

    <div class="htheme_woo_archive_image" style="background-image:url(<?php echo esc_url($src[0]); ?>)"></div>

    <?php



}



add_action('woocommerce_before_shop_loop_item_title', 'htheme_product_thumbnail_with_all_content', 10 ); #ADD NEW IMAGE AND CONTENT



//CHANGE COLUMNS

add_filter( 'loop_shop_columns', 'wc_loop_shop_columns', 1, 10 );



function wc_loop_shop_columns( $number_columns ) {



    #GLOBALS

    global $product;



    $htheme_blog_sidebar = $GLOBALS['htheme_global_object']['settings']['woocommerce']['shopLayout'];



    #SIDEBAR

    if($htheme_blog_sidebar == 'standard_sidebar' && !is_product()):

        return 3;

    endif;



    return 4;

}



function htheme_cat_thumbnail_with_all_content($category){



    #GLOBALS

    global $product;

    $thumbnail_id = get_woocommerce_term_meta( $category->term_id, 'thumbnail_id', true  );

    $src = wp_get_attachment_image_src( $thumbnail_id, 'large'  );

    if($src):

        ?>

        <div class="htheme_woo_archive_image" style="background-image:url(<?php echo esc_url($src[0]); ?>)"></div>

        <?php

    endif;

}



add_action('woocommerce_before_subcategory_title', 'htheme_cat_thumbnail_with_all_content', 10 ); #ADD NEW IMAGE AND CONTENT



add_filter( 'loop_shop_per_page', 'htheme_change_product_count', 20 );



function htheme_change_product_count($cols){

    $htheme_per_page = $GLOBALS['htheme_global_object']['settings']['woocommerce']['perPage'];

    return intval($htheme_per_page);

}



function htheme_custom_admin_post_thumbnail_html( $content ) {



    $html = '';

    $html .= '<div class="htheme_caution_box htheme_box_yellow htheme_margin_bottom_20">';

        $html .= '<strong>';

        $html .= ''.esc_html__('Recommended image sizes:', 'hello-friday').'';

        $html .= '</strong>';

        $html .= '<br>';

        $html .= ''.esc_html__('Contained width - 1200px', 'hello-friday').'';

        $html .= '<br>';

        $html .= ''.esc_html__('Full width - 2000px', 'hello-friday').'';

    $html .= '</div>';



    return $content = str_replace( __( 'Set featured image', 'hello-friday' ), __( 'Set featured image', 'hello-friday' ) . $html , $content );

}



add_filter( 'admin_post_thumbnail_html', 'htheme_custom_admin_post_thumbnail_html' );
    
asked by anonymous 26.02.2018 / 21:49

0 answers