Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom shortcode buttons #15

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions CleanBuild/functions/acf/acf-shortcodes.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,34 @@ function company_name_func( $atts ){
}
add_shortcode( 'company-name', 'company_name_func' );

function shortcode_button_script()
{
if(wp_script_is("quicktags"))
{
$buttons = array( // Add to this array to add buttons for different shortcodes. Don't forget to create an appropriate callback
array(
'id' => 'company_name_shortcode', // Used as part of the ID for the button
'label' => 'Company Name', // The label of the button
'callback' => 'company_button_callback', // The callback used for inserting the shortcode for this button
),
);
?>
<script type="text/javascript">

<?php foreach($buttons as $button){
$addButton = "QTags.addButton('" . $button['id'] . "', '" . $button['label'] . "', " . $button['callback'] . ");";
echo $addButton;
} ?>

function company_button_callback(){
QTags.insertContent("[company-name]");
}
</script>
<?php
}
}
add_action("admin_print_footer_scripts", "shortcode_button_script");


// COMPANY REG NUMBER SHORTCODE
function company_reg_func( $atts ){
Expand Down
11 changes: 1 addition & 10 deletions CleanBuild/functions/wordpress/site-enqueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// ENQUEUE CUSTOM SCRIPTS
function custom_scripts() {
wp_enqueue_script( 'jq-link', 'https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js', array(), null, true );
//wp_enqueue_script( 'fa-link', 'https://use.fontawesome.com/{CDN ID}.js', array(), null, true );
// wp_enqueue_script( 'slick-link', 'https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.8.1/slick.min.js', array(), null, true );
// wp_enqueue_script( 'backstretch-script', get_stylesheet_directory_uri() . '/js/vendor/backstretch.min.js', array(), null, true );
// wp_enqueue_script( 'fancybox-script', get_stylesheet_directory_uri() . '/js/vendor/fancybox.min.js', array(), null, true );
Expand All @@ -12,18 +13,8 @@ function custom_scripts() {

// ENQUEUE CUSTOM STYLES
function custom_styles() {
// wp_enqueue_style( 'fa-link', '//use.fontawesome.com/releases/v5.0.10/css/all.css', array(), null );
wp_enqueue_style( 'site-style', get_stylesheet_directory_uri() . '/style.css', array(), filemtime( get_stylesheet_directory() . '/style.scss' ), 'all' );
}
add_action( 'wp_enqueue_scripts', 'custom_styles' );

// FILTER FONTAWESOME <STYLE> TO INCLUDE INTEGRITY AND CROSSORIGIN ATTRIBUTES
add_filter( 'style_loader_tag', 'add_fa_init_attributes', 100, 2 );
function add_fa_init_attributes( $html, $handle ) {
if ( 'fa-link' === $handle ) {
$html = str_replace( " type", "integrity='sha384-+d0P83n9kaQMCwj8F4RJB66tzIwOKmrdb46+porD/OvrJ+37WqIM7UoBtwHO6Nlg' crossorigin='anonymous' type", $html );
}
return $html;
}

?>
16 changes: 14 additions & 2 deletions CleanBuild/functions/wordpress/wordpress-custom.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,23 @@ function yoasttobottom() {
}
add_filter( 'wpseo_metabox_prio', 'yoasttobottom');


// DISABLE SRCSET ON EMBEDDED IMAGES
function cb_disable_srcset( $sources ) {
return false;
}
add_filter( 'wp_calculate_image_srcset', 'cb_disable_srcset' );


// HAS CHILDREN FUNCTION
function has_children() {
global $post;
$children = get_pages( array( 'child_of' => $post->ID ) );
return $children ? true : false;
if( count( $children ) == 0 ) {
return false;
} else {
return true;
}
}

?>
?>
2 changes: 1 addition & 1 deletion CleanBuild/scss/_mixins.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Auto prefix
@mixin css($property, $value...) {
@mixin css($property, $value) {
@each $prefix in -webkit-, -moz-, -ms-, -o-, '' {
#{$prefix}#{$property}: $value;
}
Expand Down
Loading