Skip to content

Commit 8d2a072

Browse files
committed
enqueue method iproved
1 parent 432a36a commit 8d2a072

File tree

9 files changed

+27
-27
lines changed

9 files changed

+27
-27
lines changed

assets/js/csf.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,21 @@
565565
data_editor = $textarea.data('editor'),
566566
code_editor = CodeMirror.fromTextArea( $textarea[0], data_editor );
567567

568+
// load code-mirror theme css.
569+
if( data_editor.theme !== 'default' ) {
570+
571+
var $cssLink = $('<link>');
572+
573+
$('#csf-codemirror-css').append( $cssLink );
574+
575+
$cssLink.attr({
576+
rel: 'stylesheet',
577+
type: 'text/css',
578+
href: data_editor.cdnURL +'/theme/'+ data_editor.theme +'.min.css'
579+
});
580+
581+
}
582+
568583
CodeMirror.modeURL = data_editor.cdnURL +'/mode/%N/%N.min.js';
569584
CodeMirror.autoLoadMode(code_editor, data_editor.mode);
570585

assets/js/csf.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

classes/setup.class.php

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ class CSF {
2323
'metaboxes' => array(),
2424
'shortcoders' => array(),
2525
'taxonomy_options' => array(),
26-
'once_enqueue' => array(),
2726
);
2827

2928
// shortcode instances
@@ -345,15 +344,11 @@ public static function add_admin_enqueue_scripts() {
345344
if( ! empty( $field['type'] ) ) {
346345
$classname = 'CSF_Field_' . $field['type'];
347346
self::maybe_include_field( $field['type'] );
348-
if( class_exists( $classname ) && method_exists( $classname, 'enqueue' ) || method_exists( $classname, 'once_enqueue' ) ) {
347+
if( class_exists( $classname ) && method_exists( $classname, 'enqueue' ) ) {
349348
$instance = new $classname( $field );
350349
if( method_exists( $classname, 'enqueue' ) ) {
351350
$instance->enqueue();
352351
}
353-
if( method_exists( $classname, 'once_enqueue' ) && ! in_array( $classname, $enqueued ) ) {
354-
$instance->once_enqueue();
355-
$enqueued[] = $classname;
356-
}
357352
unset( $instance );
358353
}
359354
}
@@ -446,18 +441,13 @@ public static function createField( $field = array(), $is_ajax = false ) {
446441

447442
self::maybe_include_field( $field['type'] );
448443

449-
if( class_exists( $classname ) && method_exists( $classname, 'enqueue' ) || method_exists( $classname, 'once_enqueue' ) ) {
444+
if( class_exists( $classname ) && method_exists( $classname, 'enqueue' ) ) {
450445

451446
$instance = new $classname( $field );
452447
if( method_exists( $classname, 'enqueue' ) ) {
453448
$instance->enqueue();
454449
}
455450

456-
if( method_exists( $classname, 'once_enqueue' ) && ! in_array( $classname, $loaded ) ) {
457-
$instance->once_enqueue();
458-
$loaded[] = $classname;
459-
}
460-
461451
unset( $instance );
462452

463453
}

fields/code_editor/code_editor.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public function render() {
2222
$default_settings = array(
2323
'tabSize' => 2,
2424
'lineNumbers' => true,
25+
'theme' => 'default',
2526
'mode' => 'htmlmixed',
2627
'cdnURL' => $this->cdn_url . $this->version,
2728
);
@@ -47,12 +48,6 @@ public function enqueue() {
4748
wp_enqueue_style( 'csf-codemirror', $this->cdn_url . $this->version .'/lib/codemirror.min.css', array(), $this->version );
4849
}
4950

50-
$theme = ( ! empty( $this->field['settings']['theme'] ) ) ? $this->field['settings']['theme'] : '';
51-
52-
if( ! empty( $theme ) && ! wp_style_is( 'csf-codemirror-theme-'. $theme ) ) {
53-
wp_enqueue_style( 'csf-codemirror-theme-'. $theme, $this->cdn_url . $this->version .'/theme/'. $theme .'.min.css', array( 'csf-codemirror' ), $this->version );
54-
}
55-
5651
}
5752

5853
}

fields/typography/typography.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ public function create_select( $options, $name, $placeholder = '', $is_multiple
329329

330330
}
331331

332-
public function once_enqueue() {
332+
public function enqueue() {
333333

334334
if( ! wp_style_is( 'csf-webfont-loader' ) ) {
335335

fields/wp_editor/wp_editor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function render() {
5151

5252
}
5353

54-
public function once_enqueue() {
54+
public function enqueue() {
5555

5656
if( csf_wp_editor_api() && function_exists( 'wp_enqueue_editor' ) ) {
5757

languages/csf.pot

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,15 @@ msgstr ""
7171
msgid "Reset All"
7272
msgstr ""
7373

74-
#: classes/setup.class.php:377
74+
#: classes/setup.class.php:372
7575
msgid "Ooops! This field type (%s) can not be used here, yet."
7676
msgstr ""
7777

78-
#: classes/setup.class.php:420
78+
#: classes/setup.class.php:415
7979
msgid "This field class is not available!"
8080
msgstr ""
8181

82-
#: classes/setup.class.php:424
82+
#: classes/setup.class.php:419
8383
msgid "This type is not found!"
8484
msgstr ""
8585

samples/options.samples.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1393,9 +1393,9 @@
13931393
'id' => 'code_editor_2',
13941394
'type' => 'code_editor',
13951395
'title' => 'Code Editor',
1396-
'subtitle' => '<strong>HTML Editor</strong> Using: theme: mdn-like and mode: htmlmixed',
1396+
'subtitle' => '<strong>HTML Editor</strong> Using: theme: shadowfox and mode: htmlmixed',
13971397
'settings' => array(
1398-
'theme' => 'mdn-like',
1398+
'theme' => 'shadowfox',
13991399
'mode' => 'htmlmixed',
14001400
),
14011401
'default' =>'<div class="wrapper">

views/relnotes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<li>Added: Validate URL function callback. <a href="http://codestarframework.com/documentation/#/faq?id=how-to-use-validate-" target="_blank"><small>(doc)</small></a></li>
99
<li>Fixed: Group field save issue.</li>
1010
<li>Fixed: Multiple given post formats metabox hide/show issue.</li>
11-
<li>Fixed: Minor Bugs.</li>
11+
<li>Fixed: Minor bugs.</li>
1212
</ul>
1313

1414
<h3>v2.0</h3>

0 commit comments

Comments
 (0)