Apply Online Shortcodes

Below, you’ll find a detailed guide on how to add the Apply Online Shortcodes to your WordPress website, including their parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Apply Online Plugin shortcodes not to show or not to work correctly.

Before starting, here is an overview of the Apply Online Plugin and the shortcodes it provides:

Plugin Icon
ApplyOnline – Application Form Builder and Manager

"ApplyOnline – Application Form Builder and Manager is a dynamic plugin that simplifies the creation and management of online application forms on your WordPress site."

★★★★✩ (40) Active Installs: 5000+ Tested with: 6.3.2 PHP Version: 5.2.4
Included Shortcodes:
  • [link]
  • [aol]
  • [aol_ad]
  • [aol_form]
  • [aol_filters]
  • [aol_features]

Apply Online [link] Shortcode

The ApplyOnline plugin shortcode ‘link’ creates a hyperlink. It accepts three parameters: ‘href’ for the URL, ‘title’ for the link text, and ‘target’ for link behavior.

Shortcode: [link]

Parameters

Here is a list of all possible link shortcode parameters and attributes:

  • href – The URL the link will redirect to when clicked.
  • title – The display text for the link on the webpage.
  • target – Specifies where to open the linked document, default is new tab.

Examples and Usage

Basic example – A simple usage of the shortcode to create a link with a specified URL and title. The link will open in a new tab due to the default ‘_blank’ target attribute.

[link href="https://www.example.com" title="Visit Example"]

Advanced examples

1. Using the shortcode to create a link with a specified URL, title, and target attribute. In this case, the link will open in the same tab due to the ‘_self’ target attribute.

[link href="https://www.example.com" title="Visit Example" target="_self"]

2. Using the shortcode to create a link without specifying the title. The default title ‘Title is missing’ will be used.

[link href="https://www.example.com" target="_self"]

3. Using the shortcode without specifying the href attribute. The default href ‘Link is missing’ will be used.

[link title="Visit Example" target="_self"]

Note: The shortcode will not render properly if both href and title attributes are missing.

PHP Function Code

In case you have difficulties debugging what causing issues with [link] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('link', 'aol_links_shortcode');

Shortcode PHP function:

function aol_links_shortcode( $atts ) {
	$a = shortcode_atts( array(
            'href' => __('Link is missing', 'ApplyOnline'),
            'title' => __('Title is missing', 'ApplyOnline'),
            'target' => '_blank',
            
	), $atts );

        return '<a href="'.$a['href'].'" target="'.$a['target'].'">'.$a['title'].'</a>';
	//return "foo = {$a['foo']}";
}

Code file location:

apply-online/apply-online/includes/applyonline-functions.php

Apply Online [aol] Shortcode

The Apply-Online plugin shortcode ‘aol’ is designed to generate an archive of ads. It allows customization of ad display and filtering based on specific parameters. This shortcode fetches ads from the database, applies filters, and displays them in a defined structure. It also enables a search feature for users to find specific ads. The ‘aol’ shortcode is quite flexible, allowing control over the number of ads, inclusion or exclusion of specific ads, and the style of the list. Furthermore, it enables the setting of an author parameter and controlling the display of ad excerpts. In summary, the ‘aol’ shortcode is a powerful tool for managing and displaying ad archives in a user-friendly manner.

Shortcode: [aol]

Parameters

Here is a list of all possible aol shortcode parameters and attributes:

  • ads – Identifier of the ad to be displayed (Deprecated since 2.2.3)
  • include – Replaces ‘ads’ attribute to specify included ads
  • exclude – Specifies the ads to be excluded from display
  • excerpt – Option to display the excerpt of the ad
  • display – Determines how the ad will be displayed, ‘full’ or ‘list’
  • list-style – Specifies the style of the list, ‘ul’ or ‘ol’
  • count – Specifies the number of ads to be displayed
  • filter – Option to filter the ads to be displayed
  • type – Type of the ad to be displayed
  • author – Specifies the author of the ad

Examples and Usage

Basic example – Display all ads in an unordered list format

[aol display="list" list-style="ul" /]

Advanced examples

Display a specific type of ad, exclude certain ads, and limit the number of ads shown.

[aol type="job" exclude="3,7,9" count="5" /]

Display ads with a specific author, include only certain ads, and disable the filter option.

[aol author="1" include="2,4,6" filter="no" /]

Display ads in a full format, show the excerpt, and specify the post type.

[aol display="full" excerpt="yes" type="ad" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [aol] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'aol', array($this, 'aol') ); //archive of ads.

Shortcode PHP function:

function aol( $atts ) {
            $archive_wraper_classes = apply_filters('aol_archive_wrapper_classes', array('aol-ad-outer-wrapper'));
            $wraper_classes = apply_filters('aol_ad_wrapper_classes', array('aol-ad-inner-wrapper'));
            //$title_wrapper = apply_filters('aol_ad_title_wrapper', 'div');
            $title_classes = apply_filters('aol_ad_title_wrapper_classes', array('panel-heading'));
            $body_classes = apply_filters('aol_ad_body_wrapper_classes', array('panel-body'));
            $thumb_wrapper = apply_filters('aol_ad_thumb_wrapper', 'div');
            $thumb_classes= apply_filters('aol_ad_thumb_classes', array('aol-thumbnail', 'pull-md-left', 'center-sm-block'));
            $footer_classes = apply_filters('aol_ad_footer_wrapper_classes', array('panel-footer'));
            
            $order = apply_filters('aol_grid_element_order', array('title', 'body_start', 'meta', 'thumbnail', 'excerpt', 'body_close', 'footer'));
            $a = shortcode_atts( array(
                'ads' => '', //Depricated since 2.2.3
                'include' => '', //Replaced ads attribute.
                'exclude'  => '',
                'excerpt' => 'yes',
                'display'    => 'full',
                'list-style' => 'ul',
                'count' => '-1',
                'filter' => 'yes',
                'type'  => 'ad',
                'author' => null
                ), $atts, 'aol' );

            $lstyle = ($a['list-style'] == 'ol') ? 'ol' : 'ul';
            $args = array(
                'posts_per_page'=> $a['count'],
                'post_type'     =>'aol_'.$a['type'],
                'author'    => $a['author'],
                'exclude'   => empty($a['exclude']) ? array() : explode(',',$a['exclude']),
                //'include'   => empty($a['include']) ? array() : explode(',',$a['include']),
                'include'   => empty($a['ads']) ? array() : explode(',',$a['ads']), // Depricated since version 2.5
            );
            /*
            if( !(empty($a['ads']) and empty($a['include'])) ){
                $a['show_filter'] = 'no';
            }
             * 
             */
            //Get list of taxanomies
            $taxes = get_object_taxonomies('aol_'.$a['type']);
            $args['s'] = $search_keyword = isset($_REQUEST['aol_seach_keyword']) ? sanitize_text_field($_REQUEST['aol_seach_keyword']) : NULL;
            $args['tax_query'] = array();
            foreach($taxes as $tax){
                $tax = substr($tax, 7);
                if(isset($_REQUEST[$tax]) AND $_REQUEST[$tax] != NULL) {
                    $args['tax_query'][] = array('taxonomy' => "aol_ad_$tax", 'terms'    => array((int)$_REQUEST[$tax]));
                }
            }

            //query_posts( $args );
            //global $post; 
            $args = apply_filters('aol_pre_get_posts', $args);
            $posts = get_posts($args);

            add_filter( 'excerpt_more', array($this, 'aol_excerpt_more') );
            //$show_filter = get_option('aol_show_filter', 1);
            $filters = aol_ad_cpt_filters($a['type']);
            $filter_count = count($filters);
            ob_start();
            do_action('aol_before_shortcode', $a, $filters);
            if(!(empty($filters) OR $a['filter'] == 'no' )){
                    echo '<div class="well well-lg">'; //Started well
                        echo '<form method="post" class="form-horizontal" id="aol_'.esc_attr($a['type']).'_form" action="#aol_'.esc_attr($a['type']).'_form">';
                            echo '<div class="form-group">'; //1st row Started'
                            //$col_count = $filter_count < 4 ? 12/($filter_count+1) : 3;
                            $col_count = floor(12/($filter_count));
                            //$offset = in_array($col_count, array(5,7,9)) ? 'aol-md-offset-1' : NULL;
                            //elseif($col_count == 5) 
                            $i = 0;
                            foreach ($filters as $key => $filter){
                                $key = sanitize_key($key);
                                //$Fclass = ((isset($_REQUEST['filter']) AND $_REQUEST['filter']) == 'aol_ad_'. $key) ? 'selected' : NULL;
                                echo '<div class="aol-md-'.$col_count.'">';
                                    echo '<select name="'.esc_attr($key).'" class="aol-filter-select form-control"><option value="">'. sprintf(_x('%s - All', 'Filter Dropdown', 'ApplyOnline'), sanitize_text_field( __($filter['plural'], 'ApplyOnline') ) ).'</option>';
                                    $args = array(
                                        'taxonomy' => 'aol_ad_'. $key,
                                        'hide_empty' => true,
                                    );
                                    $terms = get_terms($args);
                                    foreach ($terms as $term){
                                        $selected = (isset($_REQUEST[$key]) AND $term->term_id == (int)$_REQUEST[$key]) ? 'selected="selected"': NULL;
                                        echo '<option value="'.(int)$term->term_id.'" '.$selected.'>'.sanitize_text_field($term->name).'</option>';
                                    }
                                    echo '</select>'; 
                                echo '</div>';
                                $i++;
                            }
                            echo '</div>'; //Ended 1st row
                        echo '<div class="form-group">'; //2nd row started
                        echo '<div class="aol-md-10"><input type="text" name="aol_seach_keyword" class="form-control" placeholder="'.__('Search Keyword', 'ApplyOnline').'" value="'.$search_keyword.'"></div>';
                        echo '<div class="aol-md-2"><button class="fusion-button button btn btn-info btn-block aol-filter-button">'.__('Filter', 'ApplyOnline').'</button></div>';
                        echo '</div></form>'; //2nd row closed, form closed 
                    echo '</div>'; //Ended Well
            }
            if(!empty($posts)):
                if($a['display'] == 'list') echo "<$lstyle>";
                do_action('aol_before_archive');
                echo '<div class="'. esc_attr(implode(' ', $archive_wraper_classes)).'">';
                $post_count = 0;
                foreach($posts as $post): setup_postdata($post);
                    $wrapper_inner_classes = apply_filters('aol_ad_inner_wrapper_classes', array('panel', 'panel-default'), $post);
                    /* Getting Post Status*/
                    $timestamp = (int)get_post_meta($post->ID, '_aol_ad_closing_date', true);
                    $timestamp = apply_filters('aol_ad_closing_date', $timestamp, $post);
                    if( $timestamp == 0 OR $timestamp > time() ) $status = 'open';
                    else $status = 'closed';
                    /* END Getting Post Status*/
                    
                    $terms = get_terms(array('object_ids' => $post->ID, 'hide_empty' => TRUE, 'taxonomy' => aol_sanitize_taxonomies($filters)));
                    
                    if($a['display'] == 'list'): echo '<li>'. apply_filters('aol_shortcode_list', '<a href="'.get_the_permalink($post).'">'.$post->post_title.'</a>').'</li>';
                    else:
                        do_action('aol_before_ad', $post_count, $post->post_count);
                        echo '<div class="'. esc_attr(implode(' ', $wraper_classes)).' aol_ad_'.$post->ID.'">';
                            echo '<div class="'. esc_attr( implode(' ', $wrapper_inner_classes) ).' '.$status.'">';
                            foreach($order as $index):
                                switch ($index):
                                    case 'title':
                                        $output = apply_filters('aol_shortcode_title', $post->post_title, $post, $title_classes);
                                        echo '<div class="'. esc_attr( implode(' ', $title_classes) ).'">'.$output.'</div>';
                                        break;

                                    case 'body_start' :
                                        echo '<div class="'.esc_attr( implode(' ', $body_classes) ).'">';
                                        do_action('aol_shortcode_before_body');
                                        break;

                                    case 'thumbnail' :
                                        if(has_post_thumbnail($post))  echo get_the_post_thumbnail($post->ID, apply_filters('aol_ad_thumbnail_size', 'thumbnail') , array('class' => implode(' ', $thumb_classes), 'title' => $post->post_title, 'alt' => $post->post_title));
                                        break;

                                    case 'meta' :
                                        echo apply_filters('aol_ad_meta', NULL, $post);
                                        break;

                                    case 'body_close':
                                        $body = array(
                                            'excerpt' => get_the_excerpt($post),
                                            'readmore' => sprintf(
                                                    '<a href="%s" ><button class="%s">%s</button></a>',
                                                    get_the_permalink($post),
                                                    'fusion-button button read-more btn btn-info',
                                                    __( 'Read More', 'ApplyOnline' )
                                                    )
                                            );
                                        $body = apply_filters('aol_shortcode_body', $body, $post);
                                        do_action('aol_shortcode_before_body', $post);
                                        if($a['excerpt'] != 'no') echo '<p>'.$body['excerpt'].'</p>';
                                        echo '<div class="clearfix"></div>';
                                        echo apply_filters('aol_shortcode_button', $body['readmore']);
                                        do_action('aol_shortocde_after_body', $post);
                                        echo "</div>"; //Boody Wrapper
                                        break;

                                    case 'footer':
                                        if(empty($terms) or empty($filters)) break;
                                        echo '<div class="'. esc_attr( implode(' ', $footer_classes) ).'">';
                                        echo apply_filters('aol_shortcode_footer', $this->aol_filters_terms($terms, $post->ID), $post, $terms);
                                        echo "</div>";
                                    break;
                                endswitch;
                            endforeach;
                        echo "</div></div>"; //Closing inner & outer wrapers.
                        do_action('aol_after_ad', $post_count, $post->post_count);
                        if($a['display'] == 'list') echo "</$lstyle>";
                    endif; //End aol display check
                    $post_count++;
                endforeach; 
                echo "</div>"; //Outer Wrapper
                do_action('aol_after_archive', $post);
            else: echo get_option('aol_not_found_alert', 'Sorry, we could not find what you were looking for.');
            endif;
            wp_reset_postdata();
            $html = apply_filters('aol_shortcode', ob_get_clean());
            return '<div class="aol-archive aol-wrapper">'.$html.'</div>';
        }

Code file location:

apply-online/apply-online/public/class-applyonline-public.php

Apply Online [aol_ad] Shortcode

The ‘aol_ad’ shortcode from Apply-Online plugin is used to display a single advertisement with an application form. It accepts an ‘id’ parameter to fetch and display the specific ad post content. If an ‘id’ is provided, this shortcode will return the ad’s content along with the application form.

Shortcode: [aol_ad]

Parameters

Here is a list of all possible aol_ad shortcode parameters and attributes:

  • id – The unique code that identifies a specific ad and form.

Examples and Usage

Basic example – Display a single ad with its associated form by referencing the ad’s ID.

[aol_ad id=1 /]

Advanced examples:

Display a single ad with its associated form by referencing the ad’s ID. If the ad with the given ID is not found, it will not return anything.

[aol_ad id=5 /]

Display a single ad with its associated form by referencing the ad’s ID. If the ad with the given ID is not found, it will not return anything. This is an example of using a higher ID value, showing that the shortcode can handle a wide range of ID values.

[aol_ad id=100 /]

Please note that the ‘id’ attribute in the shortcode corresponds to the ID of the ad as stored in your WordPress database. You need to ensure that you use the correct ID for the ad you wish to display.

PHP Function Code

In case you have difficulties debugging what causing issues with [aol_ad] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'aol_ad', array($this, 'aol_ad') ); //Single ad with form.

Shortcode PHP function:

function aol_ad( $atts ) {
            $a = shortcode_atts( array(
                'id'   => NULL,
            ), $atts );

            if(isset($a['id'])) {
                $id = $a['id'];
                $post = get_post($id);
                return $post->post_content. aol_form($a['id']);
            }
        }

Code file location:

apply-online/apply-online/public/class-applyonline-public.php

Apply Online [aol_form] Shortcode

The AOL Form shortcode is a tool that displays a single ad form on a specific page. The shortcode checks if it’s used on the Ads Page, where an ID isn’t required. If an ID is present, it returns the form for the corresponding ad.

Shortcode: [aol_form]

Parameters

Here is a list of all possible aol_form shortcode parameters and attributes:

  • id – Identifies the particular ad form

Examples and Usage

Basic example – Showcases the usage of the shortcode to display a single ad form by referencing its ID.

[aol_form id=1 /]

Advanced examples

Displays a single ad form by referencing its ID. If the ID is not specified, the shortcode will attempt to display the form associated with the current post, provided it is of the ‘aol_ad’ type.

[aol_form /]

Using the shortcode to display a single ad form by referencing its ID. If the ID is not found, the shortcode will attempt to display the form associated with the current post, provided it is of the ‘aol_ad’ type.

[aol_form id=2 /]

It’s important to note that the ‘id’ parameter in the shortcode corresponds to the ID of the ad form you wish to display. If the ‘id’ parameter is not specified, the shortcode will attempt to display the form associated with the current post, provided it is of the ‘aol_ad’ type.

PHP Function Code

In case you have difficulties debugging what causing issues with [aol_form] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'aol_form', array($this, 'aol_form') ); //Single ad form only.

Shortcode PHP function:

function aol_form( $atts ){
            global $post;
            $id = is_singular('aol_ad') ? $post->ID: NULL;
            $a = shortcode_atts( array(
                //Check if shortcode is called on the Ads Page, ID is not required in that case.
                //@todo extend post type to all ad types.
                'id'   => $id,
            ), $atts );
            
            if(isset($a['id']))    return aol_form($a['id']);
        }

Code file location:

apply-online/apply-online/public/class-applyonline-public.php

Apply Online [aol_filters] Shortcode

The ‘aol_filters’ shortcode from Apply-Online plugin is used to display ad filters. It fetches ad-related terms and displays them in a formatted manner. This shortcode supports all ad types and allows customization of its display style. It retrieves the ad ID from the global post object if not provided. It then fetches the filters for the ad and the related terms. The terms are then displayed within a ‘div’ element with the class ‘aol_meta’. If there are multiple terms for the same taxonomy, they are grouped together under the taxonomy label. This ensures a clean and organized display of ad filters.

Shortcode: [aol_filters]

Parameters

Here is a list of all possible aol_filters shortcode parameters and attributes:

  • style – determines the format of the output, default is ‘csv’
  • ad – specifies the ID of the ad to be displayed, default is 0 (shows the current post’s ad)

Examples and Usage

Basic example – Displaying the AOL filters by referencing the ad ID.

[aol_filters ad=1 /]

By using this shortcode, you can display the AOL filters for a specific ad. The shortcode uses the ad’s ID to fetch and display the appropriate filters.

Advanced Examples

Displaying the AOL filters in a different style by specifying the ‘style’ attribute.

[aol_filters style='list' ad=1 /]

In this example, the AOL filters for a specific ad are displayed in a list format. This is achieved by setting the ‘style’ attribute to ‘list’.

Displaying the AOL filters for the current post if the ‘ad’ attribute is not specified.

[aol_filters /]

This shortcode will display the AOL filters for the current post. It does this by using the global $post variable to get the ID of the current post if the ‘ad’ attribute is not specified.

PHP Function Code

In case you have difficulties debugging what causing issues with [aol_filters] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'aol_filters', array($this, 'aol_filters') ); //Single ad form only.

Shortcode PHP function:

function aol_filters($atts){
            //@ad support for all ad types.
            //if(!is_singular('aol_ad')) return;
            
            $a = shortcode_atts( array(
                'style'   => 'csv',
                'ad'      => 0,
            ), $atts );
            if(empty($a['ad'])){
                global $post;
                $post_id = $post->ID;
            } else {
                    $post_id = (int)$a['ad'];
            }

            $filters = aol_ad_cpt_filters(get_post_type());
            $terms = get_terms(array('object_ids' => $post_id, 'hide_empty' => TRUE, 'taxonomy' => aol_sanitize_taxonomies($filters)));

            ob_start();
            echo '<div class="aol_meta">' ;
            echo $this->aol_filters_terms($terms, $post_id);
            echo '</div>';
            return ob_get_clean();
            
            ob_start();
            $terms = get_terms(array('object_ids' => $post_id, 'orderby' => 'term_group', 'hide_empty' => TRUE, 'taxonomy' => aol_sanitize_taxonomies($filters)));
            echo '<div class="aol_meta">' ;
                if( !(empty($terms) or empty($filters)) ):
                    $tax = NULL;
                    foreach ($terms as $term){
                            $title = NULL;
                            $separator = ', ';
                        if($tax != $term->taxonomy) {
                            $taxObj = get_taxonomy($term->taxonomy);
                            $pad = empty($tax) ? NULL : ' &nbsp;';
                            $title = $pad.'<h4 class="aol-ad-taxonomy">'.$taxObj->label.': </h4>';
                        }
                        echo $title.'<span>'.$term->name.$separator.'</span>'; 
                        $tax = $term->taxonomy;
                    } 
                endif;
            echo '</div>';
            return ob_get_clean();
        }

Code file location:

apply-online/apply-online/public/class-applyonline-public.php

Apply Online [aol_features] Shortcode

The AOL Features shortcode is a tool provided by the Apply-Online plugin in WordPress. It allows users to display features in different styles. This shortcode takes a ‘style’ attribute, which can be set to ‘table’ by default. It returns the features in the chosen style format.

Shortcode: [aol_features]

Parameters

Here is a list of all possible aol_features shortcode parameters and attributes:

  • style – determines the display style of the features, default is ‘table’

Examples and Usage

Basic example – The following shortcode illustrates how to use the ‘aol_features’ shortcode with the default ‘style’ parameter set to ‘table’.

[aol_features]

Advanced examples

Changing the style parameter – Here, we’re using the ‘aol_features’ shortcode, but we’re changing the ‘style’ parameter to ‘list’. This will change the way the features are displayed on the front-end.

[aol_features style='list']

Using multiple parameters – This example demonstrates how to use the ‘aol_features’ shortcode with multiple parameters. We’re still setting the ‘style’ parameter, but we’re also adding a ‘category’ parameter. This will limit the features that are displayed to a specific category.

[aol_features style='list' category='category-slug']

PHP Function Code

In case you have difficulties debugging what causing issues with [aol_features] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'aol_features', array($this, 'aol_features') );

Shortcode PHP function:

function aol_features($atts){
            $a = shortcode_atts( array(
                'style'   => 'table',
            ), $atts );
            
            return aol_features($a['style']);
        }

Code file location:

apply-online/apply-online/public/class-applyonline-public.php

Conclusion

Now that you’ve learned how to embed the Apply Online Plugin shortcodes, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *