• Hello,
    I am trying to override the single-company.php and archive-company.php templates using the Blocksy theme’s content blocks feature, together with GreenShift’s query builder block from their query blocks addon and the Search & Filter Pro plugin for advanced search options. I am able to override all the WP Job Manager templates, including their Resume Manager addon’s templates, however I am having issues overriding the templates of the MAS Companies plugin. I reached out to Blocksy first, given that I am overriding the templates with their Content Blocks feature, and they gave it an honest review but ultimately said:

    “I have gotten word from the developers and unfortunately, this will not be fixable from our end. It was indeed discovered that the plugin that you have implemented to create these archives/singulars does forcefully replace our own templates, even if implemented via Content Blocks. The Content Blocks template features require all CPTs to be declared correctly, as per WordPress’ guidelines…

    As long as this forceful replacement is happening, we will not be able to change much from our end. The developers have advised to check out if the plugin has an option to correctly change the template.”

    From what I gather from that, the MAS Company templates are either not standard CPT’s or are implementing functionality that forces the original templates to be used.

    I do already know that the Company Archive settings requires that we declare compatibility in the child theme’s functions.php file and I have successfully implemented that already. It would be great to learn how to now override MAS Company templates, and the single-company.php and archive-company.php templates in particular with php templates or FSE themes – and especially with Blocksy’s content blocks (typically if they are standard CPT’s that can be overridden with php templates than Blocksy Content Blocks should work too).

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hi @indigetal,

    Can you please clarify what override you need in single-company and archive-company templates.

    Can you please help me understand your requirement with a screenshot ?

    Please note templates are copied and created same like as WooCommerce templates.

    Thanks, Abbas

    Thread Starter indigetal

    (@indigetal)

    Hi Abbas,

    I am simply attempting to override php template files the standard WordPress way via the child theme, or via Blocksy’s Content Blocks (which normally work with all page template files and CPT’s). I have successfully overridden the template files of WP Job Manager, including the single job template, the job archive template, the single resume template, and the resume archive template, but I am unable to override the MAS Companies plugin’s templates. As I mentioned, I asked Blocksy developers about it and they have said that there is something preventing standard template overrides from working on MAS Companies template files. The files that I am attempting to override are the single-company.php and archive-company.php files in the “templates” folder.

    Hi @indigetal,

    Please add attached folder inside your child theme folder and make your single-company.php and archive-company.php template customization.

    https://drive.google.com/file/d/19q33xYAfgl5SCVjADGr89CHDYBUTJRFX/view?usp=sharing

    Thanks, Abbas

    Thread Starter indigetal

    (@indigetal)

    Okay, I have confirmed that overriding the PHP templates in a mas-wp-job-manager-company folder in the child theme works as expected. However, my larger goal is to determine the source of compatibility issues between the MAS Companies template loader and Blocksy’s Content Blocks, which typically work with standard WordPress template loaders.

    I have looked into this more after learning about the particular file path that is required and I have identified that the MAS_WPJMC_Template_Loader class in includes/class-mas-wp-job-manager-company-template-loader.php hooks into the template_include filter to implement custom logic via self::get_template_loader_files() and self::get_template_loader_default_file() in the template_loader() function to determine which files to search for in a specific order. This logic overrides the standard WordPress template hierarchy, effectively nullifying implementations like Blocksy’s Content Blocks that rely on the standard WordPress template loading mechanism.

    Here’s the relevant code snippet from the template_loader method beginning on line 46 in includes/class-mas-wp-job-manager-company-template-loader.php:

    public static function template_loader($template) {
    if (is_embed()) {
    return $template;
    }

    $default_file = self::get_template_loader_default_file();

    if ($default_file) {
    $search_files = self::get_template_loader_files($default_file);
    $template = locate_template($search_files);

    if (!$template) {
    $template = mas_wpjmc()->plugin_dir . 'templates/' . $default_file;
    }
    }

    return $template;
    }

    So the plugin constructs a very specific set of template file paths, including directory-specific paths, which may also present compatibility issues with Full Site Editing themes. Ideally, MAS Companies would follow the standard WordPress template loading mechanism to ensure broad compatibility.

    I have also consulted with Blocksy and can still reach out to them about how to potentially modify the get_template_loader_files() to include paths where Blocksy places its templates. However, a long-term solution would involve MAS Companies aligning more closely with the standard WordPress template loading practices.

    Thank you for your assistance in addressing this issue. Please let me know if additional information is needed.

    Thread Starter indigetal

    (@indigetal)

    Okay, I have resolved the issue by removing the custom logic that specifies directory-specific paths and instead leverage WordPress’s inherent template hierarchy functions in `includes/class-mas-wp-job-manager-company-template-loader.php’. I would like to propose this change be included in the next update of the “MAS Companies for WP Job Manager” plugin to align its template loading mechanism with standard WordPress practices. This change would enhance compatibility with Full Site Editing (FSE) themes and popular plugins like Blocksy, GreenShift, and Search & Filter Pro.Current Issue

    Currently, the plugin employs a custom template loading mechanism through the MAS_WPJMC_Template_Loader class. This approach specifies a very specific set of template file paths, including directory-specific paths, and defaults to the plugin’s own templates. This custom logic overrides the standard WordPress template hierarchy, which can cause compatibility issues.

    I suggest modifying the template loading logic to follow the standard WordPress template loading hierarchy. This involves using WordPress’s built-in locate_template function, which respects the theme’s template overrides and integrates seamlessly with other plugins.

    Below is the revised class-mas-wp-job-manager-company-template-loader.php file:

    <?php
    /**
    * Template Loader
    *
    */

    defined( 'ABSPATH' ) || exit;

    /**
    * Template loader class.
    */
    class MAS_WPJMC_Template_Loader {

    /**
    * Store the company page ID.
    *
    * @var integer
    */
    public static $companies_page_id = 0;

    /**
    * Hook in methods.
    */
    public static function init() {
    self::$companies_page_id = mas_wpjmc_get_page_id('companies');

    // Hook into template_include to load custom templates
    add_filter('template_include', array(__CLASS__, 'template_loader'));
    }

    /**
    * Load a template.
    *
    * Handles template usage so that we can use our own templates instead of the themes.
    *
    * @param string $template Template to load.
    * @return string
    */
    public static function template_loader($template) {
    if (is_singular('company')) {
    $new_template = locate_template(array('single-company.php'));

    if ($new_template) {
    $template = $new_template;
    }
    } elseif (is_post_type_archive('company') || is_page(self::$companies_page_id) || mas_wpjmc_is_company_taxonomy()) {
    $new_template = locate_template(array('archive-company.php'));

    if ($new_template) {
    $template = $new_template;
    }
    }

    return $template;
    }
    }

    add_action('init', array('MAS_WPJMC_Template_Loader', 'init'));

    By adhering to WordPress’s standard template loading hierarchy, the plugin will gain broad compatibility and integrate with Full Site Editing themes and plugins like Blocksy, GreenShift, and other plugins that rely on the standard template loading process.

    Thank you for your attention to this matter.

    Best Regards,
    Brandon

    jmabbas

    (@jmabbas)

    Hi @indigetal,

    Thanks for this tip. I try to contact our developers to include this changes in plugin updates.

    Kindest Regards, Abbas

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.