PluginProbe
Powerkit – Supercharge your WordPress Site / trunk
Powerkit – Supercharge your WordPress Site vtrunk
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 trunk, at modules/basic-elements/helpers/helper-basic-elements.php

75 lines 1.6 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 // Exit if accessed directly.
10 if ( ! defined( 'ABSPATH' ) ) {
11 exit;
12 }
13
14 /**
15 * Register Shortcodes
16 *
17 * @param array $map Shortcode parameters.
18 */
19 function powerkit_basic_shortcodes_register( $map ) {
20 add_filter( 'powerkit_basic_shortcodes_ui_args', function( $sections ) use ( $map ) {
21 $sections[] = $map;
22 return $sections;
23 } );
24 }
25
26 /**
27 * Autoload files in the directory.
28 *
29 * @param string $path Directory path.
30 * @param string $pattern Regex pattern.
31 * @since 1.0.0
32 */
33 function powerkit_basic_shortcodes_autoload( $path, $pattern = false ) {
34 if ( is_dir( $path ) ) {
35 $files = scandir( $path );
36 } else {
37 return false;
38 }
39
40 // loop folders.
41 foreach ( $files as $file ) {
42 $path_file = $path . '/' . basename( $file );
43
44 if ( $pattern && ! preg_match( "/$pattern/", basename( $file ) ) ) {
45 continue;
46 }
47
48 if ( file_exists( $path_file ) && 'index.php' !== $file ) {
49
50 if ( is_dir( $path_file ) && file_exists( $path_file . "/$file.php" ) ) {
51 require_once $path_file . "/$file.php";
52 } elseif ( is_file( $path_file ) && preg_match( '/\.php$/i', $path_file ) ) {
53 require_once $path_file;
54 }
55 }
56 }
57 }
58
59 /**
60 * Clean shortcodes
61 *
62 * @param string $content Post content.
63 * @return string Filtered Post content.
64 */
65 function powerkit_basic_shortcodes_clean( $content ) {
66 $array = array(
67 '<p>[' => '[',
68 ']</p>' => ']',
69 ']<br />' => ']',
70 );
71 $content = strtr( $content, $array );
72 return $content;
73 }
74 add_filter( 'the_content', 'powerkit_basic_shortcodes_clean' );
75