• Resolved Rahul Balakrishna

    (@rahulbalakrishna)


    Hi,

    In the Add/Edit Listing page when I enter the Yoast and Listing details and click on Save/Publish then it only saves the entered Listing details, not the entered Yoast details. Can someone please confirm if this plugin is compatible with the Yoast plugin?

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Support EricStylemixThemes

    (@ericstylemixthemes)

    Hello @rahulbalakrishna

    Thank you for reaching out!

    We detected some compatibility issues with the SEO plugins in the uListing plugin. Currently, the uListing plugin doesn’t support the SEO settings. The compatibility update will be included in our future releases.

    Kind regards

    I just fixed this yesterday. The Edit Listing page in the admin reloads the page after the form is save which is why your Yoast elements aren’t saved. It must be changed to submit the page.

    assets/js/admin/dist/app.js

    Replace:

    ei(this.getAjaxUrl+"?action=uListing_listing_save","POST",n).then((function(t){return t.json()})).then((function(e){if(c(e.message,e.status),t.change_type=!0,t.load=!1,t.status_helper=t.post_status,e.redirect_url&&t.is_create)return window.location.replace(e.redirect_url),!0;window.location.reload()})).catch((function(t){return console.log(t)}))}

    With:

    ei(this.getAjaxUrl+"?action=uListing_listing_save","POST",n).then((function(t){return t.json()})).then((function(e){if(c(e.message,e.status),t.change_type=!0,t.load=!1,t.status_helper=t.post_status,e.redirect_url&&t.is_create)return document.getElementById('post').submit()})).catch((function(t){return console.log(t)}))}

    Thread Starter Rahul Balakrishna

    (@rahulbalakrishna)

    @mdabrowski78 Thank you for your response. I tried and the admin does not reload the page after the listing form is saved. But it does not submit the page i.e. the form with ID ‘post’. Any suggestions

    You may need to change your version number in the plugin for it to recognize the new code
    edit ulisting.php and change version number, or do a hard refresh, and/or reload the php change manually in the browser to make sure the .js change made it into the file.

    This was very hard to fix for me, and it took many attempts, and I needed to try several times to make sure that the .js file was refreshing my change… but you will succeed in the end, so long as you remove the window.location.refresh() and reload() events and replace with the document.getElementById(‘post’).submit() event and get that .js file to update with your changes.

    Good luck

    @rahulbalakrishna we found bugs with our solution. Even though I had success getting Yoast content to save, it ended yup erasing uListing categories and other uListing data elements because those need to be saved through the plugin and not through wordpress’s regular edit page post processing.

    So, back to trying different solution. If we find something that works we will update you.

    Thread Starter Rahul Balakrishna

    (@rahulbalakrishna)

    @mdabrowski78 Thank you for the update. I really appreciate your effort.

    Hi,

    @mdabrowski78, @rahulbalakrishna,

    thank you for providing a solution, it could be used as a temporary fix until we will release a fix for this incompatibility with YOAST. Hope the needed fix will be released soon.

    regards

    @rahulbalakrishna Success! We have overcome the Yoast limitations for now.

    You will need to adjust these to your needs and be comfortable with changing the StmListing.php code until the developer can implement Yoast support. Our solution is just a workaround.

    Our solution:

    1. Add 3 Custom Fields to get SEO data in your listing form (users do not fill in the Yoast box):
    – SEO Title
    – SEO Description
    – SEO Image Path
    2. Modify the includes/classes/StmListing.php to make function calls to Yoast to copy the contents of these custom fields to Yoast’s expected Meta fields.

    Make the following changes to the uListing_listing_save() function, and modify these to reflect your preferred defaults and field names:

    FIRST CHUNK – After $options is defined

                    $options = isset($request_data['options']) ? apply_filters('uListing-sanitize-data', $request_data['options']) : [];
                    if ( !empty($options) ) {
    
    					// HACK Yoast SEO integration 
                        //
                        // We must define 3 custom fields which we capture in the edit listing page
                        //
                        //  seo_title               Text field -- Becomes SEO Title
                        //  seo_meta_descirption    Textarea field -- Becomes SEO Title
                        //  seo_image_path          Text field -- Becomes twitter and facebook image. 
    
                        // uListing Options contains arrays of values. We must split into array of Keys and Values
                        // for easy lookup
    
    			        foreach ($options as $key => $value) {
    			            if (is_array($value)) {
    			                foreach ($value as $k => $v) {
    			                    if ($k === 'meta')
    			                        continue;
    			                    if ($k == 'value' AND is_array($v))
    			                    	continue;
    			                    				
    								$variableAccessKeys[$key] = $k;
    								$variableAccessVals[$key] = $v;
    							}
    						}
    					}
    				
                        // Prepopulate SEO Title and SEO Meta Description fields from standard Title, and Description fields
    
    					if (array_key_exists('seo_title', $options) && 
    						array_key_exists('seo_title', $variableAccessKeys) &&
    						$options['seo_title'][$variableAccessKeys['seo_title']] == '') {
    						$options['seo_title'][$variableAccessKeys['seo_title']]	= $request_data['title'];
    					}
    
    					if (array_key_exists('description', $options) && 
    						array_key_exists('seo_meta_description', $variableAccessKeys) &&
    						$options['seo_meta_description'][$variableAccessKeys['seo_meta_description']] == '') {
    						$options['seo_meta_description'][$variableAccessKeys['seo_meta_description']] = $variableAccessVals['description']; 
    					}	
    
    					// End HACK	

    NEXT CHUNK – Look after $listing->save()

    
    $result['redirect_url'] = admin_url("post.php?post=". $listing->ID ."&action=edit");
                    $listing->save();
                    
                    // HACK Yoast SEO integration continued
                    //
                    // Set yoast fields for title and meta description
    	            
    	            if (array_key_exists('title', $request_data)) {    
    					update_post_meta($post_id, '_genesis_title', $request_data['title'] . ' - DayBack Calendar');
    			        update_post_meta($post_id, '_yoast_wpseo_title', $request_data['title'] . ' - DayBack Calendar');
    			    }
    
    				update_post_meta($post_id, '_genesis_description', $variableAccessVals['seo_meta_description']);
    		        update_post_meta($post_id, '_yoast_wpseo_metadesc', $variableAccessVals['seo_meta_description']);
    
    				// If an image has been specified, strip sizing, look up the asset in the database to get
                    // the image ID. Assign the twitter image and image ID
    
    				if ($variableAccessVals['seo_image_path'] != '') {
    					update_post_meta($post_id, '_yoast_wpseo_opengraph-image', $variableAccessVals['seo_image_path']);
    					update_post_meta($post_id, '_yoast_wpseo_twitter-image', $variableAccessVals['seo_image_path']);				
    					
    					$imgUrl = $variableAccessVals['seo_image_path'];
    					$imgUrl = preg_replace("/-(\d+)x(\d+)\.png/", '.png', $variableAccessVals['seo_image_path']);
    					
    					// Grab the Image ID by URL
    				    global $wpdb;
    					$attachment = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE guid='%s';", $imgUrl)); 
    					$imgID = $attachment[0]; 
    					
    					if ($imgID > 0) {
    						update_post_meta($post_id, '_yoast_wpseo_opengraph-image-id', $imgID);
    						update_post_meta($post_id, '_yoast_wpseo_twitter-image-id', $imgID);						
    					}
    				}
    				
    				// End SeedCode
    				
                    $result['status']   = 'success';
                    $result['success']  = true;
                    $result['message']  = __('Listing saved successfully', 'ulisting');
    
    • This reply was modified 2 years, 9 months ago by mdabrowski78.
    • This reply was modified 2 years, 9 months ago by mdabrowski78.
    • This reply was modified 2 years, 9 months ago by mdabrowski78.
    • This reply was modified 2 years, 9 months ago by mdabrowski78.
    Plugin Support mgordonStylemixThemes

    (@mgordon7)

    We are glad that you have sorted it on your own. However, kindly note that our testing department will check the core and provide the results to our devs team to include all the needed fixes with SEO plugins. This kind of deep check of compatibility requires more time. We do believe that the integration will be included as soon as possible

    Cheers

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Is the plugin compatible with Yoast plugin’ is closed to new replies.