PluginProbe
Powerkit – Supercharge your WordPress Site / 3.0.0
Powerkit – Supercharge your WordPress Site v3.0.0
3.1.1 3.1.0 3.0.9 3.0.8 trunk 2.2.6 2.2.7 2.2.8 2.2.9 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8 2.3.9 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 All 87 releases
powerkit / modules / basic-elements / helpers / helper-basic-elements.php

helper-basic-elements.php in Powerkit – Supercharge your WordPress Site 3.0.0, at modules/basic-elements/helpers/helper-basic-elements.php

70 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Helpers Social Links
4 *
5 * @package Powerkit
6 * @subpackage Modules/Helper
7 */
8
9 /**
10 * Register Shortcodes
11 *
12 * @param array $map Shortcode parameters.
13 */
14 function powerkit_basic_shortcodes_register( $map ) {
15 add_filter( 'powerkit_basic_shortcodes_ui_args', function( $sections ) use ( $map ) {
16 $sections[] = $map;
17 return $sections;
18 } );
19 }
20
21 /**
22 * Autoload files in the directory.
23 *
24 * @param string $path Directory path.
25 * @param string $pattern Regex pattern.
26 * @since 1.0.0
27 */
28 function powerkit_basic_shortcodes_autoload( $path, $pattern = false ) {
29 if ( is_dir( $path ) ) {
30 $files = scandir( $path );
31 } else {
32 return false;
33 }
34
35 // loop folders.
36 foreach ( $files as $file ) {
37 $path_file = $path . '/' . basename( $file );
38
39 if ( $pattern && ! preg_match( "/$pattern/", basename( $file ) ) ) {
40 continue;
41 }
42
43 if ( file_exists( $path_file ) && 'index.php' !== $file ) {
44
45 if ( is_dir( $path_file ) && file_exists( $path_file . "/$file.php" ) ) {
46 require_once $path_file . "/$file.php";
47 } elseif ( is_file( $path_file ) && preg_match( '/\.php$/i', $path_file ) ) {
48 require_once $path_file;
49 }
50 }
51 }
52 }
53
54 /**
55 * Clean shortcodes
56 *
57 * @param string $content Post content.
58 * @return string Filtered Post content.
59 */
60 function powerkit_basic_shortcodes_clean( $content ) {
61 $array = array(
62 '<p>[' => '[',
63 ']</p>' => ']',
64 ']<br />' => ']',
65 );
66 $content = strtr( $content, $array );
67 return $content;
68 }
69 add_filter( 'the_content', 'powerkit_basic_shortcodes_clean' );
70