Access Plugin data from Functions.php

Your syntax is slightly off in a few places. I’ll try and let the code explain: function wpse_199498_meta_to_table( $post_id, $post ) { // Use the second argument of our hook, which is the post object if ( $post->post_type !== ‘festival-event’ ) return; global $wpdb; // Don’t need to use $_POST, just use the functions as … Read more

How to style options page in dashboard?

You can simply add those CSS to admin HEAD section, it’s fast and easy solution. function jrl_styles() { ?><style type=”text/css”> #jrl-wrap { width: 700px; padding: 3em; /* … */ } </style><?php } add_action(‘admin_head’, ‘jrl_styles’); Or you can enque your CSS file like this: function load_custom_wp_admin_style() { wp_register_style( ‘custom_wp_admin_css’, get_stylesheet_directory_uri() . ‘/functions/site-options.css’, false, ‘1.0.0’ ); wp_enqueue_style( … Read more

How to override a plugin function wrapped in a class?

if the modification is called in the action admin_menu you can come just after, in order to correct the menu with some code like this : add_action(“admin_menu”, function () { $parent_file=”parent.php”; $full_url = add_query_arg( ‘action’, ‘action-name’, admin_url( ‘users.php’ ) ); global $submenu; // searching the last submenu $last = array_pop($submenu[$parent_file]); // correcting the URL $last[2] … Read more

Don’t delete a page if it holds users

It gives an array with objects. So in_array() won’t find anything, you have to convert it before. After you get the results from wbdb: $employees_array = array(); foreach($employees as $employee) { $employees_array[] = $employee->meta_value; } if(in_array($company, $employees_array)) { … }

How to output a PHP file values by shortcode?

We’ve built shortcodes in the past using concatenating variables. To paraphrase the link above, you should output your PHP as such. $output=”<p>”; $output .= ‘<strong>’ . $content . ‘</strong>’; $output .= ‘</p>’; return $output; Note, see the .= variable concatenation.