• Resolved twaiiiin

    (@monsieurt)


    Hi,

    I copy-pasted the [aesop_chapter] shortcode in my theme to override it, and it works ! I added several parameters to the shortcode to modify the HTML/CSS output.

    BUT. How could I add news fields in the Aesop Settings Generator for “Chapters” to configure my news parameters ?

    I can do it in a text editor, but it would be better with fields.

    Thank you, you are the best ! 🙂

    https://ww.wp.xz.cn/plugins/aesop-story-engine/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Michael Beil

    (@michaelbeil)

    You can find the way we set this up here in our sample addon and do something similar: https://github.com/AesopInteractive/sample-addon/blob/master/class.settings.php

    Thread Starter twaiiiin

    (@monsieurt)

    Thank you for your answer.

    Unless I am mistaken this “sample-addon” adds new components to ASE but I’m trying to add options to a default shortcode… or maybe I missing something.

    Plugin Author Michael Beil

    (@michaelbeil)

    That was a link to the class settings for a component which is what you’re looking for.

    Thread Starter twaiiiin

    (@monsieurt)

    Thank you very much for your help ! I finally found a solution.

    For people interested about it: I added this code in a plugin.
    Feel free to tell me if there is a big mistake…

    /**
    *
    *	This class is responsible for adding custom options in the default "Chapter Component" used by both Aesop Story Engine and Lasso
    *
    */
    class ChapterAddOptionsInComponentSettings {
    
    	function __construct(){
    
    		// if you arent using Lasso then this filter isnt needed
    		add_filter('lasso_custom_options',		array($this,'options'));
    
    		// if you arent using aesop story engine then this filter isnt needed
    		add_filter('aesop_avail_components',	array($this, 'options') );
    	}
    	/**
    	*
    	*	This adds our options into the generator for both Lasso and Aesop Story Engine
    	*
    	*/
    	function options($shortcodes) {
    
            $custom = array(
    			'chapter' => array(
    				'atts' 	=> array(
    					'bgattachement'		=> array(
    						'type'		=> 'select',
    						'values' 	=> array(
    							array(
    								'value' => 'cover',
    								'name'	=> __('Cover','aesop-core')
    							),
    							array(
    								'value' => 'fixed',
    								'name'	=> __('Fixed','aesop-core')
    							)
    						),
    						'default'	=> 'cover',
    						'desc'		=> __('Background Attachement','aesop-core'),
    						'tip'		=> __('If set to cover, the background image of the chapter will be as large as the browser window.','aesop-core')
    					)
    				)
    			)
    		);
    
            /**
            *
            *	This merges our new options with the already existing options in the component
            *	Tip: Use array_merge( $shortcodes, $custom ); to replace the existing options in the component with your own.
            */
            $customoptions = array_merge_recursive($shortcodes, $custom);
    
    		return $customoptions;
    
    	}
    }
    new ChapterAddOptionsInComponentSettings;
    Thread Starter twaiiiin

    (@monsieurt)

    For people interested about it: this is my custom component-heading.php file with the new bgattachement option in the HTML/CSS output:

    /**
     	* Creates a fullscreen chapter heading
     	*
     	* @since    1.0.0
    */
    if (!function_exists('aesop_chapter_shortcode')){
    
    	function aesop_chapter_shortcode($atts, $content = null) {
    		$defaults = array(
    			'title' 	=> '',
    			'subtitle' 	=> '',
    			'bgtype' 	=> 'img',
                'bgattachement' 	=> 'cover',
    			'img' 		=> '',
    			'full'		=> ''
    		);
    
    		$atts = apply_filters('aesop_chapter_defaults',shortcode_atts($defaults, $atts));
    
    		// let this be used multiple times
    		static $instance = 0;
    		$instance++;
    		$unique = sprintf('%s-%s',get_the_ID(), $instance);
    
    		ob_start();
    
    		$inline_styles 		= 'background-color:#000000; background-repeat:repeat; background-position:center center; background-attachment:'.esc_attr($atts['bgattachement']).';';
    		$styles 			= apply_filters( 'aesop_chapter_img_styles_'.esc_attr( $unique ), esc_attr( $inline_styles ) );
    
    		$img_style 		 	= 'img' == $atts['bgtype'] && $atts['img'] ? sprintf('style="	background-image:url(\'%s\');%s"', esc_url( $atts['img'] ), $styles) : 'style="height:auto;" ';
    		$img_style_class 	= 'img' == $atts['bgtype'] && $atts['img'] ? 'has-chapter-image' : 'no-chapter-image';
    
    		$video_chapter_class = 'video' == $atts['bgtype'] ? 'aesop-video-chapter' : null;
    
    		$full_class = 'on' == $atts['full'] ? 'aesop-chapter-full' : false;
            $bgfixed_class = 'fixed' == $atts['bgattachement'] ? 'aesop-chapter-fixed' : false;
            $bgcover_class = 'cover' == $atts['bgattachement'] ? 'aesop-chapter-cover' : false;
    
    		do_action('aesop_chapter_before'); //action
    
    			?>
    			<div id="chapter-unique-<?php echo $unique;?>" <?php echo aesop_component_data_atts( 'chapter', $unique, $atts );?> class="aesop-article-chapter-wrap default-cover <?php echo $video_chapter_class;?> aesop-component <?php echo $img_style_class;?> <?php echo $full_class;?> <?php echo $bgfixed_class;?> <?php echo $bgcover_class;?>" >
    
    				<?php do_action('aesop_chapter_inside_top'); //action ?>
    
    				<div class="aesop-article-chapter clearfix" <?php echo $img_style;?> >
    
    					<h2 class="aesop-cover-title" itemprop="title" data-title="<?php echo esc_attr( $atts['title'] );?>">
    						<span><?php echo esc_html( $atts['title'] );?></span>
    
    						<?php if ( $atts['subtitle'] ) { ?>
    							<small><?php echo esc_html( $atts['subtitle'] );?></small>
    						<?php } ?>
    					</h2>
    
    					<?php if ( 'video' == $atts['bgtype'] ) { ?>
    					<div class="video-container">
    						<?php echo do_shortcode('[video src="'.esc_url( $atts['img'] ).'" loop="on" autoplay="on"]'); ?>
    					</div>
    					<?php } ?>
    
    				</div>
    
    				<?php do_action('aesop_chapter_inside_bottom'); //action ?>
    
    			</div>
    		<?php
    
    		do_action('aesop_chapter_after'); //action
    
    		return ob_get_clean();
    	}
    }
Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘add new admin fields with shortcode override’ is closed to new replies.