0
votes

I've edited a functions.php in the theme folder itself, to make sure it's not overwriting the file I've made an child-theme. I just can't get the function overwrite in my functions.php . I've put the debug-mode on which encounters the following errors. I also tried to give the function another name, it doesn't work.

Hope someone can help me!

wp_enqueue_script was called incorrectly

Fatal error: Cannot redeclare accesspress_pro_bx_slider_cb() (previously >declared in >/home/ersiteweb/domains/ersite.website/public_html/zaliginantwerpen/wp->content/themes/accesspress-pro-child/functions.php:34) in >/home/ersiteweb/domains/ersite.website/public_html/zaliginantwerpen/wp->content/themes/accesspress-pro/inc/accesspress-functions.php on line 651

function accesspress_pro_bx_slider_cb() {

                global $accesspress_pro_options;
                $accesspress_pro_settings = get_option( 'accesspress_pro_options', $accesspress_pro_options );
                $slider_images = $accesspress_pro_settings['slider'];
                $slider_show_pager = $accesspress_pro_settings['slider_show_pager'] == 'yes1' ? 'true' : 'false';
                $slider_show_controls = $accesspress_pro_settings['slider_show_controls'] == 'yes2' ? 'true' : 'false';
                $slider_auto = $accesspress_pro_settings['slider_auto'] == 'yes3' ? 'true' : 'false';

                $count = count($slider_images);
                $total = 0;
                ?>
                    <script type="text/javascript">
                    jQuery(function(){
                    jQuery('.bx-slider').bxSlider({
                    adaptiveHeight : true,
                    pager:<?php echo $slider_show_pager; ?>,
                    controls:<?php echo $slider_show_controls; ?>,
                    mode:'fade',
                    auto :<?php echo $slider_auto; ?>,
                    pause: '<?php echo $accesspress_pro_settings['slider_speed']; ?>',
                    speed: 1000,
                    });
                    });
                    </script>

                    <div class="bx-slider">
                    <?php
                        if(!empty($slider_images )){
                        foreach ($slider_images as $slider_image) {
                        $total++;
                    ?>

                    <div class="slides">
        <img src="<?php echo $slider_image['banner']; ?>">

                    <?php if($accesspress_pro_settings['slider_caption']=='yes4'): ?>
                    <div class="slider-caption">
                    <div class="ak-container">
                    <?php if($slider_image['caption_header']): ?>
                    <div class="title">
                        <div class="hidenow1"><h1><?php the_field('title1_1');?></h1></div>
                        <div class="hidenow1"><h1><?php the_field('title1_1');?></h1></div>
                        <div class="hidenow2"><h1><?php the_field('title1_2');?></h1></div>
                        <div class="hidenow3"><h1><?php the_field('title1_3');?></h1></div>
                        <div class="hidenow4"><h1><?php the_field('title1_4');?></h1></div>
                        <div class="hidenow5"><h1><?php the_field('title1_5');?></h1></div>
                        <div class="hidenow6"><h1><?php the_field('title1_6');?></h1></div>
                        <div class="hidenow7"><h1><?php the_field('title1_7');?></h1></div>
                        <div class="hidenow8"><h1><?php the_field('title1_8');?></h1></div>
                        <div class="hidenow9"><h1><?php the_field('title1_9');?></h1></div>
                        <h1 class="caption-title"><?php echo $slider_image['caption_header']; ?></h1>
                    </div> <!--title -->
                    <?php endif; ?>

                 <?php if($slider_image['caption_desc']): ?>
                     <div class="subtitle">
                    <div class="hidenow1"><p><?php the_field('subtitle1_1');?></p></div>
                    <div class="hidenow2"><p><?php the_field('subtitle1_2');?></p></div>
                    <div class="hidenow3"><p><?php the_field('subtitle1_3');?></p></div>
                    <div class="hidenow4"><p><?php the_field('subtitle1_4');?></p></div>
                    <div class="hidenow5"><p><?php the_field('subtitle1_5');?></p></div>
                    <div class="hidenow6"><p><?php the_field('subtitle1_6');?></p></div>
                    <div class="hidenow7"><p><?php the_field('subtitle1_7');?></p></div>
                    <div class="hidenow8"><p><?php the_field('subtitle1_8');?></p></div>
                    <div class="hidenow9"><p><?php the_field('subtitle1_9');?></p></div>
                 <h1 class="caption-description"><?php echo $slider_image['caption_desc']; ?></h1>
             </div><!--subtitle-->
                <?php endif; ?>

                <?php if(!empty($slider_image['slider_read_more'])) :?>
                <a class="more-link" href="<?php echo $slider_image['slider_read_more_link']; ?>"><?php echo $slider_image['slider_read_more']; ?></a>
                <?php endif; ?>

            </div> <!--akcontainer-->
            </div> <!--slidecaption -->
             <?php  endif; ?>

                </div> <!--slides -->
                                <?php
                                }
                            } ?>
                </div> <!--bxslider -->
                <?php
   } //function


 add_action( 
 'wp_enqueue_scripts','accesspress_pro_sequence_slider','accesspress_pro_se
  quence_slider_cb');
1
if you are adding JavaScript/css then only use wp_enqueue_scripts. because you are add other 2 argument with HTML. so it is wrong. you see the link codex.wordpress.org/Plugin_API/Action_Reference/…Shital Marakana

1 Answers

0
votes

In php you cannot overwrite class. For resolve your error you must to change your function name in file accesspress-function.php or in the file functions.php if you want to change it.

In the accesspress-function.php modify:

if (!function_exists('accesspress_pro_bx_slider_cb')) {
  function accesspress_pro_bx_slider_cb() {
    .........
  }
}

Also i invite you to read This guide to functions wordpress child theme