Today I’m working on a feature where I’ll need to be able to select a menu on an options page in ACF inside a repeater field. I took a look and didn’t see anyone else offering up how they did this so here it goes: I started with this https://www.advancedcustomfields.com/resources/dynamically-populate-a-select-fields-choices/ and created a select field called ‘menus’.

The code then to get things to work was

function add_acf_menu_field( $field ) {

    // reset choices
    $field['choices'] = array();


    // get a list of the menus and their associated ids
    $menus = wp_get_nav_menus();
    foreach($menus as $menu) {
        $field['choices'][$menu->term_id] = $menu->name;
    }

    // return the field
    return $field;
}

add_filter('acf/prepare_field/name=menus', 'add_acf_menu_field');

Hope this helps anyone coming across the same thing.

Just uploaded a cool plugin that one of my clients let me release publicly, it’s a great little tool for people that want to draw on their images and display them on the front end.

Best of all the original image isn’t affected – you get to manage the objects on the image as separate objects and move them around, add more and delete them then save it again. It’s even mobile friendly!

Check it out here, it’s completely free and I’m sure I’ll be adding tons of new features: https://wordpress.org/plugins/image-annotator/

Enjoy!

If anyone has tried to take a Squarespace site and import it into WordPress then you have come across the issue where the images are still linked externally to Squarespace. No problem, there are plugins like Import External Images that will load those all up for you, right? Well it wasn’t so easy for me and after scouring the internet for a fix I ended up modifying the Import External Images plugin so that it uses curl to download the images instead of WordPress’ download_url function which was giving me a forbidden error. After a little tinkering and tweaking of the headers sent with the curl request I finally came up with a solution that should work for anyone having the same issue. You can download it here: http://www.moeloubani.com/downloads/import-external-images-sqspc.zip

Let me know if it works (or doesn’t)!

Edit: updated to work with image urls ending in ?format=original (or any query string after the image name for that matter).

Just released a new plugin for any fellow WordPress developers out there, it adds a contact form to the dashboard area of the back end of your or your clients’ websites so that they can contact you right from there. More or less it’s a great way to keep clients even years later where they can quickly turn to that support box for support.

You can see a picture below of what the email you get from them looks like, it includes a bunch of diagnostic info that should be helpful like their WordPress version, active plugins, PHP version, MySQL version and more. It even shows you what browser they are using in case it is a browser specific thing.

Hopefully it will be a help for some of you out there looking for something like this.

You can download it now for free here – https://wordpress.org/plugins/wp-dash-support/

Enjoy!

wpdashsupportemail

I just released a new version of my TREB RETS plugin – this one uses a new and better version of PHRets the underlying software as well as some updates to the way properties are stored. I’m also using Composer to load dependencies (if you come from a coding background – which you really should, at least a little bit, to use this plugin in the state it’s in – you’ll know what I mean, otherwise skip this part) and using it to load PHRets and the dependencies it uses. This also means that the minimum version for PHP for this plugin is now 5.4 – even though WordPress has a 5.2 minimum. 5.2 and 5.3 are way outdated now but my apologies in advance for anyone who wants to use this plugin that has to update their server.

If you’re coming from Github and want to download the plugin just click here

If you want to visit the Github repo for the plugin click here

If you want to be updated when new versions are released and when the plugin is finally going to have a full open release where everything works flawlessly, please add your email below. I’ll never contact you for anything outside of this plugin and never EVER give your emails to someone else.

Right now I’m looking for one or two people who have already signed their TREB agreements and are ready to use this plugin – if you can let me use your credentials to TREB to further develop the plugin I can install and configure it for you free of charge. More details in this post -> For Those Looking to do TREB Integrations

Any questions? I’m always happy to provide custom integration and support for those having trouble with RETS (or any web development project). You can reach me by email at moe@loubani.com.

After having to do this whole process a few times I’ve realized that there is no clear cut way to do it – there’s tutorials for older versions of Homestead and/or Windows but nothing that puts them all together. This is just my experience with how I did it and I’m sure it’ll be a bit different for everyone so feel free to leave a comment if it didn’t work for you.

For this I’m using the latest version of VirtualBox 5.0.2, Vagrant 1.7.4, Composer for Windows, WAMP 2.5 (64 bit) and Windows 8.1.

For my console I mainly use Git Bash from the Git for Windows package here – https://git-for-windows.github.io/

  1. First thing you want to do is download install VirtualBox from here – https://www.virtualbox.org/wiki/Downloads
  2. Then you need to download and install Vagrant for Windows from here – http://www.vagrantup.com/downloads.html
  3. After both are installed your computer needs a reboot. Remember this page and come back when your computer starts up.
  4. Now you install WAMP – I choose all the default settings and just hit next until it’s ready.
  5. After that is done you’ll need to install Composer. During this process you’ll be asked for the path to PHP – luckily you now have that on your Windows computer after installing WAMP so point Composer to your PHP binary (for me it was C:\wamp\bin\php\php5.5.12\php.exe)
  6. At this point I started following standard Homestead installation guides but still ran into some issues. My first one was when I went into Git Bash and tried to run the ‘vagrant box add laravel/homestead’ command and got some sort of TTY error. To fix this I tried doing the same thing but with good old Windows Command in administrator mode and it worked! (Thanks to https://github.com/Vas-ko for this tip)
  7. Now I went back into Git Bash and installed Homestead globally using Composer with the command ‘composer global require “laravel/homestead=~2.0″‘
  8. Once this was done I thought it was time to run ‘homestead init’ but I got another error – this time it told me the command wasn’t found. This means I needed to add the Composer binary path to my Windows system variables. To do this: Go to system properties (use search or search in Windows 8.1 for ‘path’ and choose Edit system variables) go to the system variables at the bottom and find one where the variable is Path and double click on the area beside it and add C:\Users\Moe\AppData\Roaming\Composer\vendor\bin (replace Moe with your username on Windows obviously) and make sure to separate it from the one before it with a semicolon ;
  9. Make sure you restart console (Git Bash) now so that the new system variables can be loaded in
  10. Time to initialize Homestead, run the ‘homestead init’ command.
  11. Now it’s time to generate your ssh keys, to do this I go to my root directory in console (cd ~ or go to C:\Users\Yourusername) and run the ‘ssh-keygen -t rsa -C “you@homestead”‘ command and choosing to leave the password blank (I just hit enter at all the prompts)
  12. Now it’s time to edit your Homestead.yaml file in order to map the server to a directory, if you’re using the default make sure you have a directory called ‘Code’ in your C:\Users\Yourusername directory

At this point you should be up and running with a configuration that matches all others so any other tutorial will apply as to where to go from here. Good luck and feel free to ask questions in the comments.

Need someone to make my plugin work for your site? I’m looking for one or two customers to help build out my plugin – in return I only ask that you help me correspond with TREB to get some additional features implemented and some questions answered.

Interested? This means a free integration for you on your WordPress site! Email me -> moe@loubani.com

If this post is still up this offer still applies!

Here is another plugin I made that works with another system TREB has that (apparently) needs less paperwork. I’ve seen people try to use this one more often than the last one but give both a try if you’re looking for real estate integration for your website in Ontario.

The installation instructions are included in the link. This plugin, like my last one, will require a template to be made that displays the properties using the custom fields they are saved in. Other than that and for setting your username and password it should be good to go out of the box and take the hard part out of integrating your site with the TREB database.

https://github.com/moeloubani/wptrebs3pv

Enjoy!

Just finished this plugin for a client to help them integrate listings from a MLS search directly onto their WordPress website instead of going through an iframe. It downloads the images and sets one as a featured image to the custom post type post it creates. It uses PHRets to connect to RETS. Since there is no agent info given in the TREB MLS listings you can enter your MLS numbers into the plugin and it will automatically crawl every 24 hours and keep the listings up to date. See the read me on Github for more info.

https://github.com/moeloubani/wptrebrets

Get in touch with me if you’d like any customizations for Toronto Real Estate Board MLS integrations using this plugin or a new custom solution.

Today I ran into a little issue with a Woocommerce extension called Customer/Order CSV Export. Whenever a custom field name ended with a question mark, the export wouldn’t return the results for that field/column. I looked into it and the problem was with some extra spaces that were for some  reason (anyone know why?) added to the beginning of the value in the array.

Here is what I did to fix it from line 295 in the main plugin file:

foreach ($extra_data_fields as $key => $value) {
	$fixed_value = $woo_order->order_custom_fields[$value]['0'];
	if (strpos($value, '?') !== false) { 
		$fixed_value = substr($fixed_value, 2);
	}
	$order_extra[ $key ] = isset($woo_order->order_custom_fields[$value]) ? $fixed_value : '';
}

One thing I couldn’t figure out was the cause of the extra spaces from the question mark. Anyone know what could be causing that?