Welcome to ManageWP.org

Register to share, discuss and vote for the best WordPress stories every day, find new ideas and inspiration for your business and network with other members of the WordPress community. Join the #1 WordPress news community!

×

1 min read Jakub Mikita
Development | btb.works | 3 days ago

Close unclosed HTML tags in PHP

Simple WordPress PHP function which closes unclosed HTML tags. Can fix broken HTML and allow safe output without any layout breaks.

Close unclosed HTML tags in PHP

Development | btb.works | 3 days ago

Recently I stumped upon a handy WordPress function which closes HTML tags. The function name is force_balance_tags().
Taking as an example unclosed list items:
echo force_balance_tags( '<ul>
<li>this
<li>is
<li>a
<li>list
</ul>' );
It will produce something like this:
<ul>
<li>this
</li><li>is
</li><li>a
</li><li>list
</li></ul>

3 min read Jakub Mikita
Development | btb.works | 26 days ago

How to fix a broken serialization

Fixing database serialization issues and recovering corrupted serialized string with a simple script

How to fix a broken serialization

Development | btb.works | 26 days ago

Serialization is a way to store multidimensional data as a string. It’s commonly used in the WordPress database, because of the architecture of the tables. When it breaks (for various reasons) it’s a disaster. But not with our handy-dandy scripts. Fixing a database dump with broken serialization
Steps are simple:
Create the database dump (you should have a .sql file)
Run the script: `./fix-serialization.php database.sql`
Upload the .sql file back to the server
The script has been created by an awesome WordPress developer – Wojtek SzaƂkiewicz.
Recovering the corrupted serialized array
If you have a variable with a string which cannot be unserialized, try to use the below function:
/**
* Extract what remains from an unintentionally truncated serialized string
*
* @param string The serialized array
*/
public function repairSerializedArray($serialized)
{
$tmp = preg_replace('/^a:\d+:\{/', '', $serialized);
return $this->repairSerializedArray_R($tmp); // operates on and whittles down the actual argument
}

/**
* The recursive function that does all of the heavy lifing. Do not call directly.

* @param string The broken serialzized array
* @return string Returns

2 min read Jakub Mikita
Development | btb.works | Jan. 20, 2020

How to access the WordPress admin without password

Logging in as an administrator, the easy way with a short snippet. Site files access required.

How to access the WordPress admin without password

Development | btb.works | Jan. 20, 2020

How many times you forgot the password or login to the website you managing. I forgot a lot of times, mostly because I didn’t save the password in the Password manager. Or I don’t get the credentials from my client. Luckily, there’s an easy way to login to the WordPress admin panel, having only the file access. The short answer is: use the wp_set_auth_cookie() function! It will save a session cookie for the provided user ID. Session cookie means you are logged in.
Here’s the snippet I’ve been using for a long time if I don’t know the user ID (plot twist – it’s not always 1).
add_action( 'send_headers', function() {
if ( ! isset( $_GET['secure-hash-295g785j46v-change-this'] )