Cannot DIsplay a Snackbar Notice on Button Click – Notice is undefined

I am trying to use withSelect and withDispatch to display an admin notice when "save" button is clicked. I am using the following code from this repo but it throws an error: "notices is undefined". Here is the code I am using:

import { Icon, Button, SnackbarList } from '@wordpress/components'; import { dispatch, withSelect, withDispatch } from '@wordpress/data'; import { compose } from '@wordpress/compose'; // Display and Dispatch the notice const NewNotices = ({ notices, removeNotice }) => {          //Uncaught TypeError: notices is undefined     const snackbarNotices = notices.filter((notice) => notice.type === 'snackbar');      return (         <>             <SnackbarList                 className="cwg-admin-notices"                 notices={snackbarNotices}                 onRemove={removeNotice}             />         </>     ); }  export default compose([     withSelect((select) => ({         notices: select('core/notices').getNotices(),     })),     withDispatch((dispatch) => ({         removeNotice: dispatch('core/notices').removeNotice,     })), ])(NewNotices); 
<> //Create the notice on btn click <Button    isPrimary    onClick={() =>    {    settings.save();    dispatch('core/notices')    .createNotice(    'success',    __('Settings Saved', 'slug'),    {    type: 'snackbar',    isDismissible: true,    icon:     <Icon icon="smiley" />    }    );    }}    >    {__('Save', 'slug')} </Button> <NewNotices /> </> 

Changing button alignment to center on mobile?

I have used the following code and added it to Additional CSS under theme customization:

@media only screen and (max-width: 768px) { .iphonebutton {     text-align: center !important;     padding: 0px !important;     margin: 0px !important;     display: block !important; } } 

It is not changing the alignment for mobile to center. Not sure what I am doing wrong.

My dynamic button evaluates as soon as it’s created. How do I stop this behavior?

I think I finally hit on the holy grail of buttons. I coded a dynamic autosave button whose duration and frequency can be set all the while showing very useful dynamic real time information directly in the label (button name, countdown in seconds, "saved" and beep alert when saved) without freezing the frontend or tying up the kernel. And get this, it even works when the button scrolls off screen. I have no idea how I got it to do that.

There is just one little snag. They autosave starts as soon as the button is created. No need to click or hover over it. Please help me fix this odd behavior.

There is just one more little teeny tiny thing if you don’t mind. I would like to anchor the code to a function like this dynaSave[s_,n_]:= DynamicModule[...]but it produces syntax errors.

(* dynaSave button works but oddly evaluates when created *)  Quiet@Remove["Global`*"];  DynamicModule[{   s = 10, n = Infinity, col1 = Black, col2 = RGBColor[.2, .65, .2],    bg = RGBColor[.775, .85, 1]   },  ops := Sequence[AutoAction -> True, ImageSize -> {80, 30},     Appearance -> "Palette",     BaseStyle -> {14, col1, Bold, FontFamily -> "Arial"},     Background -> bg];  actions := (NotebookSave[];Beep[];Style["SAVED", Bold, col2]);   actionclock[f_, g_] :=    Dynamic[t = f - Clock[{0, f, 1}, f, g]; If[t == 0, actions, t]];  Button[Dynamic[x, (#) &,     Initialization :> (x := "DynaSave")], (x := actionclock[s, n]) &,    ops]   ] 

How to Add Custom Button to Text(HTML) Editor and NOT Visual Editor

I followed this tutorial which is adding a custom button into Visual Editor as it is supposed to. But this is not adding the button into the Text(HTML) Editor. Can you please let me know how I can add my own button into Text(HTML) Editor only (or at least both! and not Visual one)

function enqueue_plugin_scripts($  plugin_array) {     //enqueue TinyMCE plugin script with its ID.     $  plugin_array["green_button_plugin"] =  plugin_dir_url(__FILE__) . "index.js";     return $  plugin_array; }  add_filter("mce_external_plugins", "enqueue_plugin_scripts");  function register_buttons_editor($  buttons) {     //register buttons with their id.     array_push($  buttons, "green");     return $  buttons; }  add_filter("mce_buttons", "register_buttons_editor"); 

How to edit the default icon of Add Media button?

I am trying to replace the default Add Media icon in my WordPress site. I searched for the same on the web and got this:

How to replace default icon on "Add Media" button?

This seems to work for the OP, and ofcourse should’ve worked for others too. But, I am getting confused as the answer contains words like Child Theme and all. I could understand the first part of the answer, but I lost the track when the answer talked about this:

wp_enqueue_style('my-css', get_stylesheet_directory_uri().'/css/my-admin.css' 

From where did this part of the url came: '/css/my-admin.css. I searched in my database at the backend but couldn’t find this particular file anywhere. I know this might be a silly thing to ask, but this is it. Can someone help in this regard?

How to remap one of the TinyMCE Advanced Editor button to open the wordpress media library?

I am using the TinyMCE advanced editor for my WordPress site. I want the users in the frontend to be able to upload images using the WordPress media gallery, and for this purpose I would like to remap the Insert/edit image button, or add a new button (whichever is more feasible) to open the WordPress media gallery, so that the Authors can add captions and alt text to their images:

enter image description here

I have been searching on the internet about this, but haven’t found anything fruitful yet.

Can someone help in this regard?

Image Gallery – Click Button to Show Image

I’m working on an Image Gallery with buttons to show images with an [X] in the upper right corner to close the image. While the image is displayed the screen will not be darkened, but will be frozen from clicking anything except for the [X] to close the image. In the attached code there’s a call to a CustomFunction, which is where I really need help. All of the images will be smaller that 500 x 500 pixels and will be displayed in the center of the screen. I’m hoping there’s a way to use…

Image Gallery – Click Button to Show Image