Samuel
Forum Replies Created
-
Forum: Developing with WordPress
In reply to: What’s the Best Function to Hook remove_cap To?ChatGPT solved it! I should’ve been using
__FILE__
instead of pointing the hooks to the class’s file. I didn’t knowrequire_once()
appends the file’s content into the plugin’s main file.- This reply was modified 1 year, 8 months ago by Samuel. Reason: Correct typographical error
Forum: Developing with WordPress
In reply to: What’s the Best Function to Hook remove_cap To?I found this page in the documentation, but the deactivation hook isn’t being fired, when I deactivate the plugin. The permissions aren’t being restored.
Here’s all related codes:
register_activation_hook( GUIDE_POSTS__PLUGIN_DIR . 'class.guides.php', array( 'Guides', 'activate_plugin' ) ); register_deactivation_hook( GUIDE_POSTS__PLUGIN_DIR . 'class.guides.php', array( 'Guides', 'deactivate_plugin' ) );
public static function activate_plugin() { self::register_guides_and_grant_permissions(); } public static function deactivate_plugin() { // Unregister Guides unregister_post_type( 'guides' ); flush_rewrite_rules; // Grant role permissions $editor = get_role( 'editor' ); $editor->remove_cap( 'manage_categories' ); $contributor = get_role( 'contributor' ); $contributor->remove_cap( 'upload_files' ); } public static function register_guides_and_grant_permissions() { $labels = array( 'name' => 'Guides', 'singular_name' => 'Guide', 'menu_name' => 'Guides', ); $args = array( 'labels' => $labels, 'public' => true, 'has_archive' => true, 'publicly_queryable' => true, 'query_var' => true, 'rewrite' => array( 'slug' => 'guide' ), 'capability_type' => 'post', 'hierarchical' => false, 'supports' => array( 'title', 'editor', 'thumbnail' ), 'taxonomies' => array( 'category' ), 'menu_icon' => 'dashicons-location', 'show_in_rest' => true, ); // Register the custom post type register_post_type( 'guide', $args ); // Grant role permissions $editor = get_role( 'editor' ); $editor->add_cap( 'manage_categories' ); $contributor = get_role( 'contributor' ); $contributor->add_cap( 'upload_files' ); }
Thanks! I’ll think about that carefully. I just want the posts to look like how they look like on the editor.
Yes! Thank you! How do I point it to the ones that WordPress loads in the administration pages?
No. I don’t want to load the editor styles in the administration pages. I want to load them in my theme. The images that are added and positioned in the block editor and classic editor (on custom fields using it) are not positioned properly on the posts displayed by the theme. I tried adding
add_theme_support( 'editor-style' );
but it still doesn’t position the images properly.I found the culprit. I forgot that I was manually adding the theme’s
style.css
to theheader.php
.Forum: Plugins
In reply to: [Contact Form 7] How to Configure reCAPTCHAI figured it out. I have to go to the old version and setup a classic key.
Forum: Plugins
In reply to: [Contact Form 7] How to Configure reCAPTCHAI just need to know if I must add the JavaScript provided to my theme or if Contact Form 7 already does that. Please help.
Forum: Plugins
In reply to: [Contact Form 7] How to Configure reCAPTCHAI already saw that page. reCAPTCHA doesn’t work like that anymore. The Secret Key isn’t provided once the thing is setup. It gave me a link to go to that tells me to add JavaScript into my theme. Here’s the link. It’s telling me that it needs a token.
Forum: Developing with WordPress
In reply to: Check if Featured Image Is Set Before PublishingWill this work with the block editor?
Forum: Developing with WordPress
In reply to: Check if Featured Image Is Set Before PublishingThanks!
Forum: Developing with WordPress
In reply to: Why Are The Widgets In The Dashboard Unstyled?I finally got it to load on the Widgets administration page!
Forum: Developing with WordPress
In reply to: Why Are The Widgets In The Dashboard Unstyled?I tried it hooking the function to
admin_init
but it’s not loading, so I asked ChatGPT about it and it suggestedwidgets_admin_page
but that one didn’t work either. I also tried switching fromadd_editor_style()
towp_enqueue_style()
and that didn’t load the files either. I’m attempting to load a Google Fonts file with the correct URL. Will that get in the way?- This reply was modified 1 year, 9 months ago by Samuel.
Forum: Developing with WordPress
In reply to: Why Are The Widgets In The Dashboard Unstyled?Thanks but I asked for documentation about the selectors because I’m not sure which of the styles are used by other widgets too, so it will be applied to all of the widgets. Sorry, I’m being lazy. I guess I’ll just have to do it one by one. Anyway, thanks again!
Forum: Developing with WordPress
In reply to: Why Are The Widgets In The Dashboard Unstyled?Where do I place the add_editor_style()? Within the function hooked to wp_enqueue_scripts? I tried adding it to my functions.php and it’s not loading.