Migrating Shortcodes to WordPress
-
John,
You had once suggest I migrate the shortcodes to WordPress and create them there. Since I now only actively use just the toggles and tabs, I did so and these toggles and tabs work fine. However, they still need the Arconix plugin to be activated. I had been hoping to remove a plugin. So somewhere within the shortcodes it must be referencing something created by the main plugin.
Maybe you can easily see what I am missing.
I first remark out Arconix Shortcodes Compatibility Mode and the filters to just add my own js
/* define('ACS_COMPAT', true); */ // Arconix Shortcodes Compatibility Mode // Load arconix-shortcodes-js from protected folder /* add_filter('pre_register_arconix_shortcodes_js', '__return_false'); add_filter('pre_register_arconix_shortcodes_css', '__return_false');*/ /* Remove CSS since I combined it with my main code */ add_action('wp_enqueue_scripts', 'arconix_scripts'); function arconix_scripts() { wp_register_script('arconix-shortcodes-js', 'http://www.mbaprepadvantage.com/wp-content/themes/dynamik-gen/arconix-shortcodes'. '/arconix-shortcodes3.89.min.js', '', '', true); }I then add the 3 shortcodes ported over and these work fine with the WordPress shortcodes assigned to them, but only when the plugin is active and compatibility mode is turned on since I have lopped of the “ac”:
// Shortcodes Ported From Arconix // Toggle Shortcode add_shortcode( 'toggle', 'toggle_shortcode' ); function toggle_shortcode( $atts, $content = null ) { if( wp_script_is( 'arconix-shortcodes-js', 'registered' ) ) wp_enqueue_script( 'arconix-shortcodes-js' ); $defaults = apply_filters( 'arconix_toggle_shortcode_args', array( 'title' => '', 'load' => 'closed', 'css' => '' ) ); extract( shortcode_atts( $defaults, $atts, 'arconix_toggle' ) ); if( $css ) $css = ' ' . sanitize_html_class( $css ); switch ( $load ) { case 'open': $load = 'toggle-open'; $i = 'fa-minus-square'; break; case 'closed': default: $load = 'toggle-closed'; $i = 'fa-plus-square'; break; } $icon = "<i class='fa {$i}'></i>"; $r = '<div class="arconix-toggle-title'. $css . ' ' . $load . '">' . $title . $icon . '</div>'; $r .= '<div class="arconix-toggle-content">' . remove_wpautop( $content ) . '</div>'; return apply_filters( 'arconix_toggle_return', $r ); } // Collective Tabs Shortcode add_shortcode( 'tabs', 'tabs_shortcode' ); function tabs_shortcode( $atts, $content = null ) { if( wp_script_is( 'arconix-shortcodes-js', 'registered' ) ) wp_enqueue_script( 'arconix-shortcodes-js' ); $defaults = apply_filters( 'arconix_tabs_shortcode_args', array( 'style' => 'horizontal', 'id' => 'name', 'css' => '' ) ); extract( shortcode_atts( $defaults, $atts, 'arconix_tabs' ) ); if( $css ) $css = ' ' . sanitize_html_class( $css ); $GLOBALS['tab_count'] = 0; $tabid = 0; do_shortcode( $content ); if( is_array( $GLOBALS['tabs'] ) ) { foreach( $GLOBALS['tabs'] as $tab ) { // Set up tabid based on the id defined above switch( $id ) { case "name": $tabid = sanitize_html_class( $tab['title'] ); break; case "number": $tabid += 1; break; default: break; } $tabs[] = '<li data-arconix-icon="' . $tab['icon'] . '" data-arconix-color="' . $tab['color'] . '" class="arconix-tab tab-' . sanitize_html_class( $tab['title'] ) . '"><a class="" href="#tab-' . $tabid . '">' . $tab['title'] . '</a></li>'; $panes[] = '<div class="arconix-pane pane-' . sanitize_html_class( $tab['title'] ) . '">' . remove_wpautop( $tab['content'] ) . '</div>'; } $r = "\n" . '<div class="arconix-tabs-' . sanitize_html_class( $style ) . $css . '"><ul class="arconix-tabs">' . implode( "\n", $tabs ) . '</ul>' . "\n" . '<div class="arconix-panes">' . implode( "\n", $panes ) . '</div></div>' . "\n"; } // Reset the variables in the event we use multiple tabs on single page $GLOBALS['tabs'] = null; $GLOBALS['tab_count'] = 0; return apply_filters( 'arconix_tabs_return', $r ); } // Individual Tab Shortcode add_shortcode( 'tab', 'tab_shortcode' ); function tab_shortcode( $atts, $content = null ) { $defaults = apply_filters( 'arconix_tab_shortcode_args', array( 'title' => 'Tab', 'icon' => ' ', 'icon_color' => ' ' ) ); extract( shortcode_atts( $defaults, $atts, 'arconix_tab' ) ); $x = $GLOBALS['tab_count']; $GLOBALS['tabs'][$x] = array( 'title' => sprintf( $title, $GLOBALS['tab_count'] ), 'content' => $content, 'icon' => $icon, 'color' => $icon_color ); $GLOBALS['tab_count']++; }Thanks a lot.
The topic ‘Migrating Shortcodes to WordPress’ is closed to new replies.