All posts by Redactie

MAMP MYPHPADMIN Delete wordpress trash

Delete Trash from WordPress

Delete WordPress Trash from SQLAs I was testing on mij localhost (using MAMP) I run into trouble while permanently deleting several hundred products from my Trash.

Instead of using WordPress interface I decided to user MyPhPAdmin to do this. Whereas WordPress gave and timeout when only selecting a few products, via SQL the job was doen in less than 3 seconds.

Here’s the Code snippet:

DELETE wp_posts,wp_term_relationships,wp_postmeta,wp_term_taxonomy
FROM wp_posts 
LEFT JOIN wp_term_relationships ON ( wp_posts.ID = wp_term_relationships.object_id )
LEFT JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id )
LEFT JOIN wp_term_taxonomy ON ( wp_term_taxonomy.term_taxonomy_id = wp_term_relationships.term_taxonomy_id )
WHERE wp_posts.post_status='trash';

How make row in Parse Unique using Parse CloudCode

In the Parse app database there is no option to make a key (object) unique. Usually you can chat using af find before adding a row but when you use .saveinbackground()  you cannot be sure.

Best solution is to add a beforeSave trigger on Parse Server using cloud code. I’m not a cloud code specialist so it took me quite a while to figure it out but using the code below you should be able to do this pretty quick.

This needs no modification of you app.

Add this (and adust to your needs) to you main.js and upload to Parse Server.

myObjectClass is the ‘table name’ in Parse.
myKey is the ‘field’ you want to make unique within your table (object)

Parse.Cloud.beforeSave("myObjectClass", function(request, response) {
    var myObject = request.object;
    
	if (myObject.isNew()){  // only check new records, else its a update
		var query = new Parse.Query("myObjectClass");
		query.equalTo("myKey",myObject.get("myKey"));
		query.count({
			success:function(number){ //record found, don't save
				//sResult = number;
				if (number > 0 ){
					response.error("Record already exists");
				} else {
					response.success();
				}
			},
			error:function(error){ // no record found -> save
				response.success();
			}
		})
    } else {
        response.success();
    }
});

How to change text size of TabLayout Tabs in Android Studio

To change the size of the font 2 steps need to be done:

  1. Add as Style for the Tablayout
  2. Apply the style to the TabLayout in the XML

Find or create res -> values -> styles.xml

1. Add the Style to the XML

<style name="MyCustomTabText" parent="TextAppearance.Design.Tab">
    <item name="android:textSize">12sp</item>
</style>

2. Apply Style

Find the Layout containing the TabLayout and add the style. The added line is bold.

<android.support.design.widget.TabLayout
    android:id="@+id/tabs"
    app:tabTextAppearance="@style/MyCustomTabText" 
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />

 

How to Add Option / settings menu to android App

 

Add this to your mainactivity:

@Override
public boolean onCreateOptionsMenu(Menu menu){
    // Create menu
    // See onOptionItemSelected for actions when clicked

    Menu settingsMenu = menu;
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.optionmenu, menu);

    MenuItem settingsMenuLogin = settingsMenu.findItem(R.id.settingsMenuExport);

return true;
}

and

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();


    if (id == R.id.settingsMenuExport) {
        // add additional check
        Intent i = new Intent(getApplicationContext(), export.class);
        startActivity(i);
    }
    return super.onOptionsItemSelected(item);
}

and create an xml in res\menu like this:

optionmenu.xml

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">
    <item
        android:id="@+id/settingsMenuExport"
        android:orderInCategory="100"
        android:title="Export"
        app:showAsAction="never" />
</menu>

 

Database size phpadmin wordpress

WordPress Database size in phpMyAdmin

How to show WordPress database size in pypmyadminI got an email from my hosting provider that I was exceeding my wordpress database space of 1000MB, which I thought was very strange. Had 2 dabases in which I each imported content of about 50MB (gzip format). I could not find the actual database size so I did some digging around and found the SQL code below which does the trick:

SELECT table_schema "Data Base Name",
sum( data_length + index_length ) / 1024 / 1024 "Data Base Size in MB"
FROM information_schema.TABLES GROUP BY table_schema ;

Continue reading WordPress Database size in phpMyAdmin

WordPress

Proudly Powered By WordPress – Change footer

Remove ‘Proudly Powerd By WordPress’

WordPressWhen starting with a new wordpress site the footer containts ‘Proudly Powered By WordPress’. If you want to your side to look more professional, of rather link to another site then WordPress you need to change this in the footer.php.

I used to edit this using a FTP program as Filezilla. But nowadays you can edit this from the WordPress Admin it self. Continue reading Proudly Powered By WordPress – Change footer

Press This « WordPress Codex

With WordPress 4.2.1 the Press This function is introduced. The “Press This” function allows quick publishing with a special web browser bookmarklet. You can create a post by quoting some text, images, and videos on any web page.

Source: Press This « WordPress Codex

lightbox (wp lightbox 2)

Using Lightbox to display Images

Avoid Ugly Image presentation

lightbox (wp lightbox 2)One of the easiest ways to make your website more actractive is using a ‘lightbox’ for displaying images. Default action for imanges is to desplay them just plain in the browser. This is not only a ugly presentation but it is also user unfriendly.

On my main website I’ve actually been using this bad presentation for far to long, reason for this is that I didn’t not know better, or actually didn’t know how easy the solution could be.

There are several (good) plugins available which will do the trick. I tried 3 of them: Continue reading Using Lightbox to display Images

WordPress Jetpack

Jetpack: [auth_failed] Authorization header was malformed

WordPress JetpackI noticed I got the message: “Jetpack: [auth_failed] Authorization header was malformed” in my wordpress admin panel. Refreshing and Reconnecting the social media links (Facebook, Twitter, Google+) did not work.

The solution turns out pretty easy:

  1. Go to the Jetpack page in your dashboard.
  2. Click on the Debug link appearing at the bottom of the page.
  3. Click the link that says “click here to contact Jetpack support.”
  4. Fill in the description box and your name and email address.
  5. Click the “Contact Support” button.

Continue reading Jetpack: [auth_failed] Authorization header was malformed

WordPress

WordPress Heartbeat (wp-admin/admin-ajax.php)

heartbeat-control-plugin-wordpressWhile monitoring Stats of my websites wp-admin/admin-ajax.php was always on top of the list of most requested pages which made me wonder, Why is there so much activity from the wp-admin/ folder? Nobody (no regular visitor) is supposed to go there / request a page from the admin folder, right? Continue reading WordPress Heartbeat (wp-admin/admin-ajax.php)