Created
June 20, 2025 12:09
-
-
Save HeyMehedi/796f5e5a7e19368c56d7eecfb36d482a to your computer and use it in GitHub Desktop.
boltaudit_show_more
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| add_shortcode( 'boltaudit_show_more', 'boltaudit_show_more' ); | |
| function boltaudit_show_more( $attr, $smcontent ) { | |
| if ( ! isset( $attr['color'] ) ) { | |
| $attr['color'] = '#cc0000'; | |
| } | |
| if ( ! isset( $attr['list'] ) ) { | |
| $attr['list'] = ''; | |
| } | |
| if ( ! isset( $attr['align'] ) ) { | |
| $attr['align'] = 'left'; | |
| } | |
| if ( ! isset( $attr['more'] ) ) { | |
| $attr['more'] = 'show more'; | |
| } | |
| if ( ! isset( $attr['less'] ) ) { | |
| $attr['less'] = 'show less'; | |
| } | |
| if ( ! isset( $attr['size'] ) ) { | |
| $attr['size'] = '100'; | |
| } | |
| $html = '<div class="show_more">'; | |
| $html .= '<p class="wpsm-show" style="color: ' . $attr['color'] . '; font-size: ' . $attr['size'] . '%' . '; text-align: ' . $attr['align'] . ';">'; | |
| $html .= $attr['list'] . ' ' . $attr['more']; | |
| $html .= '</p><div class="wpsm-content">'; | |
| $html .= do_shortcode( $smcontent ); | |
| $html .= ' <p class="wpsm-hide" style="color: ' . $attr['color'] . '; font-size: ' . $attr['size'] . '%' . '; text-align: ' . $attr['align'] . ';">'; | |
| $html .= $attr['list'] . ' ' . $attr['less']; | |
| $html .= '</p>'; | |
| $html .= '</div></div>'; | |
| $html .= '<style> | |
| .wpsm-show a, | |
| .wpsm-show:active, | |
| .wpsm-show:visited { | |
| cursor:pointer; | |
| text-decoration:none; | |
| font-size:100% | |
| } | |
| .wpsm-show:hover{ | |
| cursor:pointer; | |
| text-decoration:underline | |
| } | |
| .wpsm-hide a, | |
| .wpsm-hide:active, | |
| .wpsm-hide:visited{ | |
| cursor:pointer; | |
| text-decoration:none | |
| } | |
| .wpsm-hide:hover{ | |
| cursor:pointer; | |
| text-decoration:underline | |
| } | |
| .wpsm-content-hide{ | |
| display:none | |
| } | |
| .wpsm-show a, | |
| .wpsm-show:active, | |
| .wpsm-show:visited { | |
| cursor: pointer; | |
| text-decoration: none; | |
| font-size: 100%; | |
| } | |
| .wpsm-show:hover { | |
| cursor: pointer; | |
| text-decoration: underline; | |
| } | |
| .wpsm-hide a, | |
| .wpsm-hide:active, | |
| .wpsm-hide:visited { | |
| cursor: pointer; | |
| text-decoration: none; | |
| } | |
| .wpsm-hide:hover { | |
| cursor: pointer; | |
| text-decoration: underline; | |
| } | |
| .wpsm-content-hide { | |
| display: none; | |
| } | |
| </style>'; | |
| $html .= "<script> | |
| jQuery('.wpsm-content').addClass('wpsm-content-hide') | |
| jQuery('.wpsm-show, .wpsm-hide').removeClass('wpsm-content-hide') | |
| jQuery('.wpsm-show').on('click', function(e) { | |
| jQuery(this).next('.wpsm-content').removeClass('wpsm-content-hide'); | |
| jQuery(this).addClass('wpsm-content-hide'); | |
| e.preventDefault(); | |
| }); | |
| jQuery('.wpsm-hide').on('click', function(e) { | |
| var wpsm = jQuery(this).parent('.wpsm-content'); | |
| wpsm.addClass('wpsm-content-hide'); | |
| wpsm.prev('.wpsm-show').removeClass('wpsm-content-hide'); | |
| e.preventDefault(); | |
| }); | |
| </script>"; | |
| return $html; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment