Plugin Directory

Changeset 2174100


Ignore:
Timestamp:
10/16/2019 08:17:09 AM (6 years ago)
Author:
gma992
Message:

Updated editor metabox to work with wp5.0+

Location:
wpjm-company-profile-page/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • wpjm-company-profile-page/trunk/readme.md

    r2173686 r2174100  
    2626= 1.2 =
    2727- Tested up to WordPress 5.2.4
     28
     29= 1.2.1 =
     30- Enabled metabox for the new Editor since WP5.0+
  • wpjm-company-profile-page/trunk/readme.txt

    r2173686 r2174100  
    3131= 1.2 =
    3232* Tested up to WordPress 5.2.4
     33
     34= 1.2.1 =
     35* Enabled metabox for the new Editor since WP5.0+
  • wpjm-company-profile-page/trunk/wpjm-company-profile-page.php

    r2173686 r2174100  
    66 * Author:      Gabriel Maldonado
    77 * Author URI:  https://tilcode.blog/
    8  * Version:     1.2
     8 * Version:     1.2.1
    99 * Text Domain: wpjm-company-profile-page
    1010 * Domain Path: /languages
     
    7676    $plugin_dir_path = plugin_dir_path( __FILE__ );
    7777    $company_template_url = $plugin_dir_path . 'company-archive-page-template.php';
    78    
    79     if ( is_tax('companies') ) {
    80 
     78
     79    if ( is_tax($taxonomy="companies") ) {
     80
     81    // TODO: Sometimes this fails as is_tax() returns NULL. This can be fixed flushing the cache via $wp_rewrite->flush_rules( true ); but is an expensive operation. Would be a good idea to integrate this somehow if the page returns a 404 for example.
    8182        $template = $company_template_url;
    8283        return $template;
     
    8990
    9091/*
    91 * Creates custom companies/company taxonomy
     92* Creates custom companies/company taxonomy. This will show under Job Listings > Companies as well as within the Editor metabox
    9293*/
    9394function gma_wpjmcpp_job_taxonomy_init(){
     
    99100            'label' => __( 'Companies', 'wpjm-company-profile-page' ),
    100101            'rewrite' => array( 'slug' => 'company'),
    101             'public' => true
     102            'public' => true,
     103      /*
     104      Necessary after WP 5.0+ in order to show the metabox within the editor. Since the editor operates using the REST API, taxonomies and post types must be whitelisted to be accessible within the editor.
     105      https://developer.wordpress.org/reference/functions/register_taxonomy/
     106      */
     107      'show_in_rest' => true,
    102108        )
    103109    );
     
    206212
    207213  $data = get_post_meta( $post->ID, "_company_name", true);
     214  // ##
     215  //var_dump($data); // string(0) in http://localhost:8888/local/job/new-job-2/
     216  //wp_die();
     217  // ##
    208218  $the_new_company_taxonomy = wp_get_post_terms($post->ID, 'companies');
    209   $single_company_slug = $the_new_company_taxonomy[0]->slug;
    210   $url = home_url() . '/company/' . $single_company_slug;
     219  // ##
     220  //var_dump($the_new_company_taxonomy); // OK, data added in wp-admin is here.
     221  //wp_die();
     222  // ##
     223
     224 
     225      $single_company_slug = $the_new_company_taxonomy[0]->slug;
     226      $url = home_url() . '/company/' . $single_company_slug; // OK, page is created.
     227
     228
    211229
    212230  // Checks if the company name has been added as a tag to the individual job listing
Note: See TracChangeset for help on using the changeset viewer.