wp_enqueue_style was called incorrectly
-
Am getting this error after activating wordpress debug. Please how do I solve this?
Notice: wp_enqueue_style was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or login_enqueue_scripts hooks. Please see Debugging in WordPress for more information. (This message was added in version 3.3.0.) in /home/tophrotd/public_html/wp-includes/functions.php on line 4773 Notice: Constant DB_COLLATE already defined in /home/tophrotd/public_html/wp-config.php on line 83Below is the files in my function.php
<?php /** * GeneratePress child theme functions and definitions. * * Add your custom PHP in this file. * Only edit this file if you have direct access to it on your server (to fix errors if they happen). */ function generatepress_child_enqueue_scripts() { if ( is_rtl() ) { wp_enqueue_style( 'generatepress-rtl', trailingslashit( get_template_directory_uri() ) . 'rtl.css' ); } } add_action( 'wp_enqueue_scripts', 'generatepress_child_enqueue_scripts', 100 ); wp_enqueue_style ('font-awesome', '//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css', array (), '5.3.1'); function address_mobile_address_bar() { $color = "#dcdee3"; //this is for Chrome, Firefox OS, Opera and Vivaldi echo '<meta name="theme-color" content="'.$color.'">'; //Windows Phone ** echo '<meta name="msapplication-navbutton-color" content="'.$color.'">'; // iOS Safari echo '<meta name="apple-mobile-web-app-capable" content="yes">'; echo '<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">'; } add_action( 'wp_head', 'address_mobile_address_bar' ); add_action( 'wp_footer', 'tu_add_radio_script' ); function tu_add_radio_script() { ?> <script> var slideIndex = 0; carousel(); function carousel() { var i; var x = document.getElementsByClassName("tophits-slider"); for (i = 0; i < x.length; i++) { x[i].style.display = "none"; } slideIndex++; if (slideIndex > x.length) {slideIndex = 1} x[slideIndex-1].style.display = "block"; setTimeout(carousel, 4000); } function addLink() { //Get the selected text and append the extra info var selection = window.getSelection(), pagelink = '<br /><br /> Read more at: ' + document.location.href, copytext = selection + pagelink, newdiv = document.createElement('div'); //hide the newly created container newdiv.style.position = 'absolute'; newdiv.style.left = '-99999px'; //insert the container, fill it with the extended text, and define the new selection document.body.appendChild(newdiv); newdiv.innerHTML = copytext; selection.selectAllChildren(newdiv); window.setTimeout(function () { document.body.removeChild(newdiv); }, 100); } document.addEventListener('copy', addLink); </script> <?php } add_action( 'after_setup_theme', 'tu_add_comment_url_filter' ); function tu_add_comment_url_filter() { add_filter( 'comment_form_default_fields', 'tu_disable_comment_url', 20 ); } function tu_disable_comment_url($fields) { unset($fields['url']); return $fields; } add_filter( 'comment_form_default_fields', 'tu_filter_comment_fields', 20 ); function tu_filter_comment_fields( $fields ) { $commenter = wp_get_current_commenter(); $consent = empty( $commenter['comment_author_email'] ) ? '' : ' checked="checked"'; $fields['cookies'] = '<p class="comment-form-cookies-consent"><input id="wp-comment-cookies-consent" name="wp-comment-cookies-consent" type="checkbox" value="yes"' . $consent . ' />' . '<label for="wp-comment-cookies-consent">Save my name and email in this browser for the next time I will comment on tophits.ng</label></p>'; return $fields; } if ( ! function_exists( 'generate_content_nav' ) ) : /** * Display navigation to next/previous pages when applicable */ function generate_content_nav( $nav_id ) { global $wp_query, $post; // Don't print empty markup on single pages if there's nowhere to navigate. if ( is_single() ) { $previous = ( is_attachment() ) ? get_post( $post->post_parent ) : get_adjacent_post( false, '', true ); $next = get_adjacent_post( false, '', false ); if ( ! $next && ! $previous ) return; } // Don't print empty markup in archives if there's only one page. if ( $wp_query->max_num_pages < 2 && ( is_home() || is_archive() || is_search() ) ) return; $nav_class = ( is_single() ) ? 'post-navigation' : 'paging-navigation'; ?> <nav role="navigation" id="<?php echo esc_attr( $nav_id ); ?>" class="<?php echo $nav_class; ?>"> <h6 class="screen-reader-text"><?php _e( 'Post navigation', 'generate' ); ?></h6> <?php if ( $wp_query->max_num_pages > 1 && ( is_home() || is_archive() || is_search() ) ) : // navigation links for home, archive, and search pages ?> <?php if ( get_next_posts_link() ) : ?> <div class="nav-previous"><span class="prev" title="<?php _e('Previous','generate');?>"><?php next_posts_link( __( 'Older posts', 'generate' ) ); ?></span></div> <?php endif; ?> <?php if ( get_previous_posts_link() ) : ?> <div class="nav-next"><span class="next" title="<?php _e('Next','generate');?>"><?php previous_posts_link( __( 'Newer posts', 'generate' ) ); ?></span></div> <?php endif; if ( function_exists( 'the_posts_pagination' ) ) { the_posts_pagination( array( 'mid_size' => apply_filters( 'generate_pagination_mid_size', 1 ), 'prev_text' => apply_filters( 'generate_previous_link_text', __( '← Previous', 'generatepress' ) ), 'next_text' => apply_filters( 'generate_next_link_text', __( 'Next →', 'generatepress' ) ), ) ); } do_action('generate_paging_navigation'); ?> <?php endif; ?> </nav><!-- #<?php echo esc_html( $nav_id ); ?> --> <?php } endif; // generate_content_nav /****post-tag****/ function asr_tags() { $asrtags = get_the_tags(); foreach($asrtags as $tag){ $string .= '<span class="post-tag"><a class="p-tag" href="'. get_tag_link($tag->term_id) .'">'. $tag->name . '</a></span>' . "\n" ; } return $string; } add_shortcode('asrtags' , 'asr_tags' ); function tophitsbutton_social_sharing_buttons($content) { global $post; if(is_singular() || is_home()){ // Get current page URL $tophitsbuttonURL = urlencode(get_permalink()); // Get current page title $tophitsbuttonTitle = htmlspecialchars(urlencode(html_entity_decode(get_the_title(), ENT_COMPAT, 'UTF-8')), ENT_COMPAT, 'UTF-8'); // $tophitsbuttonTitle = str_replace( ' ', '%20', get_the_title()); // Get Post Thumbnail for pinterest $tophitsbuttonThumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' ); // Construct sharing URL without using any script $twitterURL = 'https://twitter.com/intent/tweet?text='.$tophitsbuttonTitle.'&url='.$tophitsbuttonURL.'&via=tophitsbutton'; $facebookURL = 'https://www.facebook.com/sharer/sharer.php?u='.$tophitsbuttonURL; $googleURL = 'https://plus.google.com/share?url='.$tophitsbuttonURL; $bufferURL = 'https://bufferapp.com/add?url='.$tophitsbuttonURL.'&text='.$tophitsbuttonTitle; $whatsappURL = 'whatsapp://send?text='.$tophitsbuttonTitle . ' ' . $tophitsbuttonURL; $linkedInURL = 'https://www.linkedin.com/shareArticle?mini=true&url='.$tophitsbuttonURL.'&title='.$tophitsbuttonTitle; // Based on popular demand added Pinterest too $pinterestURL = 'https://pinterest.com/pin/create/button/?url='.$tophitsbuttonURL.'&media='.$tophitsbuttonThumbnail[0].'&description='.$tophitsbuttonTitle; // Add sharing button at the end of page/page content $content .= '<!-- Implement your own superfast social sharing buttons without any JavaScript loading. No plugin required. Detailed steps here: http://tophitsbutton.me/1VIxAsz -->'; $content .= '<div class="tophitsbutton-social">'; $content .= '<h5>SHARE ON</h5> <a class="tophitsbutton-link tophitsbutton-twitter" href="'. $twitterURL .'" target="_blank">Twitter</a>'; $content .= '<a class="tophitsbutton-link tophitsbutton-facebook" href="'.$facebookURL.'" target="_blank">Facebook</a>'; $content .= '<a class="tophitsbutton-link tophitsbutton-googleplus" href="'.$googleURL.'" target="_blank">Google+</a>'; $content .= '<a class="tophitsbutton-link tophitsbutton-buffer" href="'.$bufferURL.'" target="_blank">Buffer</a>'; $content .= '<a class="tophitsbutton-link tophitsbutton-whatsapp" href="'.$whatsappURL.'" target="_blank">WhatsApp</a>'; $content .= '<a class="tophitsbutton-link tophitsbutton-linkedin" href="'.$linkedInURL.'" target="_blank">LinkedIn</a>'; $content .= '<a class="tophitsbutton-link tophitsbutton-pinterest" href="'.$pinterestURL.'" data-pin-custom="true" target="_blank">Pin It</a>'; $content .= '</div>'; return $content; }else{ // if not a post/page then don't include sharing button return $content; } }; add_filter( 'the_content', 'tophitsbutton_social_sharing_buttons'); /*****post-tag*****/ /************************************CODE-1*************************************** * @Author: Boutros AbiChedid * @Date: January 16, 2012 * @Websites: http://bacsoftwareconsulting.com/ ; http://blueoliveonline.com/ * @Description: Displays the Number of times Posts are Viewed on Your Blog. * Function: Sets, Tracks and Displays the Count of Post Views (Post View Counter) * Code is browser and JavaScript independent. * @Tested on: WordPress version 3.2.1 *********************************************************************************/ //Set the Post Custom Field in the WP dashboard as Name/Value pair function bac_PostViews($post_ID) { //Set the name of the Posts Custom Field. $count_key = 'post_views_count'; //Returns values of the custom field with the specified key from the specified post. $count = get_post_meta($post_ID, $count_key, true); //If the the Post Custom Field value is empty. if($count == ''){ $count = 0; // set the counter to zero. //Delete all custom fields with the specified key from the specified post. delete_post_meta($post_ID, $count_key); //Add a custom (meta) field (Name/value)to the specified post. add_post_meta($post_ID, $count_key, '0'); return $count . ' View'; //If the the Post Custom Field value is NOT empty. }else{ $count++; //increment the counter by 1. //Update the value of an existing meta key (custom field) for the specified post. update_post_meta($post_ID, $count_key, $count); //If statement, is just to have the singular form 'View' for the value '1' if($count == '1'){ return $count . ' View'; } //In all other cases return (count) Views else { return $count . ' Views'; } } } ?> <?php /*********************************CODE-3******************************************** * @Author: Boutros AbiChedid * @Date: January 16, 2012 * @Websites: http://bacsoftwareconsulting.com/ ; http://blueoliveonline.com/ * @Description: Adds a Non-Sortable 'Views' Columnn to the Post Tab in WP dashboard. * This code requires CODE-1(and CODE-2) as a prerequesite. * Code is browser and JavaScript independent. * @Tested on: WordPress version 3.2.1 ***********************************************************************************/ //Gets the number of Post Views to be used later. function get_PostViews($post_ID){ $count_key = 'post_views_count'; //Returns values of the custom field with the specified key from the specified post. $count = get_post_meta($post_ID, $count_key, true); return $count; } //Function that Adds a 'Views' Column to your Posts tab in WordPress Dashboard. function post_column_views($newcolumn){ //Retrieves the translated string, if translation exists, and assign it to the 'default' array. $newcolumn['post_views'] = __('Views'); return $newcolumn; } //Function that Populates the 'Views' Column with the number of views count. function post_custom_column_views($column_name, $id){ if($column_name === 'post_views'){ // Display the Post View Count of the current post. // get_the_ID() - Returns the numeric ID of the current post. echo get_PostViews(get_the_ID()); } } //Hooks a function to a specific filter action. //applied to the list of columns to print on the manage posts screen. add_filter('manage_posts_columns', 'post_column_views'); //Hooks a function to a specific action. //allows you to add custom columns to the list post/custom post type pages. //'10' default: specify the function's priority. //and '2' is the number of the functions' arguments. add_action('manage_posts_custom_column', 'post_custom_column_views',10,2); ?>Any solution?
The page I need help with: [log in to see the link]
The topic ‘wp_enqueue_style was called incorrectly’ is closed to new replies.
