base_path = trailingslashit( $base_path ); $this->base_url = trailingslashit( $base_url ); require $this->base_path . 'inc/class-cx-controls-base.php'; $this->load_controls(); } /** * Automatically load found conrols * * @return void */ public function load_controls() { foreach ( glob( $this->base_path . 'inc/controls/*.php' ) as $file ) { require $file; } } /** * Register new control instance * * @return object */ public function register_control( $type = 'text', $args = array() ) { $prefix = 'CX_Control_'; $classname = $prefix . str_replace( ' ', '_', ucwords( str_replace( '-', ' ', $type ) ) ); if ( ! class_exists( $classname ) ) { return false; } $instance = new $classname( $args ); $instance->set_base_url( $this->base_url ); return $instance; } } }