├── .gitignore
├── lib
└── codestar-framework
│ ├── index.php
│ ├── fields
│ ├── index.php
│ ├── heading
│ │ └── heading.php
│ ├── subheading
│ │ └── subheading.php
│ ├── content
│ │ └── content.php
│ ├── submessage
│ │ └── submessage.php
│ ├── notice
│ │ └── notice.php
│ ├── callback
│ │ └── callback.php
│ ├── text
│ │ └── text.php
│ ├── fieldset
│ │ └── fieldset.php
│ ├── color_group
│ │ └── color_group.php
│ ├── palette
│ │ └── palette.php
│ ├── switcher
│ │ └── switcher.php
│ ├── backup
│ │ └── backup.php
│ ├── textarea
│ │ └── textarea.php
│ ├── gallery
│ │ └── gallery.php
│ ├── color
│ │ └── color.php
│ ├── accordion
│ │ └── accordion.php
│ ├── datetime
│ │ └── datetime.php
│ ├── tabbed
│ │ └── tabbed.php
│ ├── date
│ │ └── date.php
│ ├── code_editor
│ │ └── code_editor.php
│ ├── number
│ │ └── number.php
│ ├── button_set
│ │ └── button_set.php
│ ├── spinner
│ │ └── spinner.php
│ ├── sortable
│ │ └── sortable.php
│ ├── image_select
│ │ └── image_select.php
│ ├── sorter
│ │ └── sorter.php
│ ├── slider
│ │ └── slider.php
│ ├── icon
│ │ └── icon.php
│ ├── upload
│ │ └── upload.php
│ ├── link
│ │ └── link.php
│ ├── wp_editor
│ │ └── wp_editor.php
│ ├── radio
│ │ └── radio.php
│ ├── link_color
│ │ └── link_color.php
│ ├── map
│ │ └── map.php
│ ├── checkbox
│ │ └── checkbox.php
│ ├── repeater
│ │ └── repeater.php
│ ├── dimensions
│ │ └── dimensions.php
│ └── media
│ │ └── media.php
│ ├── languages
│ ├── ar.mo
│ ├── az.mo
│ ├── ja.mo
│ ├── th.mo
│ ├── vi.mo
│ ├── bn_BD.mo
│ ├── de_DE.mo
│ ├── es_ES.mo
│ ├── fr_FR.mo
│ ├── hi_IN.mo
│ ├── id_ID.mo
│ ├── it_IT.mo
│ ├── ko_KR.mo
│ ├── ne_NP.mo
│ ├── nl_NL.mo
│ ├── pl_PL.mo
│ ├── pt_PT.mo
│ ├── ru_RU.mo
│ ├── tr_TR.mo
│ └── zh_CN.mo
│ ├── views
│ ├── footer.php
│ ├── documentation.php
│ ├── support.php
│ ├── quickstart.php
│ ├── header.php
│ ├── free-vs-premium.php
│ └── welcome.php
│ ├── assets
│ ├── images
│ │ ├── checkerboard.png
│ │ ├── wp-plugin-logo.svg
│ │ └── wp-logo.svg
│ ├── scss
│ │ ├── partials
│ │ │ ├── _navmenu.scss
│ │ │ ├── _widget.scss
│ │ │ ├── _profile.scss
│ │ │ ├── _taxonomy.scss
│ │ │ ├── _responsive.scss
│ │ │ ├── _helper.scss
│ │ │ └── _customizer.scss
│ │ └── style.scss
│ └── js
│ │ └── gutenberg.js
│ ├── functions
│ ├── sanitize.php
│ ├── walker.php
│ ├── helpers.php
│ └── validate.php
│ ├── codestar-framework.php
│ ├── samples
│ ├── taxonomy-options.php
│ ├── comment-options.php
│ ├── profile-options.php
│ └── nav-menu-options.php
│ └── classes
│ └── widget-options.class.php
├── src
├── Models
│ ├── Config
│ │ └── NoFile.php
│ ├── Model.php
│ ├── ModelFactory.php
│ └── Taxonomy.php
├── Infrastructure
│ ├── Container
│ │ ├── ContainerAssembler.php
│ │ ├── CanRegister.php
│ │ ├── Instantiator.php
│ │ ├── Invalid.php
│ │ ├── Container.php
│ │ └── FailedToMakeInstance.php
│ ├── Service
│ │ ├── Processable.php
│ │ ├── Service.php
│ │ ├── App.php
│ │ ├── Assembly.php
│ │ ├── Actionable.php
│ │ └── Conditional.php
│ └── Plugin
│ │ ├── Activateable.php
│ │ ├── Deactivateable.php
│ │ ├── Registerable.php
│ │ └── Plugin.php
├── Features
│ ├── FeatureA
│ │ ├── SaltusFeatureA.php
│ │ └── FeatureA.php
│ ├── RememberTabs
│ │ ├── RememberTabs.php
│ │ └── SaltusRememberTabs.php
│ ├── SingleExport
│ │ ├── SingleExport.php
│ │ └── SaltusSingleExport.php
│ ├── AdminCols
│ │ └── AdminCols.php
│ ├── AdminFilters
│ │ ├── AdminFilters.php
│ │ └── WalkerTaxonomyDropdown.php
│ ├── Settings
│ │ ├── Settings.php
│ │ └── CodestarSettings.php
│ ├── Duplicate
│ │ └── Duplicate.php
│ ├── Meta
│ │ ├── Meta.php
│ │ └── CodestarMeta.php
│ └── DragAndDrop
│ │ ├── DragAndDrop.php
│ │ └── UpdateMenuDragAndDrop.php
├── Exception
│ └── SaltusFrameworkThrowable.php
└── Modeler.php
├── assets
└── Feature
│ ├── DragAndDrop
│ ├── order.css
│ └── order.js
│ └── RememberTabs
│ └── rememberTabs.js
├── composer.json
└── phpcs.xml
/.gitignore:
--------------------------------------------------------------------------------
1 | vendor/
2 | .vscode
3 | .DS_Store
4 | **/.DS_Store
--------------------------------------------------------------------------------
/lib/codestar-framework/index.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/lib/codestar-framework/languages/bn_BD.mo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SaltusDev/saltus-framework/HEAD/lib/codestar-framework/languages/bn_BD.mo
--------------------------------------------------------------------------------
/lib/codestar-framework/languages/de_DE.mo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SaltusDev/saltus-framework/HEAD/lib/codestar-framework/languages/de_DE.mo
--------------------------------------------------------------------------------
/lib/codestar-framework/languages/es_ES.mo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SaltusDev/saltus-framework/HEAD/lib/codestar-framework/languages/es_ES.mo
--------------------------------------------------------------------------------
/lib/codestar-framework/languages/fr_FR.mo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SaltusDev/saltus-framework/HEAD/lib/codestar-framework/languages/fr_FR.mo
--------------------------------------------------------------------------------
/lib/codestar-framework/languages/hi_IN.mo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SaltusDev/saltus-framework/HEAD/lib/codestar-framework/languages/hi_IN.mo
--------------------------------------------------------------------------------
/lib/codestar-framework/languages/id_ID.mo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SaltusDev/saltus-framework/HEAD/lib/codestar-framework/languages/id_ID.mo
--------------------------------------------------------------------------------
/lib/codestar-framework/languages/it_IT.mo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SaltusDev/saltus-framework/HEAD/lib/codestar-framework/languages/it_IT.mo
--------------------------------------------------------------------------------
/lib/codestar-framework/languages/ko_KR.mo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SaltusDev/saltus-framework/HEAD/lib/codestar-framework/languages/ko_KR.mo
--------------------------------------------------------------------------------
/lib/codestar-framework/languages/ne_NP.mo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SaltusDev/saltus-framework/HEAD/lib/codestar-framework/languages/ne_NP.mo
--------------------------------------------------------------------------------
/lib/codestar-framework/languages/nl_NL.mo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SaltusDev/saltus-framework/HEAD/lib/codestar-framework/languages/nl_NL.mo
--------------------------------------------------------------------------------
/lib/codestar-framework/languages/pl_PL.mo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SaltusDev/saltus-framework/HEAD/lib/codestar-framework/languages/pl_PL.mo
--------------------------------------------------------------------------------
/lib/codestar-framework/languages/pt_PT.mo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SaltusDev/saltus-framework/HEAD/lib/codestar-framework/languages/pt_PT.mo
--------------------------------------------------------------------------------
/lib/codestar-framework/languages/ru_RU.mo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SaltusDev/saltus-framework/HEAD/lib/codestar-framework/languages/ru_RU.mo
--------------------------------------------------------------------------------
/lib/codestar-framework/languages/tr_TR.mo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SaltusDev/saltus-framework/HEAD/lib/codestar-framework/languages/tr_TR.mo
--------------------------------------------------------------------------------
/lib/codestar-framework/languages/zh_CN.mo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SaltusDev/saltus-framework/HEAD/lib/codestar-framework/languages/zh_CN.mo
--------------------------------------------------------------------------------
/lib/codestar-framework/assets/images/checkerboard.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SaltusDev/saltus-framework/HEAD/lib/codestar-framework/assets/images/checkerboard.png
--------------------------------------------------------------------------------
/src/Models/Config/NoFile.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
If you are new to Codestar Framework, here is a step-by-step plan for getting started.
4 |
5 | We are provide support forum for premium version users. You can join to support forum for submit any question after purchasing. Free version users support is limited on github.
4 |
5 | '. $this->field['content'] .'
';
22 |
23 | }
24 |
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/lib/codestar-framework/fields/notice/notice.php:
--------------------------------------------------------------------------------
1 | field['style'] ) ) ? $this->field['style'] : 'normal';
20 |
21 | echo ( ! empty( $this->field['content'] ) ) ? ''. $this->field['content'] .'
' : '';
22 |
23 | }
24 |
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/lib/codestar-framework/fields/callback/callback.php:
--------------------------------------------------------------------------------
1 | field['function'] ) && is_callable( $this->field['function'] ) ) {
20 |
21 | $args = ( isset( $this->field['args'] ) ) ? $this->field['args'] : null;
22 |
23 | call_user_func( $this->field['function'], $args );
24 |
25 | }
26 |
27 | }
28 |
29 | }
30 | }
31 |
32 |
--------------------------------------------------------------------------------
/lib/codestar-framework/functions/walker.php:
--------------------------------------------------------------------------------
1 | ID, $item, $depth, $args );
21 | $custom_fields = ob_get_clean();
22 |
23 | $output .= preg_replace( '/(?=<(fieldset|p)[^>]+class="[^"]*field-move)/', $custom_fields, $html );
24 |
25 | }
26 |
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/lib/codestar-framework/assets/images/wp-logo.svg:
--------------------------------------------------------------------------------
1 | ';
22 |
23 | foreach ( $this->field['fields'] as $field ) {
24 |
25 | $field_id = ( isset( $field['id'] ) ) ? $field['id'] : '';
26 | $field_default = ( isset( $field['default'] ) ) ? $field['default'] : '';
27 | $field_value = ( isset( $this->value[$field_id] ) ) ? $this->value[$field_id] : $field_default;
28 | $unique_id = ( ! empty( $this->unique ) ) ? $this->unique .'['. $this->field['id'] .']' : $this->field['id'];
29 |
30 | CSF::field( $field, $field_value, $unique_id, 'field/fieldset' );
31 |
32 | }
33 |
34 | echo '
';
35 |
36 | echo $this->field_after();
37 |
38 | }
39 |
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/lib/codestar-framework/assets/scss/partials/_profile.scss:
--------------------------------------------------------------------------------
1 | /**
2 | * 06. Profile
3 | */
4 | .csf-profile-options{
5 |
6 | > h2 > .fa {
7 | padding-right: 7px;
8 | }
9 |
10 | > .csf-field{
11 | max-width: 750px;
12 | padding: 15px 0;
13 | border-top: none !important;
14 |
15 | > .csf-title{
16 | width: 200px;
17 |
18 | h4{
19 | font-size: 14px;
20 | font-weight: 600;
21 | line-height: 1.3;
22 | display: inline-block;
23 | vertical-align: middle;
24 | }
25 | }
26 |
27 | > .csf-fieldset{
28 | width: calc(100% - 220px);
29 |
30 | > .csf-help{
31 | top: -15px;
32 | right: -5px;
33 | }
34 | }
35 | }
36 |
37 | > .csf-field-heading{
38 | font-size: 1.1em;
39 | }
40 |
41 | > .csf-field-subheading{
42 | font-size: 12px;
43 | }
44 |
45 | > .csf-field-subheading,
46 | > .csf-field-heading{
47 | margin: 10px 0;
48 | padding: 15px !important;
49 | border: 1px solid #ddd;
50 | }
51 |
52 | > .csf-field-submessage{
53 | margin: 20px 0;
54 |
55 | .csf-submessage{
56 | padding: 10px;
57 | border-left-width: 1px;
58 | border-left-style: solid;
59 | border-right-width: 1px;
60 | border-right-style: solid;
61 | }
62 | }
63 |
64 | > .csf-field-notice{
65 | background-color: transparent;
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/src/Infrastructure/Container/Invalid.php:
--------------------------------------------------------------------------------
1 | field['options'] ) ) ? $this->field['options'] : array();
20 |
21 | echo $this->field_before();
22 |
23 | if ( ! empty( $options ) ) {
24 | foreach ( $options as $key => $option ) {
25 |
26 | $color_value = ( ! empty( $this->value[$key] ) ) ? $this->value[$key] : '';
27 | $default_attr = ( ! empty( $this->field['default'][$key] ) ) ? ' data-default-color="'. esc_attr( $this->field['default'][$key] ) .'"' : '';
28 |
29 | echo '
19 |
20 |
Welcome to Codestar Framework v
21 |
22 |
A Simple and Lightweight WordPress Option Framework for Themes and Plugins
23 |
24 |
Demo
25 |
26 |
27 |
28 |
32 |
Codestar Framework
33 |
v
34 |
35 |
36 |
37 | $link ) {
40 |
41 | if ( CSF::$premium && $key === 'free-vs-premium' ) { continue; }
42 |
43 | $activate = ( $section === $key ) ? ' nav-tab-active' : '';
44 |
45 | echo ''. esc_attr( $link ) .' ';
46 |
47 | }
48 |
49 | ?>
50 |
51 |
--------------------------------------------------------------------------------
/src/Features/DragAndDrop/UpdateMenuDragAndDrop.php:
--------------------------------------------------------------------------------
1 | $id ) {
47 | $id_arr[ absint( $position ) ] = absint( $id );
48 | }
49 | }
50 |
51 | // Deals with paginated view
52 | $id_list = implode( ',', array_map( 'absint', $id_arr ) );
53 | $query = "SELECT menu_order FROM $wpdb->posts WHERE ID IN (%s)";
54 | $query_prepared = sprintf( $query, $id_list );
55 |
56 | // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
57 | $query_result = $wpdb->get_results( $query_prepared );
58 | $menu_order_list = [];
59 | foreach ( $query_result as $result ) {
60 | $menu_order_list[] = $result->menu_order;
61 | }
62 |
63 | sort( $menu_order_list );
64 |
65 | // This should be just one request using query()
66 | foreach ( $id_arr as $position => $id ) {
67 | if ( ! isset( $menu_order_list[ $position ] ) ) {
68 | continue;
69 | }
70 | $data = array( 'menu_order' => $menu_order_list[ $position ] );
71 | $where = array( 'ID' => absint( $id ) );
72 | $wpdb->update(
73 | $wpdb->posts,
74 | $data,
75 | $where
76 | );
77 | }
78 |
79 | do_action( 'dda_update_menu_order' );
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/lib/codestar-framework/fields/datetime/datetime.php:
--------------------------------------------------------------------------------
1 | true,
21 | );
22 |
23 | $settings = ( ! empty( $this->field['settings'] ) ) ? $this->field['settings'] : array();
24 |
25 | if ( ! isset( $settings['noCalendar'] ) ) {
26 | $defaults['dateFormat'] = 'm/d/Y';
27 | }
28 |
29 | $settings = wp_parse_args( $settings, $defaults );
30 |
31 | echo $this->field_before();
32 |
33 | if ( ! empty( $this->field['from_to'] ) ) {
34 |
35 | $args = wp_parse_args( $this->field, array(
36 | 'text_from' => esc_html__( 'From', 'csf' ),
37 | 'text_to' => esc_html__( 'To', 'csf' ),
38 | ) );
39 |
40 | $value = wp_parse_args( $this->value, array(
41 | 'from' => '',
42 | 'to' => '',
43 | ) );
44 |
45 | echo '
'. esc_attr( $args['text_from'] ) .' field_attributes() .' data-type="from" /> ';
46 | echo '
'. esc_attr( $args['text_to'] ) .' field_attributes() .' data-type="to" /> ';
47 |
48 | } else {
49 |
50 | echo '
field_attributes() .'/>';
51 |
52 | }
53 |
54 | echo '
';
55 |
56 | echo $this->field_after();
57 |
58 | }
59 |
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/lib/codestar-framework/fields/tabbed/tabbed.php:
--------------------------------------------------------------------------------
1 | field_before();
22 |
23 | echo '
';
24 | foreach ( $this->field['tabs'] as $key => $tab ) {
25 |
26 | $tabbed_icon = ( ! empty( $tab['icon'] ) ) ? '
' : '';
27 | $tabbed_active = ( empty( $key ) ) ? 'csf-tabbed-active' : '';
28 |
29 | echo '
'. $tabbed_icon . esc_attr( $tab['title'] ) .' ';
30 |
31 | }
32 | echo '
';
33 |
34 | echo '
';
35 | foreach ( $this->field['tabs'] as $key => $tab ) {
36 |
37 | $tabbed_hidden = ( ! empty( $key ) ) ? ' hidden' : '';
38 |
39 | echo '
';
40 |
41 | foreach ( $tab['fields'] as $field ) {
42 |
43 | if ( in_array( $field['type'], $unallows ) ) { $field['_notice'] = true; }
44 |
45 | $field_id = ( isset( $field['id'] ) ) ? $field['id'] : '';
46 | $field_default = ( isset( $field['default'] ) ) ? $field['default'] : '';
47 | $field_value = ( isset( $this->value[$field_id] ) ) ? $this->value[$field_id] : $field_default;
48 | $unique_id = ( ! empty( $this->unique ) ) ? $this->unique .'['. $this->field['id'] .']' : $this->field['id'];
49 |
50 | CSF::field( $field, $field_value, $unique_id, 'field/tabbed' );
51 |
52 | }
53 |
54 | echo '
';
55 |
56 | }
57 | echo '
';
58 |
59 | echo $this->field_after();
60 |
61 | }
62 |
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/lib/codestar-framework/samples/nav-menu-options.php:
--------------------------------------------------------------------------------
1 | 'serialize'
13 | ) );
14 |
15 | //
16 | // Create a section
17 | //
18 | CSF::createSection( $prefix, array(
19 | 'fields' => array(
20 |
21 | //
22 | // A text field
23 | //
24 | array(
25 | 'id' => 'opt-text',
26 | 'type' => 'text',
27 | 'title' => 'Text',
28 | ),
29 |
30 | array(
31 | 'id' => 'opt-textarea',
32 | 'type' => 'textarea',
33 | 'title' => 'Textarea',
34 | 'help' => 'The help text of the field.',
35 | ),
36 |
37 | array(
38 | 'id' => 'opt-upload',
39 | 'type' => 'upload',
40 | 'title' => 'Upload',
41 | ),
42 |
43 | array(
44 | 'id' => 'opt-icon',
45 | 'type' => 'icon',
46 | 'title' => 'Icon',
47 | ),
48 |
49 | array(
50 | 'id' => 'opt-switcher',
51 | 'type' => 'switcher',
52 | 'title' => 'Switcher',
53 | 'label' => 'The label text of the switcher.',
54 | ),
55 |
56 | array(
57 | 'id' => 'opt-color',
58 | 'type' => 'color',
59 | 'title' => 'Color',
60 | 'default' => '#3498db',
61 | ),
62 |
63 | array(
64 | 'id' => 'opt-checkbox',
65 | 'type' => 'checkbox',
66 | 'title' => 'Checkbox',
67 | 'label' => 'The label text of the checkbox.',
68 | ),
69 |
70 | array(
71 | 'id' => 'opt-radio',
72 | 'type' => 'radio',
73 | 'title' => 'Radio',
74 | 'options' => array(
75 | 'yes' => 'Yes, Please.',
76 | 'no' => 'No, Thank you.',
77 | ),
78 | 'default' => 'yes',
79 | ),
80 |
81 | array(
82 | 'id' => 'opt-select',
83 | 'type' => 'select',
84 | 'title' => 'Select',
85 | 'placeholder' => 'Select an option',
86 | 'options' => array(
87 | 'opt-1' => 'Option 1',
88 | 'opt-2' => 'Option 2',
89 | 'opt-3' => 'Option 3',
90 | ),
91 | ),
92 |
93 | )
94 | ) );
95 |
--------------------------------------------------------------------------------
/lib/codestar-framework/fields/date/date.php:
--------------------------------------------------------------------------------
1 | 'mm/dd/yy',
21 | );
22 |
23 | $settings = ( ! empty( $this->field['settings'] ) ) ? $this->field['settings'] : array();
24 | $settings = wp_parse_args( $settings, $default_settings );
25 |
26 | echo $this->field_before();
27 |
28 | if ( ! empty( $this->field['from_to'] ) ) {
29 |
30 | $args = wp_parse_args( $this->field, array(
31 | 'text_from' => esc_html__( 'From', 'csf' ),
32 | 'text_to' => esc_html__( 'To', 'csf' ),
33 | ) );
34 |
35 | $value = wp_parse_args( $this->value, array(
36 | 'from' => '',
37 | 'to' => '',
38 | ) );
39 |
40 | echo '
'. esc_attr( $args['text_from'] ) .' field_attributes() .'/> ';
41 | echo '
'. esc_attr( $args['text_to'] ) .' field_attributes() .'/> ';
42 |
43 | } else {
44 |
45 | echo '
field_attributes() .'/>';
46 |
47 | }
48 |
49 | echo '
';
50 |
51 | echo $this->field_after();
52 |
53 | }
54 |
55 | public function enqueue() {
56 |
57 | if ( ! wp_script_is( 'jquery-ui-datepicker' ) ) {
58 | wp_enqueue_script( 'jquery-ui-datepicker' );
59 | }
60 |
61 | }
62 |
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/lib/codestar-framework/fields/code_editor/code_editor.php:
--------------------------------------------------------------------------------
1 | 2,
24 | 'lineNumbers' => true,
25 | 'theme' => 'default',
26 | 'mode' => 'htmlmixed',
27 | 'cdnURL' => $this->cdn_url . $this->version,
28 | );
29 |
30 | $settings = ( ! empty( $this->field['settings'] ) ) ? $this->field['settings'] : array();
31 | $settings = wp_parse_args( $settings, $default_settings );
32 |
33 | echo $this->field_before();
34 | echo '
';
35 | echo $this->field_after();
36 |
37 | }
38 |
39 | public function enqueue() {
40 |
41 | $page = ( ! empty( $_GET[ 'page' ] ) ) ? sanitize_text_field( wp_unslash( $_GET[ 'page' ] ) ) : '';
42 |
43 | // Do not loads CodeMirror in revslider page.
44 | if ( in_array( $page, array( 'revslider' ) ) ) { return; }
45 |
46 | if ( ! wp_script_is( 'csf-codemirror' ) ) {
47 | wp_enqueue_script( 'csf-codemirror', esc_url( $this->cdn_url . $this->version .'/lib/codemirror.min.js' ), array( 'csf' ), $this->version, true );
48 | wp_enqueue_script( 'csf-codemirror-loadmode', esc_url( $this->cdn_url . $this->version .'/addon/mode/loadmode.min.js' ), array( 'csf-codemirror' ), $this->version, true );
49 | }
50 |
51 | if ( ! wp_style_is( 'csf-codemirror' ) ) {
52 | wp_enqueue_style( 'csf-codemirror', esc_url( $this->cdn_url . $this->version .'/lib/codemirror.min.css' ), array(), $this->version );
53 | }
54 |
55 | }
56 |
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/lib/codestar-framework/assets/scss/partials/_taxonomy.scss:
--------------------------------------------------------------------------------
1 | /**
2 | * 06. Taxonomy
3 | */
4 | .csf-taxonomy{
5 | max-width: 95%;
6 |
7 | > .csf-field{
8 | border-top: none !important;
9 | }
10 |
11 | > .csf-field-heading{
12 | font-size: 1.1em;
13 | padding: 20px !important;
14 | border: 1px solid #ddd;
15 | }
16 |
17 | > .csf-field-subheading{
18 | font-size: 12px;
19 | padding: 15px !important;
20 | border: 1px solid #ddd;
21 | }
22 |
23 | > .csf-field-submessage{
24 |
25 | .csf-submessage{
26 | padding: 15px;
27 | border-left-width: 1px;
28 | border-left-style: solid;
29 | border-right-width: 1px;
30 | border-right-style: solid;
31 | }
32 | }
33 |
34 | > .csf-field-notice{
35 | background-color: transparent;
36 | }
37 |
38 | .csf-section-title{
39 | display: block;
40 | padding: 15px ;
41 | background-color: #f9f9f9;
42 | border: 1px solid #e5e5e5;
43 | box-shadow: 0 1px 1px rgba(0,0,0,0.04);
44 | }
45 | }
46 |
47 | .csf-taxonomy-add-fields{
48 |
49 | > .csf-field{
50 | padding: 8px 0;
51 |
52 | > .csf-title{
53 | float: none;
54 | width: 100%;
55 | padding: 2px 2px 4px 0;
56 |
57 | h4{
58 | font-size: 12px;
59 | font-weight: normal;
60 | }
61 | }
62 |
63 | > .csf-fieldset{
64 | float: none;
65 | width: 100%;
66 |
67 | > .csf-help{
68 | right: -5px;
69 | }
70 | }
71 | }
72 |
73 | + p.submit{
74 | margin-top: 0;
75 | }
76 | }
77 |
78 | .csf-taxonomy-edit-fields{
79 |
80 | > .csf-field{
81 | padding: 20px 0;
82 |
83 | > .csf-title{
84 | width: 200px;
85 |
86 | h4{
87 | font-size: 14px;
88 | font-weight: 600;
89 | line-height: 1.3;
90 | display: inline-block;
91 | vertical-align: middle;
92 | }
93 | }
94 |
95 | > .csf-fieldset{
96 | width: calc(100% - 220px);
97 |
98 | > .csf-help{
99 | top: -5px;
100 | right: -5px;
101 | }
102 | }
103 | }
104 |
105 | > .csf-field-submessage{
106 | margin: 20px 0;
107 | }
108 |
109 | > .csf-field-subheading,
110 | > .csf-field-heading{
111 | margin: 20px 0;
112 | border: 1px solid #ddd;
113 | }
114 | }
115 |
--------------------------------------------------------------------------------
/lib/codestar-framework/fields/number/number.php:
--------------------------------------------------------------------------------
1 | field, array(
20 | 'min' => 'any',
21 | 'max' => 'any',
22 | 'step' => 'any',
23 | 'unit' => '',
24 | ) );
25 |
26 | echo $this->field_before();
27 | echo '
';
28 | echo ' field_attributes() .' min="'. esc_attr( $args['min'] ) .'" max="'. esc_attr( $args['max'] ) .'" step="'. esc_attr( $args['step'] ) .'"/>';
29 | echo ( ! empty( $args['unit'] ) ) ? ''. esc_attr( $args['unit'] ) .' ' : '';
30 | echo '
';
31 | echo $this->field_after();
32 |
33 | }
34 |
35 | public function output() {
36 |
37 | $output = '';
38 | $elements = ( is_array( $this->field['output'] ) ) ? $this->field['output'] : array_filter( (array) $this->field['output'] );
39 | $important = ( ! empty( $this->field['output_important'] ) ) ? '!important' : '';
40 | $mode = ( ! empty( $this->field['output_mode'] ) ) ? $this->field['output_mode'] : 'width';
41 | $unit = ( ! empty( $this->field['unit'] ) ) ? $this->field['unit'] : 'px';
42 |
43 | if ( ! empty( $elements ) && isset( $this->value ) && $this->value !== '' ) {
44 | foreach ( $elements as $key_property => $element ) {
45 | if ( is_numeric( $key_property ) ) {
46 | if ( $mode ) {
47 | $output = implode( ',', $elements ) .'{'. $mode .':'. $this->value . $unit . $important .';}';
48 | }
49 | break;
50 | } else {
51 | $output .= $element .'{'. $key_property .':'. $this->value . $unit . $important .'}';
52 | }
53 | }
54 | }
55 |
56 | $this->parent->output_css .= $output;
57 |
58 | return $output;
59 |
60 | }
61 |
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/src/Features/AdminFilters/WalkerTaxonomyDropdown.php:
--------------------------------------------------------------------------------
1 | 'parent',
22 | 'id' => 'term_id',
23 | ];
24 |
25 | /**
26 | * @var string
27 | */
28 | public $field = null;
29 |
30 | /**
31 | * Class constructor.
32 | *
33 | * @param array $args Optional arguments.
34 | */
35 | public function __construct( $args = null ) {
36 | if ( $args && isset( $args['field'] ) ) {
37 | $this->field = $args['field'];
38 | }
39 | }
40 |
41 | /**
42 | * Start the element output.
43 | *
44 | * @param string $output Passed by reference. Used to append additional content.
45 | * @param object $object Term data object.
46 | * @param int $depth Depth of term in reference to parents.
47 | * @param array $args Optional arguments.
48 | * @param int $current_object_id Current object ID.
49 | */
50 | public function start_el( &$output, $object, $depth = 0, $args = [], $current_object_id = 0 ) {
51 | $pad = str_repeat( ' ', $depth * 3 );
52 | $tax = get_taxonomy( $args['taxonomy'] );
53 |
54 | if ( $this->field ) {
55 | $value = $object->{$this->field};
56 | } else {
57 | $value = $tax->hierarchical ? $object->term_id : $object->name;
58 | }
59 |
60 | if ( empty( $object->term_id ) && ! $tax->hierarchical ) {
61 | $value = '';
62 | }
63 |
64 | $cat_name = apply_filters( 'list_cats', $object->name, $object );
65 | $output .= "\t
term_id, (array) $args['selected'] ) ) {
70 | $output .= ' selected="selected"';
71 | }
72 |
73 | $output .= '>';
74 | $output .= $pad . esc_html( $cat_name );
75 |
76 | if ( $args['show_count'] ) {
77 | $output .= ' (' . esc_html( number_format_i18n( $object->count ) ) . ')';
78 | }
79 |
80 | $output .= " \n";
81 | }
82 |
83 | }
--------------------------------------------------------------------------------
/lib/codestar-framework/fields/button_set/button_set.php:
--------------------------------------------------------------------------------
1 | field, array(
20 | 'multiple' => false,
21 | 'options' => array(),
22 | 'query_args' => array(),
23 | ) );
24 |
25 | $value = ( is_array( $this->value ) ) ? $this->value : array_filter( (array) $this->value );
26 |
27 | echo $this->field_before();
28 |
29 | if ( isset( $this->field['options'] ) ) {
30 |
31 | $options = $this->field['options'];
32 | $options = ( is_array( $options ) ) ? $options : array_filter( $this->field_data( $options, false, $args['query_args'] ) );
33 |
34 | if ( is_array( $options ) && ! empty( $options ) ) {
35 |
36 | echo '
';
53 |
54 | } else {
55 |
56 | echo ( ! empty( $this->field['empty_message'] ) ) ? esc_attr( $this->field['empty_message'] ) : esc_html__( 'No data available.', 'csf' );
57 |
58 | }
59 |
60 | }
61 |
62 | echo $this->field_after();
63 |
64 | }
65 |
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/lib/codestar-framework/fields/spinner/spinner.php:
--------------------------------------------------------------------------------
1 | field, array(
20 | 'max' => 100,
21 | 'min' => 0,
22 | 'step' => 1,
23 | 'unit' => '',
24 | ) );
25 |
26 | echo $this->field_before();
27 |
28 | echo '
field_attributes( array( 'class' => 'csf-input-number' ) ) .' data-min="'. esc_attr( $args['min'] ) .'" data-max="'. esc_attr( $args['max'] ) .'" data-step="'. esc_attr( $args['step'] ) .'" data-unit="'. esc_attr( $args['unit'] ) .'" step="any" />
';
29 |
30 | echo $this->field_after();
31 |
32 | }
33 |
34 | public function enqueue() {
35 |
36 | if ( ! wp_script_is( 'jquery-ui-spinner' ) ) {
37 | wp_enqueue_script( 'jquery-ui-spinner' );
38 | }
39 |
40 | }
41 |
42 | public function output() {
43 |
44 | $output = '';
45 | $elements = ( is_array( $this->field['output'] ) ) ? $this->field['output'] : array_filter( (array) $this->field['output'] );
46 | $important = ( ! empty( $this->field['output_important'] ) ) ? '!important' : '';
47 | $mode = ( ! empty( $this->field['output_mode'] ) ) ? $this->field['output_mode'] : 'width';
48 | $unit = ( ! empty( $this->field['unit'] ) ) ? $this->field['unit'] : 'px';
49 |
50 | if ( ! empty( $elements ) && isset( $this->value ) && $this->value !== '' ) {
51 | foreach ( $elements as $key_property => $element ) {
52 | if ( is_numeric( $key_property ) ) {
53 | if ( $mode ) {
54 | $output = implode( ',', $elements ) .'{'. $mode .':'. $this->value . $unit . $important .';}';
55 | }
56 | break;
57 | } else {
58 | $output .= $element .'{'. $key_property .':'. $this->value . $unit . $important .'}';
59 | }
60 | }
61 | }
62 |
63 | $this->parent->output_css .= $output;
64 |
65 | return $output;
66 |
67 | }
68 |
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/lib/codestar-framework/assets/js/gutenberg.js:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * -----------------------------------------------------------
4 | *
5 | * Codestar Framework Gutenberg Block
6 | * A Simple and Lightweight WordPress Option Framework
7 | *
8 | * -----------------------------------------------------------
9 | *
10 | */
11 | ( function( blocks, blockEditor, element, components ) {
12 |
13 | if ( !window.csf_gutenberg_blocks ) { return; }
14 |
15 | Object.values(window.csf_gutenberg_blocks).forEach( function( block ) {
16 |
17 | var registerBlockType = blocks.registerBlockType;
18 | var PlainText = blockEditor.PlainText;
19 | var createElement = element.createElement;
20 | var RawHTML = element.RawHTML;
21 | var Button = components.Button;
22 |
23 | registerBlockType(block.name, {
24 | title: block.gutenberg.title,
25 | description: block.gutenberg.description,
26 | icon: block.gutenberg.icon || 'screenoptions',
27 | category: block.gutenberg.category || 'widgets',
28 | keywords: block.gutenberg.keywords,
29 | supports: {
30 | html: false,
31 | className: false,
32 | customClassName: false,
33 | },
34 | attributes: {
35 | shortcode: {
36 | string: 'string',
37 | source: 'text',
38 | }
39 | },
40 | edit: function (props) {
41 | return (
42 | createElement('div', {className: 'csf-shortcode-block'},
43 |
44 | createElement(Button, {
45 | 'data-modal-id': block.modal_id,
46 | 'data-gutenberg-id': block.name,
47 | className: 'is-secondary csf-shortcode-button',
48 | onClick: function () {
49 | window.csf_gutenberg_props = props;
50 | },
51 | }, block.button_title ),
52 |
53 | createElement(PlainText, {
54 | placeholder: block.gutenberg.placeholder,
55 | className: 'input-control blocks-shortcode__textarea',
56 | onChange: function (value) {
57 | props.setAttributes({
58 | shortcode: value
59 | });
60 | },
61 | value: props.attributes.shortcode
62 | })
63 |
64 | )
65 | );
66 | },
67 | save: function (props) {
68 | return createElement(RawHTML, {}, props.attributes.shortcode);
69 | }
70 | });
71 |
72 | });
73 |
74 | })(
75 | window.wp.blocks,
76 | window.wp.blockEditor,
77 | window.wp.element,
78 | window.wp.components
79 | );
80 |
--------------------------------------------------------------------------------
/lib/codestar-framework/fields/sortable/sortable.php:
--------------------------------------------------------------------------------
1 | field_before();
20 |
21 | echo '
';
22 |
23 | $pre_sortby = array();
24 | $pre_fields = array();
25 |
26 | // Add array-keys to defined fields for sort by
27 | foreach ( $this->field['fields'] as $key => $field ) {
28 | $pre_fields[$field['id']] = $field;
29 | }
30 |
31 | // Set sort by by saved-value or default-value
32 | if ( ! empty( $this->value ) ) {
33 |
34 | foreach ( $this->value as $key => $value ) {
35 | $pre_sortby[$key] = $pre_fields[$key];
36 | }
37 |
38 | $diff = array_diff_key( $pre_fields, $this->value );
39 |
40 | if( ! empty( $diff ) ) {
41 | $pre_sortby = array_merge( $pre_sortby, $diff );
42 | }
43 |
44 | } else {
45 |
46 | foreach ( $pre_fields as $key => $value ) {
47 | $pre_sortby[$key] = $value;
48 | }
49 |
50 | }
51 |
52 | foreach ( $pre_sortby as $key => $field ) {
53 |
54 | echo '
';
55 |
56 | echo '
';
57 |
58 | $field_default = ( isset( $this->field['default'][$key] ) ) ? $this->field['default'][$key] : '';
59 | $field_value = ( isset( $this->value[$key] ) ) ? $this->value[$key] : $field_default;
60 | $unique_id = ( ! empty( $this->unique ) ) ? $this->unique .'['. $this->field['id'] .']' : $this->field['id'];
61 |
62 | CSF::field( $field, $field_value, $unique_id, 'field/sortable' );
63 |
64 | echo '
';
65 |
66 | echo '
';
67 |
68 | echo '
';
69 |
70 | }
71 |
72 | echo '
';
73 |
74 | echo $this->field_after();
75 |
76 | }
77 |
78 | public function enqueue() {
79 |
80 | if ( ! wp_script_is( 'jquery-ui-sortable' ) ) {
81 | wp_enqueue_script( 'jquery-ui-sortable' );
82 | }
83 |
84 | }
85 |
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/src/Models/ModelFactory.php:
--------------------------------------------------------------------------------
1 | app = $app;
18 | $this->project = $project;
19 | }
20 |
21 | /**
22 | * Route to class
23 | */
24 | public function create( AbstractConfig $config ) {
25 |
26 | // soft fail
27 | if ( ! $config->has( 'type' ) ) {
28 | return false;
29 | }
30 |
31 | if ( in_array( $config->get( 'type' ), [ 'post-type', 'cpt', 'posttype', 'post_type' ], true ) ) {
32 | $cpt = new PostType( $config );
33 | $cpt->setup();
34 |
35 | $services = [ 'meta', 'settings' ];
36 | foreach ( $services as $service_name ) {
37 | if ( $config->has( $service_name ) && $this->app->has( $service_name ) ) {
38 |
39 | $config_value = $config->get( $service_name );
40 | $service = $this->app->get( $service_name );
41 | $service_imp = $service->make( $cpt->name, $this->project, $config_value );
42 |
43 | if ( $service_imp instanceof Processable ) {
44 | $service_imp->process();
45 | }
46 | }
47 | }
48 |
49 | $service_name = 'features';
50 | if ( $config->has( $service_name ) ) {
51 | $features = $config->get( $service_name );
52 |
53 | foreach ( $features as $feature_name => $args ) {
54 |
55 | if ( ! $args ) {
56 | continue;
57 | }
58 | $normalized_feature_name = strtolower( $feature_name );
59 |
60 | // Feature is not available
61 | if ( ! $this->app->has( $normalized_feature_name ) ) {
62 | continue;
63 | }
64 |
65 | // make sure $args is an array
66 | if( ! is_array( $args ) ){
67 | $args = [];
68 | }
69 |
70 | $service = $this->app->get( $normalized_feature_name );
71 | $service_imp = $service->make( $cpt->name, $this->project, $args );
72 |
73 | if ( $service_imp instanceof Processable ) {
74 | $service_imp->process();
75 | }
76 | }
77 | }
78 |
79 | // disable block editor only if 'block_editor' is false
80 | if ( $config->has( 'block_editor' ) && ! $config->get( 'block_editor' ) ) {
81 | add_filter( 'use_block_editor_for_post_type', array( $cpt, 'disable_block_editor'), 10, 2 );
82 | }
83 | return $cpt;
84 |
85 | }
86 | if ( in_array( $config->get( 'type' ), [ 'taxonomy', 'tax', 'category', 'cat', 'tag' ], true ) ) {
87 | $taxonomy = new Taxonomy( $config );
88 | $taxonomy->setup();
89 | return $taxonomy;
90 | }
91 |
92 | return false;
93 |
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/lib/codestar-framework/fields/image_select/image_select.php:
--------------------------------------------------------------------------------
1 | field, array(
20 | 'multiple' => false,
21 | 'inline' => false,
22 | 'options' => array(),
23 | ) );
24 |
25 | $inline = ( $args['inline'] ) ? ' csf--inline-list' : '';
26 |
27 | $value = ( is_array( $this->value ) ) ? $this->value : array_filter( (array) $this->value );
28 |
29 | echo $this->field_before();
30 |
31 | if ( ! empty( $args['options'] ) ) {
32 |
33 | echo '
';
34 |
35 | $num = 1;
36 |
37 | foreach ( $args['options'] as $key => $option ) {
38 |
39 | $type = ( $args['multiple'] ) ? 'checkbox' : 'radio';
40 | $extra = ( $args['multiple'] ) ? '[]' : '';
41 | $active = ( in_array( $key, $value ) ) ? ' csf--active' : '';
42 | $checked = ( in_array( $key, $value ) ) ? ' checked' : '';
43 |
44 | echo '
';
50 |
51 | }
52 |
53 | echo '
';
54 |
55 | }
56 |
57 | echo $this->field_after();
58 |
59 | }
60 |
61 | public function output() {
62 |
63 | $output = '';
64 | $bg_image = array();
65 | $important = ( ! empty( $this->field['output_important'] ) ) ? '!important' : '';
66 | $elements = ( is_array( $this->field['output'] ) ) ? join( ',', $this->field['output'] ) : $this->field['output'];
67 |
68 | if ( ! empty( $elements ) && isset( $this->value ) && $this->value !== '' ) {
69 | $output = $elements .'{background-image:url('. $this->value .')'. $important .';}';
70 | }
71 |
72 | $this->parent->output_css .= $output;
73 |
74 | return $output;
75 |
76 | }
77 |
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/lib/codestar-framework/fields/sorter/sorter.php:
--------------------------------------------------------------------------------
1 | field, array(
20 | 'disabled' => true,
21 | 'enabled_title' => esc_html__( 'Enabled', 'csf' ),
22 | 'disabled_title' => esc_html__( 'Disabled', 'csf' ),
23 | ) );
24 |
25 | echo $this->field_before();
26 |
27 | $this->value = ( ! empty( $this->value ) ) ? $this->value : $this->field['default'];
28 | $enabled_options = ( ! empty( $this->value['enabled'] ) ) ? $this->value['enabled'] : array();
29 | $disabled_options = ( ! empty( $this->value['disabled'] ) ) ? $this->value['disabled'] : array();
30 |
31 | echo '
';
32 |
33 | echo ( $args['disabled'] ) ? '
' : '';
34 |
35 | echo ( ! empty( $args['enabled_title'] ) ) ? '
'. esc_attr( $args['enabled_title'] ) .'
' : '';
36 | echo '
';
37 | if ( ! empty( $enabled_options ) ) {
38 | foreach ( $enabled_options as $key => $value ) {
39 | echo ''. esc_attr( $value ) .' ';
40 | }
41 | }
42 | echo ' ';
43 |
44 | // Check for hide/show disabled section
45 | if ( $args['disabled'] ) {
46 |
47 | echo '
';
48 |
49 | echo '
';
50 | echo ( ! empty( $args['disabled_title'] ) ) ? '
'. esc_attr( $args['disabled_title'] ) .'
' : '';
51 | echo '
';
52 | if ( ! empty( $disabled_options ) ) {
53 | foreach ( $disabled_options as $key => $value ) {
54 | echo ''. esc_attr( $value ) .' ';
55 | }
56 | }
57 | echo ' ';
58 | echo '
';
59 |
60 | }
61 |
62 |
63 | echo $this->field_after();
64 |
65 | }
66 |
67 | public function enqueue() {
68 |
69 | if ( ! wp_script_is( 'jquery-ui-sortable' ) ) {
70 | wp_enqueue_script( 'jquery-ui-sortable' );
71 | }
72 |
73 | }
74 |
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/lib/codestar-framework/fields/slider/slider.php:
--------------------------------------------------------------------------------
1 | field, array(
20 | 'max' => 100,
21 | 'min' => 0,
22 | 'step' => 1,
23 | 'unit' => '',
24 | ) );
25 |
26 | $is_unit = ( ! empty( $args['unit'] ) ) ? ' csf--is-unit' : '';
27 |
28 | echo $this->field_before();
29 |
30 | echo '
';
31 | echo '
';
32 | echo '
';
33 | echo ' field_attributes( array( 'class' => 'csf-input-number'. esc_attr( $is_unit ) ) ) .' data-min="'. esc_attr( $args['min'] ) .'" data-max="'. esc_attr( $args['max'] ) .'" data-step="'. esc_attr( $args['step'] ) .'" step="any" />';
34 | echo ( ! empty( $args['unit'] ) ) ? ''. esc_attr( $args['unit'] ) .' ' : '';
35 | echo '
';
36 | echo '
';
37 |
38 | echo $this->field_after();
39 |
40 | }
41 |
42 | public function enqueue() {
43 |
44 | if ( ! wp_script_is( 'jquery-ui-slider' ) ) {
45 | wp_enqueue_script( 'jquery-ui-slider' );
46 | }
47 |
48 | }
49 |
50 | public function output() {
51 |
52 | $output = '';
53 | $elements = ( is_array( $this->field['output'] ) ) ? $this->field['output'] : array_filter( (array) $this->field['output'] );
54 | $important = ( ! empty( $this->field['output_important'] ) ) ? '!important' : '';
55 | $mode = ( ! empty( $this->field['output_mode'] ) ) ? $this->field['output_mode'] : 'width';
56 | $unit = ( ! empty( $this->field['unit'] ) ) ? $this->field['unit'] : 'px';
57 |
58 | if ( ! empty( $elements ) && isset( $this->value ) && $this->value !== '' ) {
59 | foreach ( $elements as $key_property => $element ) {
60 | if ( is_numeric( $key_property ) ) {
61 | if ( $mode ) {
62 | $output = implode( ',', $elements ) .'{'. $mode .':'. $this->value . $unit . $important .';}';
63 | }
64 | break;
65 | } else {
66 | $output .= $element .'{'. $key_property .':'. $this->value . $unit . $important .'}';
67 | }
68 | }
69 | }
70 |
71 | $this->parent->output_css .= $output;
72 |
73 | return $output;
74 |
75 | }
76 |
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/lib/codestar-framework/fields/icon/icon.php:
--------------------------------------------------------------------------------
1 | field, array(
20 | 'button_title' => esc_html__( 'Add Icon', 'csf' ),
21 | 'remove_title' => esc_html__( 'Remove Icon', 'csf' ),
22 | ) );
23 |
24 | echo $this->field_before();
25 |
26 | $nonce = wp_create_nonce( 'csf_icon_nonce' );
27 | $hidden = ( empty( $this->value ) ) ? ' hidden' : '';
28 |
29 | echo '
';
35 |
36 | echo $this->field_after();
37 |
38 | }
39 |
40 | public function enqueue() {
41 | add_action( 'admin_footer', array( 'CSF_Field_icon', 'add_footer_modal_icon' ) );
42 | add_action( 'customize_controls_print_footer_scripts', array( 'CSF_Field_icon', 'add_footer_modal_icon' ) );
43 | }
44 |
45 | public static function add_footer_modal_icon() {
46 | ?>
47 |
67 | field, array(
20 | 'library' => array(),
21 | 'preview' => false,
22 | 'preview_width' => '',
23 | 'preview_height' => '',
24 | 'button_title' => esc_html__( 'Upload', 'csf' ),
25 | 'remove_title' => esc_html__( 'Remove', 'csf' ),
26 | ) );
27 |
28 | echo $this->field_before();
29 |
30 | $library = ( is_array( $args['library'] ) ) ? $args['library'] : array_filter( (array) $args['library'] );
31 | $library = ( ! empty( $library ) ) ? implode(',', $library ) : '';
32 | $hidden = ( empty( $this->value ) ) ? ' hidden' : '';
33 |
34 | if ( ! empty( $args['preview'] ) ) {
35 |
36 | $preview_type = ( ! empty( $this->value ) ) ? strtolower( substr( strrchr( $this->value, '.' ), 1 ) ) : '';
37 | $preview_src = ( ! empty( $preview_type ) && in_array( $preview_type, array( 'jpg', 'jpeg', 'gif', 'png', 'svg', 'webp' ) ) ) ? $this->value : '';
38 | $preview_width = ( ! empty( $args['preview_width'] ) ) ? 'max-width:'. esc_attr( $args['preview_width'] ) .'px;' : '';
39 | $preview_height = ( ! empty( $args['preview_height'] ) ) ? 'max-height:'. esc_attr( $args['preview_height'] ) .'px;' : '';
40 | $preview_style = ( ! empty( $preview_width ) || ! empty( $preview_height ) ) ? ' style="'. esc_attr( $preview_width . $preview_height ) .'"': '';
41 | $preview_hidden = ( empty( $preview_src ) ) ? ' hidden' : '';
42 |
43 | echo '
';
44 | echo '
';
45 | echo '
';
46 | echo '
';
47 | echo '
';
48 |
49 | }
50 |
51 | echo '
';
56 |
57 | echo $this->field_after();
58 |
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/lib/codestar-framework/assets/scss/partials/_responsive.scss:
--------------------------------------------------------------------------------
1 | /**
2 | * 12. Responsive
3 | */
4 | @media only screen and (max-width:1200px){
5 |
6 | .csf-metabox{
7 |
8 | .csf-field{
9 |
10 | .csf-title{
11 | float: none;
12 | width: 100%;
13 | margin-bottom: 10px;
14 | }
15 |
16 | .csf-fieldset{
17 | float: none;
18 | width: 100%;
19 | }
20 | }
21 | }
22 | }
23 |
24 | @media only screen and (max-width:782px){
25 |
26 | .csf-header-inner{
27 | text-align: center;
28 |
29 | h1{
30 | width: 100%;
31 | margin-bottom: 10px;
32 | }
33 | }
34 |
35 | .csf-form-result{
36 | float: none;
37 | margin-right: 0;
38 | margin-bottom: 10px;
39 | }
40 |
41 | .csf-search,
42 | .csf-header-right,
43 | .csf-header-left{
44 | width: 100%;
45 | }
46 |
47 | .csf-search{
48 | text-align: center;
49 | margin-bottom: 15px;
50 | }
51 |
52 | .csf-footer{
53 | text-align: center;
54 | }
55 |
56 | .csf-buttons{
57 | float: none;
58 | }
59 |
60 | .csf-copyright{
61 | float: none;
62 | margin-top: 10px;
63 | }
64 |
65 | .csf-nav,
66 | .csf-expand-all,
67 | .csf-reset-section,
68 | .csf-nav-background{
69 | display: none !important;
70 | }
71 |
72 | .csf-nav-normal + .csf-content{
73 | margin-left: 0;
74 | }
75 |
76 | .csf-section-title,
77 | .csf-section{
78 | display: block !important;
79 | }
80 |
81 | .csf-field{
82 |
83 | .csf-title{
84 | float: none;
85 | width: 100%;
86 | margin-bottom: 10px;
87 | }
88 |
89 | .csf-fieldset{
90 | float: none;
91 | width: 100%;
92 | }
93 | }
94 |
95 | .csf-field-color{
96 |
97 | .button.wp-picker-clear{
98 | padding: 0 8px;
99 | line-height: 2.14285714;
100 | min-height: 32px;
101 | }
102 | }
103 |
104 | .csf-profile-options,
105 | .csf-taxonomy-edit-fields{
106 |
107 | > .csf-field{
108 |
109 | > .csf-title{
110 | float: none;
111 | width: 100%;
112 | margin-bottom: 10px;
113 | }
114 |
115 | > .csf-fieldset{
116 | float: none;
117 | width: 100%;
118 | }
119 | }
120 | }
121 |
122 | .csf-nav-menu-options{
123 |
124 | > .csf-fields{
125 | margin-left: -10px;
126 | margin-right: -10px;
127 |
128 | > .csf-field{
129 | padding: 10px;
130 | }
131 | }
132 | }
133 | }
134 |
135 | @media only screen and (max-width: 782px) {
136 |
137 | .csf-modal{
138 |
139 | .csf-modal-inner{
140 | width: 90%;
141 | }
142 | }
143 | }
144 |
145 | @media only screen and (max-height: 750px) {
146 |
147 | .csf-modal{
148 |
149 | .csf-modal-inner{
150 | height: auto;
151 | }
152 |
153 | .csf-modal-content{
154 | height: calc(100vh - 200px);
155 | }
156 | }
157 | }
158 |
--------------------------------------------------------------------------------
/lib/codestar-framework/assets/scss/style.scss:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * ---------------------------------------------------------
4 | * CODESTAR FRAMEWORK CSS MAP
5 | * ---------------------------------------------------------
6 | *
7 | * 01. Base
8 | * 01. 01. Header
9 | * 01. 02. Sticky
10 | * 01. 03. Header Buttons
11 | * 01. 04. Navigation
12 | * 01. 05. Wrapper
13 | * 01. 06. Content
14 | * 01. 07. Section
15 | * 01. 08. Footer
16 | * 01. 09. Copyright
17 | * 01. 10. Show All Settings
18 | * 01. 11. Search Input
19 | * 01. 12. Metabox
20 | * 01. 13. Comment Metabox
21 | * 01. 14. Help Tooltip
22 | * 02. Themes
23 | * 02. 01. Theme Dark
24 | * 02. 02. Theme Light
25 | * 03. Fields
26 | * 03. 01. Field
27 | * 03. 02. Field: accordion
28 | * 03. 03. Field: background
29 | * 03. 04. Field: backup
30 | * 03. 05. Field: border, spacing, dimensions
31 | * 03. 06. Field: button_set
32 | * 03. 07. Field: checkbox, radio
33 | * 03. 08. Field: code_editor
34 | * 03. 09. Field: color
35 | * 03. 10. Field: color_group
36 | * 03. 11. Field: fieldset
37 | * 03. 12. Field: date
38 | * 03. 13. Field: datetime
39 | * 03. 14. Field: gallery
40 | * 03. 15. Field: group
41 | * 03. 16. Field: icon
42 | * 03. 17. Field: image_select
43 | * 03. 18. Field: link_color
44 | * 03. 19. Field: map
45 | * 03. 20. Field: media
46 | * 03. 21. Field: palette
47 | * 03. 22. Field: repeater
48 | * 03. 23. Field: select
49 | * 03. 24. Field: slider
50 | * 03. 25. Field: sortable
51 | * 03. 26. Field: sorter
52 | * 03. 27. Field: spinner
53 | * 03. 28. Field: switcher
54 | * 03. 29. Field: tabbed
55 | * 03. 30. Field: text
56 | * 03. 31. Field: textarea
57 | * 03. 32. Field: typography
58 | * 03. 33. Field: upload
59 | * 03. 34. Field: wp_editor
60 | * 03. 35. Field: heading
61 | * 03. 36. Field: subheading
62 | * 03. 37. Field: submessage
63 | * 03. 38. Field: notice
64 | * 03. 39. Field: number
65 | * 03. 40. Field: link
66 | * 03. 41. Field: others
67 | * 04. Widget
68 | * 05. Customizer
69 | * 06. Taxonomy
70 | * 07. Profile
71 | * 08. Nav Menu
72 | * 09. Modal
73 | * 09. 01. Shortcode Modal
74 | * 09. 02. Gutenberg Modal
75 | * 09. 03. Icon Modal
76 | * 10. Helper
77 | * 11. Welcome Page
78 | * 12. Responsive
79 | * 13. Others
80 | *
81 | * ---------------------------------------------------------
82 | *
83 | */
84 | @import "partials/base";
85 | @import "partials/themes";
86 | @import "partials/fields";
87 | @import "partials/widget";
88 | @import "partials/customizer";
89 | @import "partials/taxonomy";
90 | @import "partials/navmenu";
91 | @import "partials/profile";
92 | @import "partials/modal";
93 | @import "partials/helper";
94 | @import "partials/welcome";
95 | @import "partials/responsive";
96 | @import "partials/chosen";
97 | @import "partials/flatpickr";
98 |
--------------------------------------------------------------------------------
/lib/codestar-framework/assets/scss/partials/_helper.scss:
--------------------------------------------------------------------------------
1 | /**
2 | * 10. Helper
3 | */
4 | .csf-subtitle-text{
5 | margin-top: 6px;
6 | font-weight: 400;
7 | color: #999;
8 | }
9 |
10 | .csf-desc-text{
11 | clear: both;
12 | float: left;
13 | width: 100%;
14 | margin-top: 6px;
15 | font-weight: 400;
16 | color: #999;
17 | }
18 |
19 | .csf-error-text{
20 | margin-top: 6px;
21 | color: #d02c21;
22 | }
23 |
24 | .csf-before-text{
25 | margin-bottom: 6px;
26 | }
27 |
28 | .csf-after-text{
29 | margin-top: 6px;
30 | }
31 |
32 | .csf-metabox-hide{
33 | display: none !important;
34 | }
35 |
36 | .csf-metabox-show{
37 | display: block !important;
38 | }
39 |
40 | .csf-depend-hidden.csf-depend-on{
41 | display: none;
42 | }
43 |
44 | .csf-depend-visible.csf-depend-on{
45 | display: block;
46 | opacity: 0.75;
47 | filter: grayscale(1);
48 | user-select: none;
49 | border-top: 1px solid #eee;
50 |
51 | .clear:before{
52 | content: "";
53 | left: 0;
54 | top: 0;
55 | right: 0;
56 | bottom: 0;
57 | position: absolute;
58 | background-color: #eee;
59 | opacity: 0.25;
60 | z-index: 10;
61 | }
62 | }
63 |
64 | .csf-warning-primary{
65 | color: #fff !important;
66 | border-color: #dc3545 !important;
67 | background: #dc3545 !important;
68 |
69 | &:hover,
70 | &:focus{
71 | border-color: #bd2130 !important;
72 | background: #bd2130 !important;
73 | }
74 |
75 | &:focus{
76 | box-shadow: 0 0 0 1px #fff, 0 0 0 3px #bd2130 !important;
77 | }
78 |
79 | &:active{
80 | border-color: #bd2130 !important;
81 | background: #bd2130 !important;
82 | }
83 | }
84 |
85 | .csf-form-result{
86 | display: none;
87 | float: left;
88 | padding: 0 8px;
89 | margin-right: 4px;
90 | font-size: 11px;
91 | line-height: 30px;
92 | user-select: none;
93 | border-radius: 2px;
94 | }
95 |
96 | .csf-form-show{
97 | display: block;
98 | }
99 |
100 | .csf-form-success{
101 | color: #fff;
102 | background-color: #46b450;
103 | }
104 |
105 | .csf-form-warning{
106 | color: #8a6d3b;
107 | background-color: #faebcc;
108 | }
109 |
110 | .csf-label-error{
111 | position: relative;
112 | top: -2px;
113 | display: inline-block;
114 | font-size: 10px;
115 | line-height: 10px;
116 | height: 10px;
117 | width: 10px;
118 | padding: 1px;
119 | font-style: normal;
120 | text-align: center;
121 | color: #fff;
122 | vertical-align: middle;
123 | background-color: #e10000;
124 | border-radius: 2px;
125 | }
126 |
127 | .csf-no-option{
128 | padding: 30px;
129 | }
130 |
131 | .csf-input-number{
132 | -moz-appearance:textfield;
133 | }
134 |
135 | .csf-input-number::-webkit-inner-spin-button,
136 | .csf-input-number::-webkit-outer-spin-button{
137 | -webkit-appearance: none;
138 | margin: 0;
139 | }
140 |
141 | .csf-fa5-shims{
142 |
143 | .csf{
144 |
145 | .fas,
146 | .far,
147 | .fab{
148 | font-family: "FontAwesome";
149 | font-style: normal;
150 | }
151 | }
152 | }
153 |
--------------------------------------------------------------------------------
/src/Modeler.php:
--------------------------------------------------------------------------------
1 | model_factory = $model_factory;
20 | // should contain a list of loaded models
21 |
22 | }
23 |
24 | public function init( $project_path ) {
25 | $path = $this->get_path( $project_path );
26 | if ( ! $path ) {
27 | return;
28 | }
29 | $this->load( $path );
30 | }
31 |
32 | /**
33 | * Get custom path
34 | */
35 | protected function get_path( $project_path ) {
36 |
37 | $path = $project_path . '/src/models/';
38 | if ( has_filter( 'saltus_models_path' ) ) {
39 | $path = apply_filters( 'saltus_models_path', $path );
40 | }
41 |
42 | if ( file_exists( $path ) ) {
43 | return $path;
44 | }
45 | return false;
46 | }
47 |
48 | /**
49 | * Load Models
50 | */
51 | protected function load( $path ) {
52 | if ( file_exists( $path ) ) {
53 | $path_dir = new \RecursiveDirectoryIterator( $path );
54 | $path_dir_iter = new \RecursiveIteratorIterator( $path_dir );
55 |
56 | foreach ( $path_dir_iter as $filename => $file ) {
57 | if ( ! in_array( pathinfo( $file, PATHINFO_EXTENSION ), [ 'json', 'php', 'yml', 'yaml' ], true ) ) {
58 | continue;
59 | }
60 | $config = new Config( $file );
61 | ( $this->is_multiple( $config ) ?
62 | $this->iterate_multiple( $config ) :
63 | $this->create( $config )
64 | );
65 | }
66 | }
67 |
68 | // check for models added with filters
69 | if ( has_filter( 'saltus_models' ) ) {
70 | $model = apply_filters( 'saltus_models', [] );
71 | ( ! empty( $model ) && count( $model ) > 0 ?
72 | $this->iterate_multiple($model ) :
73 | $this->create( $model )
74 | );
75 | }
76 | }
77 |
78 | /**
79 | * Is multidimensional config
80 | */
81 | protected function is_multiple( $config ) {
82 | return ( is_array( current( $config->all() ) ) );
83 | }
84 |
85 | /**
86 | * Load each from multidimensional config
87 | *
88 | * Creates a new config from the part
89 | */
90 | protected function iterate_multiple( $config ) {
91 | foreach ( $config as $single_config ) {
92 | $this->create( new NoFile( $single_config ) );
93 | }
94 | }
95 |
96 | /**
97 | * Creates the model in the factory
98 | *
99 | * @param $config The set of configurations for the cpt/tax
100 | */
101 | protected function create( $config ) {
102 | $model = $this->model_factory->create( $config );
103 | if ( $model === false ) {
104 | return false;
105 | }
106 | $this->add( $model );
107 | }
108 |
109 | /**
110 | * Adds the model to a list
111 | */
112 | protected function add( $model ) {
113 | $this->model_list[ $model->get_type() ] = $model;
114 | }
115 |
116 | }
117 |
--------------------------------------------------------------------------------
/lib/codestar-framework/fields/link/link.php:
--------------------------------------------------------------------------------
1 | field, array(
20 | 'add_title' => esc_html__( 'Add Link', 'csf' ),
21 | 'edit_title' => esc_html__( 'Edit Link', 'csf' ),
22 | 'remove_title' => esc_html__( 'Remove Link', 'csf' ),
23 | ) );
24 |
25 | $default_values = array(
26 | 'url' => '',
27 | 'text' => '',
28 | 'target' => '',
29 | );
30 |
31 | $value = wp_parse_args( $this->value, $default_values );
32 |
33 | $hidden = ( ! empty( $value['url'] ) || ! empty( $value['url'] ) || ! empty( $value['url'] ) ) ? ' hidden' : '';
34 |
35 | $maybe_hidden = ( empty( $hidden ) ) ? ' hidden' : '';
36 |
37 | echo $this->field_before();
38 |
39 | echo '
';
40 |
41 | echo '
'. sprintf( '{url:"%s", text:"%s", target:"%s"}', $value['url'], $value['text'], $value['target'] ) .'
';
42 |
43 | echo '
field_attributes( array( 'class' => 'csf--url' ) ) .' />';
44 | echo '
';
45 | echo '
';
46 |
47 | echo '
'. $args['add_title'] .' ';
48 | echo '
'. $args['edit_title'] .' ';
49 | echo '
'. $args['remove_title'] .' ';
50 |
51 | echo $this->field_after();
52 |
53 | }
54 |
55 | public function enqueue() {
56 |
57 | if ( ! wp_script_is( 'wplink' ) ) {
58 | wp_enqueue_script( 'wplink' );
59 | }
60 |
61 | if ( ! wp_script_is( 'jquery-ui-autocomplete' ) ) {
62 | wp_enqueue_script( 'jquery-ui-autocomplete' );
63 | }
64 |
65 | add_action( 'admin_print_footer_scripts', array( $this, 'add_wp_link_dialog' ) );
66 |
67 | }
68 |
69 | public function add_wp_link_dialog() {
70 |
71 | if ( ! class_exists( '_WP_Editors' ) ) {
72 | require_once ABSPATH . WPINC .'/class-wp-editor.php';
73 | }
74 |
75 | wp_print_styles( 'editor-buttons' );
76 |
77 | _WP_Editors::wp_link_dialog();
78 |
79 | }
80 |
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/src/Features/Settings/CodestarSettings.php:
--------------------------------------------------------------------------------
1 | name = $name;
15 | $this->settings = $settings;
16 | }
17 |
18 | public function process() {
19 | /**
20 | * Create Settings pages
21 | */
22 | foreach ( $this->settings as $settings_id => $settings_page ) {
23 | if ( empty( $settings_page['fields'] ) && empty( $settings_page['sections'] ) ) {
24 | continue;
25 | }
26 |
27 | // else add just the fields
28 | $this->create_settings_page( $settings_id, $settings_page );
29 | }
30 | }
31 |
32 | /**
33 | * Create settings page
34 | *
35 | * @param int $settings_id identifier of the settings
36 | * @param array $settings_page paramaters for the page
37 | * @return void
38 | */
39 | private function create_settings_page( $settings_id, $settings_page ) {
40 |
41 | $default_args = array(
42 | 'menu_slug' => $settings_id,
43 | 'menu_parent' => 'edit.php?post_type=' . $this->name,
44 | 'menu_type' => 'submenu',
45 | 'theme' => 'light',
46 | 'footer_credit' => ' ', // removes codestar default credit
47 | 'framework_title' => isset( $settings_page['title'] ) ? $settings_page['title'] : '',
48 | );
49 |
50 | $args = array_merge( $default_args, $settings_page );
51 |
52 | // Create options
53 | \CSF::createOptions( $settings_id, $args );
54 |
55 | if ( isset( $settings_page['fields'] ) ) {
56 | $settings_page['fields'] = $this->prepare_fields( $settings_page['fields'] );
57 | $this->create_section( $settings_id, $settings_page );
58 | return;
59 | }
60 |
61 | if ( isset( $settings_page['sections'] ) ) {
62 | foreach ( $settings_page['sections'] as $section ) {
63 | $section['fields'] = $this->prepare_fields( $section['fields'] );
64 | $this->create_section( $settings_id, $section );
65 | }
66 | }
67 |
68 | }
69 |
70 | /**
71 | * Create section using builtin Codestart method
72 | *
73 | * @param string $id - identifier of the section
74 | * @param array $section - parameters for the section
75 | * @return void
76 | */
77 | private function create_section( $id, $section ) {
78 |
79 | \CSF::createSection( $id, $section );
80 |
81 | }
82 |
83 | /**
84 | * Prepare fields to make sure they have all necessary parameters
85 | *
86 | * @param array $fields
87 | * @return array $fields array of fields prepared to be rendered by CodestarFields
88 | */
89 | private function prepare_fields( $fields ) {
90 |
91 | foreach ( $fields as $key => &$field ) {
92 |
93 | // Each field array needs to have an id,
94 | // but only if it wasn't provided
95 | $field_id = $field['id'] ?? $key;
96 |
97 | $fields[ $key ]['id'] = $field_id;
98 |
99 | if ( isset( $field['fields'] ) ) {
100 |
101 | $field['fields'] = $this->prepare_fields( $field['fields'] );
102 |
103 | }
104 | }
105 |
106 | // codestar framework 'prefers' keys to be a numeric index, so we return the array_values
107 | return array_values( $fields );
108 | }
109 |
110 |
111 | }
112 |
--------------------------------------------------------------------------------
/lib/codestar-framework/fields/wp_editor/wp_editor.php:
--------------------------------------------------------------------------------
1 | field, array(
21 | 'tinymce' => true,
22 | 'quicktags' => true,
23 | 'media_buttons' => true,
24 | 'wpautop' => false,
25 | 'height' => '',
26 | ) );
27 |
28 | $attributes = array(
29 | 'rows' => 10,
30 | 'class' => 'wp-editor-area',
31 | 'autocomplete' => 'off',
32 | );
33 |
34 | $editor_height = ( ! empty( $args['height'] ) ) ? ' style="height:'. esc_attr( $args['height'] ) .';"' : '';
35 |
36 | $editor_settings = array(
37 | 'tinymce' => $args['tinymce'],
38 | 'quicktags' => $args['quicktags'],
39 | 'media_buttons' => $args['media_buttons'],
40 | 'wpautop' => $args['wpautop'],
41 | );
42 |
43 | echo $this->field_before();
44 |
45 | echo ( csf_wp_editor_api() ) ? '
' : '';
46 |
47 | echo '';
48 |
49 | echo ( csf_wp_editor_api() ) ? '
' : '';
50 |
51 | echo $this->field_after();
52 |
53 | }
54 |
55 | public function enqueue() {
56 |
57 | if ( csf_wp_editor_api() && function_exists( 'wp_enqueue_editor' ) ) {
58 |
59 | wp_enqueue_editor();
60 |
61 | $this->setup_wp_editor_settings();
62 |
63 | add_action( 'print_default_editor_scripts', array( $this, 'setup_wp_editor_media_buttons' ) );
64 |
65 | }
66 |
67 | }
68 |
69 | // Setup wp editor media buttons
70 | public function setup_wp_editor_media_buttons() {
71 |
72 | if ( ! function_exists( 'media_buttons' ) ) {
73 | return;
74 | }
75 |
76 | ob_start();
77 | echo '
';
78 | do_action( 'media_buttons' );
79 | echo '
';
80 | $media_buttons = ob_get_clean();
81 |
82 | echo '';
85 |
86 | }
87 |
88 | // Setup wp editor settings
89 | public function setup_wp_editor_settings() {
90 |
91 | if ( csf_wp_editor_api() && class_exists( '_WP_Editors') ) {
92 |
93 | $defaults = apply_filters( 'csf_wp_editor', array(
94 | 'tinymce' => array(
95 | 'wp_skip_init' => true
96 | ),
97 | ) );
98 |
99 | $setup = _WP_Editors::parse_settings( 'csf_wp_editor', $defaults );
100 |
101 | _WP_Editors::editor_settings( 'csf_wp_editor', $setup );
102 |
103 | }
104 |
105 | }
106 |
107 | }
108 | }
109 |
--------------------------------------------------------------------------------
/lib/codestar-framework/fields/radio/radio.php:
--------------------------------------------------------------------------------
1 | field, array(
20 | 'inline' => false,
21 | 'query_args' => array(),
22 | ) );
23 |
24 | $inline_class = ( $args['inline'] ) ? ' class="csf--inline-list"' : '';
25 |
26 | echo $this->field_before();
27 |
28 | if ( isset( $this->field['options'] ) ) {
29 |
30 | $options = $this->field['options'];
31 | $options = ( is_array( $options ) ) ? $options : array_filter( $this->field_data( $options, false, $args['query_args'] ) );
32 |
33 | if ( is_array( $options ) && ! empty( $options ) ) {
34 |
35 | echo '
';
72 |
73 | } else {
74 |
75 | echo ( ! empty( $this->field['empty_message'] ) ) ? esc_attr( $this->field['empty_message'] ) : esc_html__( 'No data available.', 'csf' );
76 |
77 | }
78 |
79 | } else {
80 |
81 | $label = ( isset( $this->field['label'] ) ) ? $this->field['label'] : '';
82 | echo '
field_attributes() . esc_attr( checked( $this->value, 1, false ) ) .'/>';
83 | echo ( ! empty( $this->field['label'] ) ) ? ''. esc_attr( $this->field['label'] ) .' ' : '';
84 | echo '';
85 |
86 | }
87 |
88 | echo $this->field_after();
89 |
90 | }
91 |
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/lib/codestar-framework/assets/scss/partials/_customizer.scss:
--------------------------------------------------------------------------------
1 | /**
2 | * 05. Widget
3 | */
4 | .control-section{
5 |
6 | .csf-field{
7 | padding: 0;
8 |
9 | .csf-title{
10 | float: none;
11 | width: 100%;
12 | margin-bottom: 6px;
13 |
14 | h4{
15 | display: block;
16 | font-size: 13px;
17 | line-height: 1;
18 | font-weight: 600;
19 | color: inherit;
20 | }
21 | }
22 |
23 | .csf-fieldset{
24 | float: none;
25 | width: 100%;
26 | }
27 | }
28 |
29 | .csf-help{
30 | top: -5px;
31 | right: -5px;
32 | }
33 |
34 | .csf-field-select select{
35 | width: 100%;
36 | }
37 |
38 | .csf-field-heading{
39 | color: inherit;
40 | font-size: 14px;
41 | line-height: 1em;
42 | margin-right: -15px;
43 | margin-left: -15px;
44 | padding: 15px;
45 | }
46 |
47 | .csf-field-subheading{
48 | color: inherit;
49 | font-size: 11px;
50 | margin-right: -15px;
51 | margin-left: -15px;
52 | padding: 10px 15px;
53 | }
54 |
55 | .csf-subtitle-text{
56 | margin-top: 4px;
57 | font-size: 12px;
58 | }
59 |
60 | .csf-field-submessage .csf-submessage{
61 | margin-right: -15px;
62 | margin-left: -15px;
63 | padding: 15px;
64 | }
65 |
66 | .csf-fieldset{
67 |
68 | .csf-field-submessage .csf-submessage,
69 | .csf-field-heading,
70 | .csf-field-subheading{
71 | margin-left: 0;
72 | margin-right: 0;
73 | }
74 | }
75 |
76 | .csf-field-date,
77 | .csf-field-datetime{
78 |
79 | label{
80 | display: block;
81 | }
82 |
83 | .csf--to{
84 | margin-top: 4px;
85 | margin-left: 0;
86 | }
87 | }
88 |
89 | .csf-field-sorter{
90 |
91 | ul li{
92 | padding: 5px;
93 | }
94 |
95 | .csf-modules{
96 | float: none;
97 | width: 100%;
98 | }
99 |
100 | .csf-modules:first-child{
101 | padding-right: 0;
102 | padding-bottom: 15px;
103 | }
104 | }
105 |
106 | .csf-field-background{
107 |
108 | .csf--background-attributes{
109 | flex-direction: column;
110 | }
111 | }
112 |
113 | .csf-field-spacing{
114 | input{
115 | width: 90px;
116 | }
117 | }
118 |
119 | .csf-field-border{
120 |
121 | .csf--input{
122 | flex: 1 50%;
123 | }
124 |
125 | input,
126 | select{
127 | width: 100%;
128 | }
129 | }
130 |
131 | .csf-field-spinner{
132 | input{
133 | width: 50px;
134 | }
135 | }
136 |
137 | .csf-field-number{
138 |
139 | .csf--wrap{
140 | width: 100%;
141 | }
142 | }
143 |
144 | .csf-field-backup{
145 |
146 | .csf-export-data{
147 | display: none;
148 | }
149 | }
150 |
151 | .csf-field-fieldset{
152 |
153 | .csf-fieldset-content{
154 | border-color: #e5e5e5;
155 | }
156 | }
157 |
158 | .csf-tabbed-content,
159 | .csf-sortable-content,
160 | .csf-repeater-content,
161 | .csf-fieldset-content,
162 | .csf-cloneable-content,
163 | .csf-accordion-content{
164 |
165 | > .csf-field{
166 | padding: 10px;
167 |
168 | .csf-title{
169 | margin-bottom: 5px;
170 | }
171 |
172 | h4{
173 | font-size: 12px;
174 | }
175 | }
176 | }
177 |
178 | .csf-depend-hidden.csf-depend-on{
179 | display: none !important;
180 | }
181 |
182 | .csf-depend-visible.csf-depend-on{
183 | border-top: 0 !important;
184 | }
185 | }
186 |
--------------------------------------------------------------------------------
/phpcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Saltus Coding Standards.
4 |
5 | */phpunit.xml*
6 | */languages/*
7 | */tests/*
8 | */node_modules/*
9 | */vendor/*
10 | lib/*
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 | ./src/
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
--------------------------------------------------------------------------------
/lib/codestar-framework/functions/validate.php:
--------------------------------------------------------------------------------
1 | add( 'required', esc_html__( 'Please enter a valid email address.', 'csf' ) );
87 | }
88 |
89 | return $validity;
90 |
91 | }
92 | }
93 |
94 | /**
95 | *
96 | * Numeric validate for Customizer
97 | *
98 | * @since 1.0.0
99 | * @version 1.0.0
100 | *
101 | */
102 | if ( ! function_exists( 'csf_customize_validate_numeric' ) ) {
103 | function csf_customize_validate_numeric( $validity, $value, $wp_customize ) {
104 |
105 | if ( ! is_numeric( $value ) ) {
106 | $validity->add( 'required', esc_html__( 'Please enter a valid number.', 'csf' ) );
107 | }
108 |
109 | return $validity;
110 |
111 | }
112 | }
113 |
114 | /**
115 | *
116 | * Required validate for Customizer
117 | *
118 | * @since 1.0.0
119 | * @version 1.0.0
120 | *
121 | */
122 | if ( ! function_exists( 'csf_customize_validate_required' ) ) {
123 | function csf_customize_validate_required( $validity, $value, $wp_customize ) {
124 |
125 | if ( empty( $value ) ) {
126 | $validity->add( 'required', esc_html__( 'This field is required.', 'csf' ) );
127 | }
128 |
129 | return $validity;
130 |
131 | }
132 | }
133 |
134 | /**
135 | *
136 | * URL validate for Customizer
137 | *
138 | * @since 1.0.0
139 | * @version 1.0.0
140 | *
141 | */
142 | if ( ! function_exists( 'csf_customize_validate_url' ) ) {
143 | function csf_customize_validate_url( $validity, $value, $wp_customize ) {
144 |
145 | if ( ! filter_var( $value, FILTER_VALIDATE_URL ) ) {
146 | $validity->add( 'required', esc_html__( 'Please enter a valid URL.', 'csf' ) );
147 | }
148 |
149 | return $validity;
150 |
151 | }
152 | }
153 |
--------------------------------------------------------------------------------
/lib/codestar-framework/fields/link_color/link_color.php:
--------------------------------------------------------------------------------
1 | field, array(
20 | 'color' => true,
21 | 'hover' => true,
22 | 'active' => false,
23 | 'visited' => false,
24 | 'focus' => false,
25 | ) );
26 |
27 | $default_values = array(
28 | 'color' => '',
29 | 'hover' => '',
30 | 'active' => '',
31 | 'visited' => '',
32 | 'focus' => '',
33 | );
34 |
35 | $color_props = array(
36 | 'color' => esc_html__( 'Normal', 'csf' ),
37 | 'hover' => esc_html__( 'Hover', 'csf' ),
38 | 'active' => esc_html__( 'Active', 'csf' ),
39 | 'visited' => esc_html__( 'Visited', 'csf' ),
40 | 'focus' => esc_html__( 'Focus', 'csf' )
41 | );
42 |
43 | $value = wp_parse_args( $this->value, $default_values );
44 |
45 | echo $this->field_before();
46 |
47 | foreach ( $color_props as $color_prop_key => $color_prop_value ) {
48 |
49 | if ( ! empty( $args[$color_prop_key] ) ) {
50 |
51 | $default_attr = ( ! empty( $this->field['default'][$color_prop_key] ) ) ? ' data-default-color="'. esc_attr( $this->field['default'][$color_prop_key] ) .'"' : '';
52 |
53 | echo '
';
54 | echo '
'. esc_attr( $color_prop_value ) .'
';
55 | echo '
field_attributes() .'/>';
56 | echo '
';
57 |
58 | }
59 |
60 | }
61 |
62 | echo $this->field_after();
63 |
64 | }
65 |
66 | public function output() {
67 |
68 | $output = '';
69 | $elements = ( is_array( $this->field['output'] ) ) ? $this->field['output'] : array_filter( (array) $this->field['output'] );
70 | $important = ( ! empty( $this->field['output_important'] ) ) ? '!important' : '';
71 |
72 | if ( ! empty( $elements ) && isset( $this->value ) && $this->value !== '' ) {
73 | foreach ( $elements as $element ) {
74 |
75 | if ( isset( $this->value['color'] ) && $this->value['color'] !== '' ) { $output .= $element .'{color:'. $this->value['color'] . $important .';}'; }
76 | if ( isset( $this->value['hover'] ) && $this->value['hover'] !== '' ) { $output .= $element .':hover{color:'. $this->value['hover'] . $important .';}'; }
77 | if ( isset( $this->value['active'] ) && $this->value['active'] !== '' ) { $output .= $element .':active{color:'. $this->value['active'] . $important .';}'; }
78 | if ( isset( $this->value['visited'] ) && $this->value['visited'] !== '' ) { $output .= $element .':visited{color:'. $this->value['visited'] . $important .';}'; }
79 | if ( isset( $this->value['focus'] ) && $this->value['focus'] !== '' ) { $output .= $element .':focus{color:'. $this->value['focus'] . $important .';}'; }
80 |
81 | }
82 | }
83 |
84 | $this->parent->output_css .= $output;
85 |
86 | return $output;
87 |
88 | }
89 |
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/lib/codestar-framework/views/free-vs-premium.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Features
7 | Free Version
8 | Premium Version
9 |
10 |
11 |
12 |
13 | Admin Option Framework
14 |
15 |
16 |
17 |
18 | Customize Option Framework
19 |
20 |
21 |
22 |
23 | Metabox Option Framework
24 |
25 |
26 |
27 |
28 | Nav Menu Option Framework
29 |
30 |
31 |
32 |
33 | Taxonomy Option Framework
34 |
35 |
36 |
37 |
38 | Profile Option Framework
39 |
40 |
41 |
42 |
43 | Widget Option Framework
44 |
45 |
46 |
47 |
48 | Comment Option Framework
49 |
50 |
51 |
52 |
53 | Shortcode Option Framework
54 |
55 |
56 |
57 |
58 | All Option Fields
59 |
60 |
61 |
62 |
63 | Developer Packages
64 |
65 |
66 |
67 |
68 | Unminfy Library
69 |
70 |
71 |
72 |
73 | New Requests
74 |
75 |
76 |
77 |
78 | Autoremove Advertisements
79 |
80 |
81 |
82 |
83 | Life-time access/updates
84 |
85 |
86 |
87 |
88 | Support Forum
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 | Download Free Version
97 | Upgrade Premium Version
98 |
99 |
100 |
101 |
--------------------------------------------------------------------------------
/lib/codestar-framework/fields/map/map.php:
--------------------------------------------------------------------------------
1 | field, array(
23 | 'placeholder' => esc_html__( 'Search...', 'csf' ),
24 | 'latitude_text' => esc_html__( 'Latitude', 'csf' ),
25 | 'longitude_text' => esc_html__( 'Longitude', 'csf' ),
26 | 'address_field' => '',
27 | 'height' => '',
28 | ) );
29 |
30 | $value = wp_parse_args( $this->value, array(
31 | 'address' => '',
32 | 'latitude' => '20',
33 | 'longitude' => '0',
34 | 'zoom' => '2',
35 | ) );
36 |
37 | $default_settings = array(
38 | 'center' => array( $value['latitude'], $value['longitude'] ),
39 | 'zoom' => $value['zoom'],
40 | 'scrollWheelZoom' => false,
41 | );
42 |
43 | $settings = ( ! empty( $this->field['settings'] ) ) ? $this->field['settings'] : array();
44 | $settings = wp_parse_args( $settings, $default_settings );
45 |
46 | $style_attr = ( ! empty( $args['height'] ) ) ? ' style="min-height:'. esc_attr( $args['height'] ) .';"' : '';
47 | $placeholder = ( ! empty( $args['placeholder'] ) ) ? array( 'placeholder' => $args['placeholder'] ) : '';
48 |
49 | echo $this->field_before();
50 |
51 | if ( empty( $args['address_field'] ) ) {
52 | echo '
';
53 | echo ' field_attributes( $placeholder ) .' />';
54 | echo '
';
55 | } else {
56 | echo '
';
57 | }
58 |
59 | echo '
';
60 |
61 | echo '
';
74 |
75 | echo '
';
76 |
77 | echo $this->field_after();
78 |
79 | }
80 |
81 | public function enqueue() {
82 |
83 | if ( ! wp_script_is( 'csf-leaflet' ) ) {
84 | wp_enqueue_script( 'csf-leaflet', esc_url( $this->cdn_url . $this->version .'/dist/leaflet.js' ), array( 'csf' ), $this->version, true );
85 | }
86 |
87 | if ( ! wp_style_is( 'csf-leaflet' ) ) {
88 | wp_enqueue_style( 'csf-leaflet', esc_url( $this->cdn_url . $this->version .'/dist/leaflet.css' ), array(), $this->version );
89 | }
90 |
91 | if ( ! wp_script_is( 'jquery-ui-autocomplete' ) ) {
92 | wp_enqueue_script( 'jquery-ui-autocomplete' );
93 | }
94 |
95 | }
96 |
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/lib/codestar-framework/fields/checkbox/checkbox.php:
--------------------------------------------------------------------------------
1 | field, array(
20 | 'inline' => false,
21 | 'query_args' => array(),
22 | 'check_all' => false,
23 | 'check_all_text' => esc_html__( 'Check/Uncheck All' ),
24 | ) );
25 |
26 | $inline_class = ( $args['inline'] ) ? ' class="csf--inline-list"' : '';
27 |
28 | echo $this->field_before();
29 |
30 | if ( isset( $this->field['options'] ) ) {
31 |
32 | $value = ( is_array( $this->value ) ) ? $this->value : array_filter( (array) $this->value );
33 | $options = $this->field['options'];
34 | $options = ( is_array( $options ) ) ? $options : array_filter( $this->field_data( $options, false, $args['query_args'] ) );
35 |
36 | if ( is_array( $options ) && ! empty( $options ) ) {
37 |
38 | echo '
';
75 |
76 | if ( $args['check_all'] ) {
77 | echo '
'. esc_html( $args['check_all_text'] ) .'
';
78 | }
79 |
80 | } else {
81 |
82 | echo ( ! empty( $this->field['empty_message'] ) ) ? esc_attr( $this->field['empty_message'] ) : esc_html__( 'No data available.', 'csf' );
83 |
84 | }
85 |
86 | } else {
87 |
88 | echo '
';
89 | echo ' field_attributes() .'/>';
90 | echo ' value, 1, false ) ) . $this->field_attributes() .'/>';
91 | echo ( ! empty( $this->field['label'] ) ) ? ''. esc_attr( $this->field['label'] ) .' ' : '';
92 | echo ' ';
93 |
94 | }
95 |
96 | echo $this->field_after();
97 |
98 | }
99 |
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/src/Features/Meta/CodestarMeta.php:
--------------------------------------------------------------------------------
1 | name = $name;
19 | $this->meta = $meta;
20 | }
21 |
22 | public function process() {
23 |
24 | /**
25 | * Create Metaboxes
26 | */
27 | foreach ( $this->meta as $box_id => $box ) {
28 | if ( empty( $box['fields'] ) && empty( $box['sections'] ) ) {
29 | continue;
30 | }
31 |
32 | // else add just the fields
33 | $this->create_metabox( $box_id, $box );
34 | }
35 |
36 | }
37 |
38 | /**
39 | * Create metabox
40 | *
41 | * @param int $box_id identifier of the metabox
42 | * @param array $box_settings paramaters for the page
43 | * @return void
44 | */
45 | private function create_metabox( $box_id, $box_settings ) {
46 |
47 | $default_args = array(
48 | 'post_type' => $this->name,
49 | 'priority' => 'high',
50 | 'context' => 'normal',
51 | 'theme' => 'light',
52 | 'data_type' => 'unserialize',
53 | );
54 |
55 | $args = array_merge( $default_args, $box_settings );
56 |
57 | if ( ! class_exists( '\CSF' ) ) {
58 | return;
59 | }
60 |
61 | // Create options
62 | \CSF::createMetabox( $box_id, $args );
63 |
64 | if ( isset( $box_settings['fields'] ) ) {
65 |
66 | $box_settings['fields'] = $this->prepare_fields( $box_settings['fields'] );
67 |
68 | $this->create_section( $box_id, $box_settings );
69 | return;
70 | }
71 |
72 | if ( isset( $box_settings['sections'] ) ) {
73 | foreach ( $box_settings['sections'] as $section ) {
74 |
75 | $section['fields'] = $this->prepare_fields( $section['fields'] );
76 | $this->create_section( $box_id, $section );
77 | }
78 | }
79 |
80 | // add filter to properly save line breaks in this meta box
81 | add_filter( sprintf( 'csf_%s_save', $box_id ), array( $this, 'sanitize_meta_save' ), 1, 3 );
82 |
83 | }
84 |
85 | /**
86 | * Create section using builtin Codestart method
87 | *
88 | * @param string $id - identifier of the section
89 | * @param array $section - parameters for the section
90 | * @return void
91 | */
92 | private function create_section( $id, $section ) {
93 |
94 | if ( ! class_exists( '\CSF' ) ) {
95 | return;
96 | }
97 | \CSF::createSection( $id, $section );
98 |
99 | }
100 |
101 | /**
102 | * Prepare fields to make sure they have all necessary parameters
103 | *
104 | * @param array $fields
105 | * @return array $fields array of fields prepared to be rendered by CodestarFields
106 | */
107 | private function prepare_fields( $fields ) {
108 |
109 | foreach ( $fields as $key => &$field ) {
110 |
111 | // Each field array needs to have an id,
112 | // but only if it wasn't provided
113 | $field_id = $field['id'] ?? $key;
114 |
115 | $fields[ $key ]['id'] = $field_id;
116 |
117 | if ( isset( $field['fields'] ) ) {
118 |
119 | $field['fields'] = $this->prepare_fields( $field['fields'] );
120 |
121 | }
122 | }
123 |
124 | // codestar framework 'prefers' keys to be a numeric index, so we return the array_values
125 | return array_values( $fields );
126 | }
127 |
128 | /**
129 | * Function to sanitize meta on save
130 | *
131 | * @param array $request with meta info
132 | * @param int $post_id
133 | * @param obj $csf class
134 | * @return array
135 | */
136 | public function sanitize_meta_save( $request, $post_id, $csf ) {
137 |
138 | if ( empty( $request ) || ! is_array( $request ) ) {
139 | return $request;
140 | }
141 |
142 | //replace line breaks on meta info to make it compatible with export
143 | array_walk_recursive(
144 | $request,
145 | function ( &$value ) {
146 | $value = str_replace( "\r\n", "\n", $value );
147 | }
148 | );
149 |
150 | return $request;
151 |
152 | }
153 | }
154 |
--------------------------------------------------------------------------------
/src/Infrastructure/Container/FailedToMakeInstance.php:
--------------------------------------------------------------------------------
1 | field, array(
20 | 'max' => 0,
21 | 'min' => 0,
22 | 'button_title' => '
',
23 | ) );
24 |
25 | if ( preg_match( '/'. preg_quote( '['. $this->field['id'] .']' ) .'/', $this->unique ) ) {
26 |
27 | echo '
'. esc_html__( 'Error: Field ID conflict.', 'csf' ) .'
';
28 |
29 | } else {
30 |
31 | echo $this->field_before();
32 |
33 | echo '
';
34 | echo '
';
35 | foreach ( $this->field['fields'] as $field ) {
36 |
37 | $field_default = ( isset( $field['default'] ) ) ? $field['default'] : '';
38 | $field_unique = ( ! empty( $this->unique ) ) ? $this->unique .'['. $this->field['id'] .'][0]' : $this->field['id'] .'[0]';
39 |
40 | CSF::field( $field, $field_default, '___'. $field_unique, 'field/repeater' );
41 |
42 | }
43 | echo '
';
44 | echo '
';
45 | echo '
';
46 | echo ' ';
47 | echo ' ';
48 | echo ' ';
49 | echo '
';
50 | echo '
';
51 | echo '
';
52 |
53 | echo '
';
54 |
55 | if ( ! empty( $this->value ) && is_array( $this->value ) ) {
56 |
57 | $num = 0;
58 |
59 | foreach ( $this->value as $key => $value ) {
60 |
61 | echo '
';
62 | echo '
';
63 | foreach ( $this->field['fields'] as $field ) {
64 |
65 | $field_unique = ( ! empty( $this->unique ) ) ? $this->unique .'['. $this->field['id'] .']['. $num .']' : $this->field['id'] .'['. $num .']';
66 | $field_value = ( isset( $field['id'] ) && isset( $this->value[$key][$field['id']] ) ) ? $this->value[$key][$field['id']] : '';
67 |
68 | CSF::field( $field, $field_value, $field_unique, 'field/repeater' );
69 |
70 | }
71 | echo '
';
72 | echo '
';
73 | echo '
';
74 | echo ' ';
75 | echo ' ';
76 | echo ' ';
77 | echo '
';
78 | echo '
';
79 | echo '
';
80 |
81 | $num++;
82 |
83 | }
84 |
85 | }
86 |
87 | echo '
';
88 |
89 | echo '
'. esc_html__( 'You cannot add more.', 'csf' ) .'
';
90 | echo '
'. esc_html__( 'You cannot remove more.', 'csf' ) .'
';
91 | echo '
'. $args['button_title'] .' ';
92 |
93 | echo $this->field_after();
94 |
95 | }
96 |
97 | }
98 |
99 | public function enqueue() {
100 |
101 | if ( ! wp_script_is( 'jquery-ui-sortable' ) ) {
102 | wp_enqueue_script( 'jquery-ui-sortable' );
103 | }
104 |
105 | }
106 |
107 | }
108 | }
109 |
--------------------------------------------------------------------------------
/lib/codestar-framework/classes/widget-options.class.php:
--------------------------------------------------------------------------------
1 | '',
17 | 'classname' => '',
18 | 'description' => '',
19 | 'width' => '',
20 | 'class' => '',
21 | 'fields' => array(),
22 | 'defaults' => array(),
23 | );
24 |
25 | public function __construct( $key, $params ) {
26 |
27 | $widget_ops = array();
28 | $control_ops = array();
29 |
30 | $this->unique = $key;
31 | $this->args = apply_filters( "csf_{$this->unique}_args", wp_parse_args( $params, $this->args ), $this );
32 |
33 | // Set control options
34 | if ( ! empty( $this->args['width'] ) ) {
35 | $control_ops['width'] = esc_attr( $this->args['width'] );
36 | }
37 |
38 | // Set widget options
39 | if ( ! empty( $this->args['description'] ) ) {
40 | $widget_ops['description'] = esc_attr( $this->args['description'] );
41 | }
42 |
43 | if ( ! empty( $this->args['classname'] ) ) {
44 | $widget_ops['classname'] = esc_attr( $this->args['classname'] );
45 | }
46 |
47 | // Set filters
48 | $widget_ops = apply_filters( "csf_{$this->unique}_widget_ops", $widget_ops, $this );
49 | $control_ops = apply_filters( "csf_{$this->unique}_control_ops", $control_ops, $this );
50 |
51 | parent::__construct( $this->unique, esc_attr( $this->args['title'] ), $widget_ops, $control_ops );
52 |
53 | }
54 |
55 | // Register widget with WordPress
56 | public static function instance( $key, $params = array() ) {
57 | return new self( $key, $params );
58 | }
59 |
60 | // Front-end display of widget.
61 | public function widget( $args, $instance ) {
62 | call_user_func( $this->unique, $args, $instance );
63 | }
64 |
65 | // get default value
66 | public function get_default( $field ) {
67 |
68 | $default = ( isset( $field['default'] ) ) ? $field['default'] : '';
69 | $default = ( isset( $this->args['defaults'][$field['id']] ) ) ? $this->args['defaults'][$field['id']] : $default;
70 |
71 | return $default;
72 |
73 | }
74 |
75 | // get widget value
76 | public function get_widget_value( $instance, $field ) {
77 |
78 | $default = ( isset( $field['id'] ) ) ? $this->get_default( $field ) : '';
79 | $value = ( isset( $field['id'] ) && isset( $instance[$field['id']] ) ) ? $instance[$field['id']] : $default;
80 |
81 | return $value;
82 |
83 | }
84 |
85 | // Back-end widget form.
86 | public function form( $instance ) {
87 |
88 | if ( ! empty( $this->args['fields'] ) ) {
89 |
90 | $class = ( $this->args['class'] ) ? ' '. $this->args['class'] : '';
91 |
92 | echo '
';
93 |
94 | foreach ( $this->args['fields'] as $field ) {
95 |
96 | $field_unique = '';
97 |
98 | if ( ! empty( $field['id'] ) ) {
99 |
100 | $field_unique = 'widget-' . $this->unique . '[' . $this->number . ']';
101 |
102 | if ( $field['id'] === 'title' ) {
103 | $field['attributes']['id'] = 'widget-'. $this->unique .'-'. $this->number .'-title';
104 | }
105 |
106 | $field['default'] = $this->get_default( $field );
107 |
108 | }
109 |
110 | CSF::field( $field, $this->get_widget_value( $instance, $field ), $field_unique );
111 |
112 | }
113 |
114 | echo '
';
115 |
116 | }
117 |
118 | }
119 |
120 | // Sanitize widget form values as they are saved.
121 | public function update( $new_instance, $old_instance ) {
122 |
123 | // auto sanitize
124 | foreach ( $this->args['fields'] as $field ) {
125 | if ( ! empty( $field['id'] ) && ( ! isset( $new_instance[$field['id']] ) || is_null( $new_instance[$field['id']] ) ) ) {
126 | $new_instance[$field['id']] = '';
127 | }
128 | }
129 |
130 | $new_instance = apply_filters( "csf_{$this->unique}_save", $new_instance, $this->args, $this );
131 |
132 | do_action( "csf_{$this->unique}_save_before", $new_instance, $this->args, $this );
133 |
134 | return $new_instance;
135 |
136 | }
137 | }
138 | }
139 |
--------------------------------------------------------------------------------
/lib/codestar-framework/views/welcome.php:
--------------------------------------------------------------------------------
1 | set_demo_mode();
24 |
25 | }
26 |
27 | // instance
28 | public static function instance() {
29 | if ( is_null( self::$instance ) ) {
30 | self::$instance = new self();
31 | }
32 | return self::$instance;
33 | }
34 |
35 | public function add_about_menu() {
36 | add_management_page( 'Codestar Framework', 'Codestar Framework', 'manage_options', 'csf-welcome', array( $this, 'add_page_welcome' ) );
37 | }
38 |
39 | public function add_page_welcome() {
40 |
41 | $section = ( ! empty( $_GET['section'] ) ) ? sanitize_text_field( wp_unslash( $_GET['section'] ) ) : '';
42 |
43 | CSF::include_plugin_file( 'views/header.php' );
44 |
45 | // safely include pages
46 | switch ( $section ) {
47 |
48 | case 'quickstart':
49 | CSF::include_plugin_file( 'views/quickstart.php' );
50 | break;
51 |
52 | case 'documentation':
53 | CSF::include_plugin_file( 'views/documentation.php' );
54 | break;
55 |
56 | case 'relnotes':
57 | CSF::include_plugin_file( 'views/relnotes.php' );
58 | break;
59 |
60 | case 'support':
61 | CSF::include_plugin_file( 'views/support.php' );
62 | break;
63 |
64 | case 'free-vs-premium':
65 | CSF::include_plugin_file( 'views/free-vs-premium.php' );
66 | break;
67 |
68 | default:
69 | CSF::include_plugin_file( 'views/about.php' );
70 | break;
71 |
72 | }
73 |
74 | CSF::include_plugin_file( 'views/footer.php' );
75 |
76 | }
77 |
78 | public static function add_plugin_action_links( $links, $plugin_file ) {
79 |
80 | if ( $plugin_file === 'codestar-framework/codestar-framework.php' && ! empty( $links ) ) {
81 | $links['csf--welcome'] = '
Settings ';
82 | if ( ! CSF::$premium ) {
83 | $links['csf--upgrade'] = '
Upgrade ';
84 | }
85 | }
86 |
87 | return $links;
88 |
89 | }
90 |
91 | public static function add_plugin_row_meta( $links, $plugin_file ) {
92 |
93 | if ( $plugin_file === 'codestar-framework/codestar-framework.php' && ! empty( $links ) ) {
94 | $links['csf--docs'] = '
Documentation ';
95 | }
96 |
97 | return $links;
98 |
99 | }
100 |
101 | public function set_demo_mode() {
102 |
103 | $demo_mode = get_option( 'csf_demo_mode', false );
104 |
105 | $demo_activate = ( ! empty( $_GET[ 'csf-demo' ] ) ) ? sanitize_text_field( wp_unslash( $_GET[ 'csf-demo' ] ) ) : '';
106 |
107 | if ( ! empty( $demo_activate ) ) {
108 |
109 | $demo_mode = ( $demo_activate === 'activate' ) ? true : false;
110 |
111 | update_option( 'csf_demo_mode', $demo_mode );
112 |
113 | }
114 |
115 | if ( ! empty( $demo_mode ) ) {
116 |
117 | CSF::include_plugin_file( 'samples/admin-options.php' );
118 |
119 | if ( CSF::$premium ) {
120 |
121 | CSF::include_plugin_file( 'samples/customize-options.php' );
122 | CSF::include_plugin_file( 'samples/metabox-options.php' );
123 | CSF::include_plugin_file( 'samples/nav-menu-options.php' );
124 | CSF::include_plugin_file( 'samples/profile-options.php' );
125 | CSF::include_plugin_file( 'samples/shortcode-options.php' );
126 | CSF::include_plugin_file( 'samples/taxonomy-options.php' );
127 | CSF::include_plugin_file( 'samples/widget-options.php' );
128 | CSF::include_plugin_file( 'samples/comment-options.php' );
129 |
130 | }
131 |
132 | }
133 |
134 | }
135 |
136 | }
137 |
138 | CSF_Welcome::instance();
139 | }
140 |
--------------------------------------------------------------------------------
/src/Models/Taxonomy.php:
--------------------------------------------------------------------------------
1 | is_disabled() ) {
15 | return;
16 | }
17 |
18 | $this->set_options( $this->get_default_options() );
19 |
20 | $this->set_labels( $this->get_default_labels() );
21 |
22 | $this->set_associations( $this->get_default_associations() );
23 |
24 | $this->set_meta();
25 |
26 | $this->register();
27 | }
28 |
29 | /**
30 | * Set config defaults
31 | *
32 | * Make public and change menu position
33 | *
34 | * @return array The list of config settings
35 | */
36 | private function get_default_options() {
37 | $options = [];
38 | if ( ! $this->config->has( 'type' ) ) {
39 | return $options;
40 | }
41 |
42 | $config['hierarchical'] = false;
43 | if ( in_array( $this->config->get( 'type' ), [ 'cat', 'category' ], true ) ) {
44 | $config['hierarchical'] = true;
45 | }
46 |
47 | // show in rest api by default
48 | $config['show_in_rest'] = true;
49 |
50 | return $config;
51 | }
52 |
53 | /**
54 | * Set default labels
55 | *
56 | * Create an labels array and implement default singular and plural labels
57 | *
58 | * @return array The list of Labels
59 | */
60 | private function get_default_labels() {
61 | $labels = [
62 | 'menu_name' => $this->many,
63 | 'name' => $this->many,
64 | 'singular_name' => $this->one,
65 | 'search_items' => 'Search ' . $this->many,
66 | 'popular_items' => 'Popular ' . $this->many,
67 | 'all_items' => 'All ' . $this->many,
68 | 'parent_item' => 'Parent ' . $this->one,
69 | 'parent_item_colon' => 'Parent ' . $this->one . ':',
70 | 'edit_item' => 'Edit ' . $this->one,
71 | 'view_item' => 'View ' . $this->one,
72 | 'update_item' => 'Update ' . $this->one,
73 | 'add_new_item' => 'Add New ' . $this->one,
74 | 'new_item_name' => 'New ' . $this->one . ' Name',
75 | 'separate_items_with_commas' => 'Separate ' . strtolower( $this->many ) . ' with commas',
76 | 'add_or_remove_items' => 'Add or remove ' . strtolower( $this->many ),
77 | 'choose_from_most_used' => 'Choose from the most used ' . strtolower( $this->many ),
78 | 'not_found' => 'No ' . strtolower( $this->many ) . ' found.',
79 | 'no_terms' => 'No ' . strtolower( $this->many ),
80 | 'items_list_navigation' => $this->many . ' list navigation',
81 | 'items_list' => $this->many . ' list',
82 | ];
83 |
84 | return $labels;
85 | }
86 |
87 | private function get_default_associations() {
88 | return [];
89 | }
90 |
91 | /**
92 | * Set Object types association to this taxonomy
93 | */
94 | private function set_associations( array $associations ) {
95 | if ( ! $this->config->has( 'associations' ) ) {
96 | $this->associations = $associations;
97 | return;
98 | }
99 |
100 | $custom_associations = $this->config->get( 'associations' );
101 | if ( is_array( $custom_associations ) ) {
102 | $this->associations = array_replace( $associations, $custom_associations );
103 | return;
104 | }
105 | $this->associations = $custom_associations;
106 | }
107 |
108 | /**
109 | *
110 | *
111 | */
112 | private function set_meta() {
113 |
114 | $meta = [];
115 | if ( $this->config->has( 'meta' ) ) {
116 | $meta = $this->config->get( 'meta' );
117 | }
118 | $this->args['meta'] = $meta;
119 | }
120 |
121 | /**
122 | * Register Taxonomy
123 | *
124 | * Uses extended-cpts if available.
125 | *
126 | * @see https://github.com/johnbillion/extended-cpts
127 | *
128 | * @return void
129 | */
130 | private function register() {
131 | $args = array_merge( $this->args, $this->options );
132 | register_taxonomy( $this->name, $this->associations, $args );
133 | add_action( 'init', array( $this, 'register_associations' ) );
134 | }
135 |
136 | public function register_associations() {
137 | if ( $this->associations === null || ! is_array( $this->associations ) ) {
138 | return;
139 | }
140 |
141 | foreach ( $this->associations as $association ) {
142 | register_taxonomy_for_object_type( $this->name, $association );
143 | }
144 | }
145 |
146 | /**
147 | * Get the type of the model
148 | *
149 | * @return string The type of Model
150 | */
151 | public function get_type() {
152 | return 'taxonomy';
153 | }
154 | }
155 |
--------------------------------------------------------------------------------
/lib/codestar-framework/fields/dimensions/dimensions.php:
--------------------------------------------------------------------------------
1 | field, array(
20 | 'width_icon' => '
',
21 | 'height_icon' => '
',
22 | 'width_placeholder' => esc_html__( 'width', 'csf' ),
23 | 'height_placeholder' => esc_html__( 'height', 'csf' ),
24 | 'width' => true,
25 | 'height' => true,
26 | 'unit' => true,
27 | 'show_units' => true,
28 | 'units' => array( 'px', '%', 'em' )
29 | ) );
30 |
31 | $default_values = array(
32 | 'width' => '',
33 | 'height' => '',
34 | 'unit' => 'px',
35 | );
36 |
37 | $value = wp_parse_args( $this->value, $default_values );
38 | $unit = ( count( $args['units'] ) === 1 && ! empty( $args['unit'] ) ) ? $args['units'][0] : '';
39 | $is_unit = ( ! empty( $unit ) ) ? ' csf--is-unit' : '';
40 |
41 | echo $this->field_before();
42 |
43 | echo '
';
75 |
76 | echo $this->field_after();
77 |
78 | }
79 |
80 | public function output() {
81 |
82 | $output = '';
83 | $element = ( is_array( $this->field['output'] ) ) ? join( ',', $this->field['output'] ) : $this->field['output'];
84 | $prefix = ( ! empty( $this->field['output_prefix'] ) ) ? $this->field['output_prefix'] .'-' : '';
85 | $important = ( ! empty( $this->field['output_important'] ) ) ? '!important' : '';
86 | $unit = ( ! empty( $this->value['unit'] ) ) ? $this->value['unit'] : 'px';
87 | $width = ( isset( $this->value['width'] ) && $this->value['width'] !== '' ) ? $prefix .'width:'. $this->value['width'] . $unit . $important .';' : '';
88 | $height = ( isset( $this->value['height'] ) && $this->value['height'] !== '' ) ? $prefix .'height:'. $this->value['height'] . $unit . $important .';' : '';
89 |
90 | if ( $width !== '' || $height !== '' ) {
91 | $output = $element .'{'. $width . $height .'}';
92 | }
93 |
94 | $this->parent->output_css .= $output;
95 |
96 | return $output;
97 |
98 | }
99 |
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/src/Features/SingleExport/SaltusSingleExport.php:
--------------------------------------------------------------------------------
1 | name = $name;
27 | $this->label = ! empty( $args['label'] ) ? $args['label'] : 'Export This';
28 | }
29 |
30 | public function process() {
31 | add_action( 'init', array( $this, 'init' ) );
32 | }
33 |
34 | /**
35 | * Get hooked in: Part II
36 | *
37 | */
38 | public function init() {
39 |
40 | if ( ! current_user_can( 'export' ) ) {
41 | return;
42 | }
43 |
44 | add_filter( 'export_args', array( $this, 'export_args' ) );
45 | add_filter( 'query', array( $this, 'query' ) );
46 | add_action( 'post_submitbox_misc_actions', array( $this, 'post_submitbox_misc_actions' ) );
47 |
48 | }
49 | /**
50 | * Insert our action link into the submit box
51 | *
52 | */
53 | public function post_submitbox_misc_actions( $post ) {
54 |
55 | // if it's not out cpt, do nothing
56 | if ( ! isset( $post->post_type ) || $post->post_type !== $this->name ) {
57 | return;
58 | }
59 |
60 | ?>
61 |
74 |
75 | '',
79 | 'export_single' => $post->ID,
80 | '_wpnonce' => wp_create_nonce( 'single_export' ),
81 | ),
82 | admin_url( 'export.php' )
83 | );
84 | ?>
85 |
label ); ?>
86 |
87 | prepare(
140 | "SELECT ID FROM {$wpdb->posts} WHERE {$wpdb->posts}.post_type = 'post' AND {$wpdb->posts}.post_status != 'auto-draft' AND {$wpdb->posts}.post_date >= %s AND {$wpdb->posts}.post_date < %s",
141 | // phpcs:ignore: WordPress.DateTime.RestrictedFunctions.date_date
142 | date( 'Y-m-d', strtotime( self::FAKE_DATE ) ),
143 | // phpcs:ignore: WordPress.DateTime.RestrictedFunctions.date_date
144 | date( 'Y-m-d', strtotime( '+1 month', strtotime( self::FAKE_DATE ) ) )
145 | );
146 |
147 | if ( $test !== $query ) {
148 | return $query;
149 | }
150 |
151 | // divide query
152 | $split = explode( 'WHERE', $query );
153 | // replace WHERE clause
154 | $split[1] = $wpdb->prepare( " {$wpdb->posts}.ID = %d", intval( $_GET['export_single'] ) );
155 | // put query back together
156 | $query = implode( 'WHERE', $split );
157 |
158 | return $query;
159 | }
160 |
161 | }
162 |
163 |
--------------------------------------------------------------------------------
/lib/codestar-framework/fields/media/media.php:
--------------------------------------------------------------------------------
1 | field, array(
20 | 'url' => true,
21 | 'preview' => true,
22 | 'preview_width' => '',
23 | 'preview_height' => '',
24 | 'library' => array(),
25 | 'button_title' => esc_html__( 'Upload', 'csf' ),
26 | 'remove_title' => esc_html__( 'Remove', 'csf' ),
27 | 'preview_size' => 'thumbnail',
28 | ) );
29 |
30 | $default_values = array(
31 | 'url' => '',
32 | 'id' => '',
33 | 'width' => '',
34 | 'height' => '',
35 | 'thumbnail' => '',
36 | 'alt' => '',
37 | 'title' => '',
38 | 'description' => ''
39 | );
40 |
41 | // fallback
42 | if ( is_numeric( $this->value ) ) {
43 |
44 | $this->value = array(
45 | 'id' => $this->value,
46 | 'url' => wp_get_attachment_url( $this->value ),
47 | 'thumbnail' => wp_get_attachment_image_src( $this->value, 'thumbnail', true )[0],
48 | );
49 |
50 | }
51 |
52 | $this->value = wp_parse_args( $this->value, $default_values );
53 |
54 | $library = ( is_array( $args['library'] ) ) ? $args['library'] : array_filter( (array) $args['library'] );
55 | $library = ( ! empty( $library ) ) ? implode(',', $library ) : '';
56 | $preview_src = ( $args['preview_size'] !== 'thumbnail' ) ? $this->value['url'] : $this->value['thumbnail'];
57 | $hidden_url = ( empty( $args['url'] ) ) ? ' hidden' : '';
58 | $hidden_auto = ( empty( $this->value['url'] ) ) ? ' hidden' : '';
59 | $placeholder = ( empty( $this->field['placeholder'] ) ) ? ' placeholder="'. esc_html__( 'Not selected', 'csf' ) .'"' : '';
60 |
61 | echo $this->field_before();
62 |
63 | if ( ! empty( $args['preview'] ) ) {
64 |
65 | $preview_width = ( ! empty( $args['preview_width'] ) ) ? 'max-width:'. esc_attr( $args['preview_width'] ) .'px;' : '';
66 | $preview_height = ( ! empty( $args['preview_height'] ) ) ? 'max-height:'. esc_attr( $args['preview_height'] ) .'px;' : '';
67 | $preview_style = ( ! empty( $preview_width ) || ! empty( $preview_height ) ) ? ' style="'. esc_attr( $preview_width . $preview_height ) .'"': '';
68 |
69 | echo '
';
70 | echo '
';
71 | echo '
';
72 | echo '
';
73 | echo '
';
74 |
75 | }
76 |
77 | echo '
';
82 |
83 | echo '
';
84 | echo '
';
85 | echo '
';
86 | echo '
';
87 | echo '
';
88 | echo '
';
89 | echo '
';
90 |
91 | echo $this->field_after();
92 |
93 | }
94 |
95 | }
96 | }
97 |
--------------------------------------------------------------------------------