cmb2 tinymce menu bar not showing - html

I'm using CMB2 to allow for front end submissions using a custom post type. The code works well but the problem is that it doesn't support menu bar. There's the textarea, submit button and the title but menu bar is not showing. What could be the problem?
Below is my code:
$cmb->add_field( array(
'name' => __( 'New Post Content', 'wds-post-submit' ),
'id' => 'submitted_post_content',
'type' => 'wysiwyg',
'options' => array(
'wpautop' => true, // use wpautop?
'media_buttons' => true, // show insert/upload button(s)
'textarea_name' => $editor_id, // set the textarea name to something different, square brackets [] can be used here
'textarea_rows' => get_option('default_post_edit_rows', 10), // rows="..."
'tabindex' => true,
'editor_css' => '', // intended for extra styles for both visual and HTML editors buttons, needs to include the `<style>` tags, can use "scoped".
'editor_class' => '', // add extra class(es) to the editor textarea
'teeny' => false, // output the minimal editor config used in Press This
'dfw' => false, // replace the default fullscreen with DFW (needs specific css)
'tinymce' => array(
'menubar' => true;
), // load TinyMCE, can be used to pass settings directly to TinyMCE using an array()
'quicktags' => true // load Quicktags, can be used to pass settings directly to Quicktags using an array()
),
) );

A little late, but: change
'menubar' => true;
to
'menubar' => true,

Related

Custom loading MediaWiki skinScripts

I'm about to set up some custom JS and CSS using something like this in LocalSettings.php, from here: https://www.mediawiki.org/wiki/Snippets/Load_an_additional_JavaScript_or_stylesheet_file_on_all_pages#Code
$wgResourceModules['zzz.customizations'] = array(
'styles' => "skin.css", // Stylesheet to be loaded in all skins
// Custom styles to apply only to Vector skin. Remove if you don't use it
'skinStyles' => array(
'vector' => 'skin-vector.css',
),
// End custom styles for vector
'scripts' => "skin.js", // Script file to be loaded in all skins
'localBasePath' => "$IP/customizations/",
'remoteBasePath' => "$wgScriptPath/customizations/"
);
function efCustomBeforePageDisplay( &$out, &$skin ) {
$out->addModules( array( 'zzz.customizations' ) );
}
This code shows a custom CSS that's loaded only for the vector skin, and another that's always loaded. I want to do the same with with the JavaScript, that is, load a JS file that's only for the vector skin as well as one that is always loaded.
I see from that documentation (https://www.mediawiki.org/wiki/Manual:$wgResourceModules) that skinScripts is supported, but I don't know how it would fit into the above code. Could anyone show me how to modify the above code to make that happen? Thanks.
The documentation you linked says:
skinScripts
Scripts to include in specific skin contexts.
Array keyed by skin name containing file path string or array of file path strings.
That isn't much different from the skinStyles entry, so I'd assume that something like this would work:
$wgResourceModules['zzz.customizations'] = array(
'styles' => "skin.css", // Stylesheet to be loaded in all skins
// Custom styles to apply only to Vector skin. Remove if you don't use it
'skinStyles' => array(
'vector' => 'skin-vector.css',
),
// End custom styles for vector
'scripts' => "skin.js", // Script file to be loaded in all skins
'skinScripts' => array(
'vector' => 'skin-vector.js',
),
'localBasePath' => "$IP/customizations/",
'remoteBasePath' => "$wgScriptPath/customizations/"
);
function efCustomBeforePageDisplay( &$out, &$skin ) {
$out->addModules( array( 'zzz.customizations' ) );
}
Where vector is the name of the skin, and skin-vector.js is the JavaScript file that only goes with that skin.

Yii2 Set selected value to dropdown which depends on another dropdown

I have a form in which there are two selectboxes, The second selectbox depends of the first one.
All form data are saved in session because there is a back button in order user to be able to change things after firs submitting.
So when user click's the back button I am able to assign the session value to the first dropdown but not to the second one which depends from the first one.
if(isset($session['form_1']['state_code']))
{ $state_code = $session['form_1']['form_1'];
$this->registerJs('$("select#state_select").trigger("change");');} else { $state_code = " "; }
echo $form->field($model, 'state_code')->dropDownList($states,
[ 'prompt' => ' Select state...',
'options' => [$state_code => ['Selected'=>'selected']],
'onchange' => '
$.get("'.Yii::$app->urlManager->createUrl('city?id=').
'"+$(this).val(),function( data ) {
$("select#city").html( data );
});'
]);
This code works for the first drop down
And the bellow code you can see the other drop down which does not work:
if(isset($session['form_2']['city_select']))
{ $c_id = $session['form_2']['city_select']; }
else{ $c_id = ''; }
echo $form->field($model, 'city_select')->dropDownList(['0' => 'Please select state..'],
[
'options' => [$c_id => ['Selected'=>'selected']],
]);
Any Idea ?
As an alternative you can use Kartik extension which solve your problem.

How to remove or change powered by text in elgg?

I am using elgg 2.0(alpha). Now i want to remove powered by text (in footer) and write my site name.
Default text is Powered by Elgg and link to http://elgg.org.
How can i change/remove this?
You can use the elgg basic function for that.
First register the method in init.
function theme_init() {
elgg_register_event_handler('pagesetup', 'system', 'theme_pagesetup', 1000);
}
And then
function theme_pagesetup() {
elgg_register_menu_item('footer', ElggMenuItem::factory(array(
'name' => 'powered',
'text' => 'My site', `keep empty if you dont want`
'href' => 'http://website.com',
'section' => 'meta',
'priority' => 1,
)));
}
Using this you can easily remove/change footer text.

Wordpress Customizer not Saving Data

I have a function to add a option to the wordpress customiser, its uploading an image to a header as well as a control for changing the color. the problem im having is that while i can upload and preview a color or image, after refreshing the page the change is removed, so i assume its not saving correctly?
below is the code in the functions file.
// ADD HEADER IMAGE AND COLOR TO CUSTOMIZER
function customizer_header ( $wp_customize ) {
// ADD SECTIONS
$wp_customize->add_section( 'header_section', array(
'title' => __( 'Navigation Bar', 'dc_header' ),
'priority' => 80,
) );
// ADD SETTINGS
$wp_customize->add_setting( 'header_color',
array(
'default' => '',
'sanitize_callback' => '',
) );
$wp_customize->add_setting( 'header_image',
array(
'default' => '',
'sanitize_callback' => '',
) );
// ADD CONTROLS
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize, 'header_color',
array(
'label' => __( 'Header Color' ),
'section' => 'header_section',
'settings' => 'header_color',
) ) );
$wp_customize->add_control(
new WP_Customize_Image_Control(
$wp_customize, 'header_image',
array(
'label' => __( 'Header Image', 'dc_header' ),
'section' => 'header_section',
'settings' => 'header_image',
) ) );
}
add_action( 'customize_register', 'customizer_header' );
I saw another post where someone was using this snippet, do i need to use this?
ive had it working without this in the past though but unsure whats the best way.
// ADD TO FRONTEND
function dc_header_frontend() {
?>
<style type="text/css">
#custom-header { background: <?php echo get_theme_mod( 'header_color' ); ?>; }
</style>
<?php
}
UPDATE: Found the problem to this, is was the allocated memory kept running out so upped the amount in the htaccess file, this has resolved the problem for anyone else experiencing it.

How to disable a form element in a Zend Form?

I want to display a Zend Form with one of the elements shown as disabled. I'm setting the value so the user can see it, but I want to disable it so the user can't edit it. This may also involve some sort of css/javascript to ensure that it looks like, and is not editable by the user. This is my element:
$this->addElement('text', 'username', array(
'label' => 'Username:',
'required' => true,
'filters' => array('StringTrim'),
'validators' => array(
array('StringLength', false, array(2, 50))
)
));
You should be able to use:
$this->username->setAttrib('disabled', 'disabled');
I think you can as well:
$this->addElement('text', 'username', array(
'label' => 'Username:',
'required' => true,
'filters' => array('StringTrim'),
'validators' => array(
array('StringLength', false, array(2, 50))
),
'attribs' => array('disabled' => 'disabled')
));
This works fine...
Just to complete the help:
If you are in a controller you can do:
$form->selRole->setAttribs(array('disable' => 'disable'));
selRole is the name of a select field
In latest zf2.2.1 you can do this in your controller;
$form->get('username')->setAttributes(array(
'disabled' => 'disabled',
));
$form->getElement("username")->setAttribs(array('disabled' => 'disabled', ));
or
$form->getElement("username")->setAttrib('disabled', 'disabled');
$var->setAttribs(array('disabled' => 'disabled'));
Apply this code into your Application
$formelement->setAttrib('readonly', 'true');
$formelement->setAttrib('style', 'pointer-events: none');
Only this was working for me, when using a file element when setting after form was submitted:
$element->setValueDisabled(true);
// disable checkbox using JS add-on
$checkbox->setAttribute('onclick', 'return false');
Benefit: retains the original color of the box but does not let the user change the value of the box.
Using disabled method of other answers changes the color of checkbox to "grayed out". Method described here, does not.
#Dennis:
Disabling Javascript is enough to enable the form again, so you can't truly rely on Javascript. Using native HTML disables it better, but is also simply worked around, by removing the disabled attribute.
Best option is showing the values you want instead of the form itself and disable the form and/or it's elements.
Wish I could add the comment directly to your post, but I'm some rep short.