Change product_base programmatically

Use your plugin activation hook to make the change. That will only run once, when your plugin is first activated, allowing the user to overwrite that change later (if they want to). register_activation_hook( __FILE__, function () { if ( $permalinks = get_option( ‘woocommerce_permalinks’ ) ) { $permalinks[‘product_base’] = ‘property’; update_option( ‘woocommerce_permalinks’, $permalinks ); flush_rewrite_rules(); } … Read more

Encoding Method for URLs?

On a lower level, the function sanitize_title_with_dashes() converts to lowercase, replaces spaces and non-alphanumeric characters with dashes, and urlencodes whatever you pass to it. <?php echo sanitize_title_with_dashes( ‘This is my blog post’ ); // this-is-my-blog-post

Remove Default Blogroll Links via Plugin script

Haven’t tested this yet, but it should do the trick in 3x: // Get all the existing links $arr_args = array( ‘hide_invisible’ => 0 ); $arr_links = get_bookmarks( $arr_args ); // Run through the list and delete ’em foreach($arr_links as $obj_link) { wp_delete_link($obj_link->link_id); } Of course, you’d only want to do this once, and only … Read more

Error passing post_content to function

Hi @Scott B: Here’s a modified version of what you have that resolves the error (although the XPath does not match; I’m not an XPath guru so can’t help with the proper XPath syntax): add_filter(‘wp_insert_post_data’, ‘my_bold_keyword’, 10, 2 ); function my_bold_keyword( $data, $postarr ) { $myKeyword = “test 123”; $d = new DOMDocument(); $d->loadHTML($postarr[‘post_content’]); //ERROR … Read more