Plugins – Is an Office a Custom Post Type?

In an upcoming WordPress project, I need to display a list of offices, and those offices would have a number of user-fillable fields.

I spent some time thinking about the anatomy of an office and decided it would do the following:

Things that make up an office (in my scenario):

  • Surname
  • Address line 1
  • adress line 2
  • city
  • road
  • Post Code
  • Will open soon?
  • Opening date?
  • width
  • length
  • Summary / short description
  • Price per day currency
  • Key points – access, parking, cafe, other assets
  • Contact Phone Number
  • Contact email
  • Description of the place / center
  • Key features and benefits
  • Photo of the tour guide for the office or center
  • Arrival by subway / train, bus, driving, etc.
  • reviews
  • photography
  • First name
  • Official name

I'm fairly new to WordPress, but would an office qualify as a custom post type from the list I've given, or would it tend to be a plugin or custom spreadsheet?

I feel like things like key features would itself be a taxonomy type, similar to using tags. For example, an office might have things like:

  • parking spot
  • Wireless Internet access
  • vending machine

I'm just a little hazy about what counts as what.

Plugins – WordPress topics are not displayed correctly

In the past few days I have set up WordPress with a newly installed Debian 10 system.
I followed some instructions and installed all the necessary packages, but unfortunately not all topics are displayed correctly.

They look like simple HTML pages, with no effects without sliders, just a simple, tedious page. It is difficult to explain, so I took some screenshots.

The people on the WordPress forums also didn't know how to deal with it. Can a missing package be the cause? I also tried different browsers on different devices that all had the same problem.

Enter the image description here

Enter the image description here

Plugins – Smush strange sizes 1200×9999 1980×9999 600×0 768×0

I'm looking at the sizes / resolutions that WP Smush (v3.4.2) uses to scale images.

Some of them don't make much sense from today's perspective.

Image sizes / user-defined in the Smush settings menu, but also on product pages:

 768x0
 600x0
1980x9999
1200x9999

I suspect they might have something to do with the aspect ratio (e.g. leave the Y dimension unchanged or scale Y so that X = 600).

Can someone tell me about it?

Plugins – get_option / wp_localize_script does not work in the OOP plug-in

I recently got it working in a single-file PHP plugin that only consisted of functions.

Now I'm going to try the WordPress plugin Boilerplate, an OOP approach with many different classes.

In short, I'm looking at two different classes / files

includes/class-ebay-keyword-suggest.php and admin/class-ebay-keyword-suggest-admin.php

The first is the core plugin class and the second is the admin specific functionality.

First, class-ebay-keyword-suggest.php __construct()& # 39; s

public function __construct() {
    if ( defined( 'EBAY_KEYWORD_SUGGEST_VERSION' ) ) {
        $this->version = EBAY_KEYWORD_SUGGEST_VERSION;
    } else {
        $this->version = '1.0.0';
    }
    $this->plugin_name = 'ebay-keyword-suggest';

    $this->load_dependencies();
    $this->set_locale();
    $this->define_admin_hooks();
    $this->define_public_hooks();
    $this->register_admin_menu();
}

load_dependencies loads the class-ebay-keyword-suggest-admin.php File, among others.

ends with the definition $this->loader such as:

$this->loader = new Ebay_Keyword_Suggest_Loader();

define_admin_hooks loads my scripts and stylesheets

private function define_admin_hooks() {
    $plugin_admin = new Ebay_Keyword_Suggest_Admin( $this->get_plugin_name(), $this->get_version() );
    $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
    $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
}

Next from register_admin_menu::

private function register_admin_menu() {
    $plugin_admin = new Ebay_Keyword_Suggest_Admin( $this->get_plugin_name(), $this->get_version() );
    add_action( 'admin_init', array( $plugin_admin, 'ebay_keyword_suggest_settings_init' ) );
    add_action( 'admin_menu', array( $plugin_admin, 'ebay_keyword_suggest_add_admin_menu' ) );
    add_action( 'admin_enqueue_scripts', array( $plugin_admin, 'enqueue_localize' ) );
}

ebay_keyword_suggest_settings_init Here I register the option / setting ebay_keyword_suggest_settings with callbacks

public function ebay_keyword_suggest_settings_init() { 

register_setting( 'pluginPage', 'pluginPage', array($this, 'ebay_keyword_suggest_settings'));

add_settings_section(
    'ebay_keyword_suggest_pluginPage_section', 
    __( 'Your section description', '' ),
    array($this, 'ebay_keyword_suggest_settings_section_callback'),
    'pluginPage'
);

add_settings_field( 
    'ebay_keyword_suggest_checkbox_field_0', 
    __( 'Settings field description', '' ), 
    array($this, 'ebay_keyword_suggest_checkbox_field_0_render'),
    'pluginPage', 
    'ebay_keyword_suggest_pluginPage_section' 
);
}

Further in the row in the add_action Functions of register_admin_menu about ebay_keyword_suggest_add_admin_menu

public function ebay_keyword_suggest_add_admin_menu() {
    add_options_page( 'eBay Keyword Suggest', 'eBay Keyword Suggest', 'manage_options', 'ebay_keyword_suggest',  array($this, 'ebay_keyword_suggest_options_page') );
}

Then we come to this line:

add_action( 'admin_enqueue_scripts', array( $plugin_admin, 'enqueue_localize' ) );

public function enqueue_localize( $hook ) {
    $getoption = get_option( 'ebay_keyword_suggest_settings' );
    $enabled = $getoption('ebay_keyword_suggest_checkbox_field_0');
    wp_localize_script( $this->plugin_name, 'ekw_script_vars', array( 'enabled' => __($enabled) ) );
}

As you can see, is the first instance of get_option is initiated here under the variable $getoption… on var_dump always returns false (and of course wp_localize_script does not work properly because the correct option variable is not retrieved.

With a combination of, it was very easy to get this to work in a single PHP file add_action& # 39; s about the functions and an easy introduction of register_setting( 'pluginPage', 'title_char_count_settings' ); followed by simply retrieving the setting get_option( 'title_char_count_settings' );

This OOP approach is a lot trickier … I have to be conclude I think … where's the hiccup going?

Plugins – Overwrite the core function locate_template

I want to override the core WordPress locate_template () function.
I want the function to also search an additional plugin directory for a template file.
I don't see any filters in the function and I don't check whether the functions are available.
Maybe someone has a better solution for it.

What I'm trying to create is a grandson theme as a plugin, and I've worked it for regular theme files, but not for overriding the get_template_part () and locate_template () functions.

For later sharing, my website will look for the file in the child themes folder, if it's not there, will look for it in the plugins folder, and if it's not there, it will be in the parent theme and then in the original WordPress- Search file.
So I add an extra layer.

Plugins – portfolio page – custom post type or field or other options

I'm trying to convert http://buildandtest.atspace.cc/)(1) to a custom WordPress theme.

What would be the best approach to set up a work page as a portfolio? I'm trying to get the same behavior as in the HTML / CSS template. If the user clicks on the image link (thumbnail view) on the working page, another page opens that contains an overview of a project with larger screenshots and text.

I have read something and found that Custom Post Type or an Advanced Custom Field Pro plugin (with repeater field function) can be used.

Plugins – Show custom form in the Quick View window in WooCommerce

I use the code that shows the "Roast Level" checkbox on the product editing page. When the manager clicks this check box, a selection box appears on the side of a single product that allows the customer to select the "Roast Level" option.

When you select and add a product to the shopping cart, the selected value is displayed in the shopping cart itself. This value is also displayed on the checkout page, on the "Thank you" page, in the order, in the email notification and on the page for processing the order in the admin area.

Here is the code:

// Show checkbox
add_action (& # 39; woocommerce_product_options_general_product_data & # 39 ;, & # 39; roast_custom_field_add & # 39;);

Function roast_custom_field_add () {
global $ post;

// checkbox
woocommerce_wp_checkbox (
Array (
& # 39; id & # 39; => & # 39; _roast_checkbox & # 39 ;,
& # 39; label & # 39; => __ (& # 39; Roast Level & # 39 ;, & # 39; woocommerce & # 39;),
& # 39; description & # 39; => __ (& # 39; activate roasting level & # 39 ;, & # 39; woocommerce & # 39;)
)
);
}

// Save field checkbox
add_action (& # 39; woocommerce_process_product_meta & # 39 ;, & # 39; roast_custom_field_save & # 39;);

Function roast_custom_field_save ($ post_id) {
// check box for custom product
$ roast_checkbox = isset ($ _ POST (& # 39; _ roast_checkbox & # 39;))? & # 39; yes no & # 39 ;;
update_post_meta ($ post_id, & # 39; _roast_checkbox & # 39 ;, esc_attr ($ roast_checkbox));
}

/ * ------------------------------------------------ ---------------
* Display selection box
-------------------------------------------------- ------------- * /
add_action (& # 39; woocommerce_before_add_to_cart_button & # 39 ;, & # 39; add_roast_custom_field & # 39 ;, 0);
Function add_roast_custom_field () {
global $ product;

// If it is a single product page and the "roast_checkbox" option is activated, the field is displayed
if (is_product () && $ product-> get_meta (& # 39; _roast_checkbox & # 39;) === & # 39; yes & # 39;) {

echo & # 39;
& # 39 ;; $ select = woocommerce_form_field (& # 39; roast_custom_options & # 39 ;, array ( & # 39; type & # 39; => & # 39; select & # 39 ;, & # 39; class & # 39; => array (& # 39; my field class form lines wide & # 39;) & # 39; label & # 39; => __ (& # 39; Roast Level & # 39;), & # 39; required & # 39; => false, & # 39; return & # 39; => false, & # 39; # 39 & options; => array ( & # 39; & # 39; => & # 39; Please select & # 39 ;, & # 39; Blue & # 39; => & # 39; Blue & # 39 ;, & # 39; rare & # 39; => & # 39; Rarely & # 39 ;, & # 39; Medium Rare & # 39; => & # 39; Medium Rare & # 39 ;, # 39 &; means & # 39; => & # 39; Medium & # 39;, & # 39; Medium Well & # 39; => & # 39; Medium Well & # 39 ;, & # 39; Well done & # 39; => & # 39; Well done & # 39; ) ), & # 39; & # 39;); echo $ select; echo & # 39;
& # 39 ;; } } / * ------------------------------------------------ --------------- * Add item data as a custom shopping cart -------------------------------------------------- ------------- * / add_filter (& # 39; woocommerce_add_cart_item_data & # 39 ;, & # 39; add_custom_cart_item_data & # 39 ;, 10, 21); Function add_custom_cart_item_data ($ cart_item_data, $ product_id, $ variant_id) { if (isset ($ _POST (& # 39; roast_custom_options & # 39;))) { $ cart_item_data (& # 39; roast_option & # 39;) = wc_clean ($ _POST (& # 39; roast_custom_options & # 39;)); } return $ cart_item_data; } / * ------------------------------------------------ --------------- * Add custom field values ​​under the name of the cart item in the cart -------------------------------------------------- ------------- * / add_filter (& # 39; woocommerce_cart_item_name & # 39 ;, & # 39; roast_custom_field & # 39 ;, 10, 21); Function roast_custom_field ($ item_name, $ cart_item, $ cart_item_key) { if (! is_cart ()) return $ item_name; if (isset ($ cart_item (& # 39; roast_option & # 39;)) { $ item_name. = & # 39;
& # 39 ;. __ ("Roast Level", "Woocommerce"). & # ;: 39 & # 39 ;. $ cart_item (& # 39; roast_option & # 39;). & # 39;
& # 39 ;; } return $ item_name; } / * ------------------------------------------------ --------------- * Display of values ​​for custom roast fields under the item name at checkout -------------------------------------------------- ------------- * / add_filter (& # 39; woocommerce_checkout_cart_item_quantity & # 39 ;, & # 39; roast_custom_checkout_cart_item_name & # 39 ;, 10, 21); Function roast_custom_checkout_cart_item_name ($ item_qty, $ cart_item, $ cart_item_key) { if (isset ($ cart_item (& # 39; roast_option & # 39;)) { $ item_qty. = & # 39;
& # 39 ;. __ ("Roast Level", "Woocommerce"). & # ;: 39 & # 39 ;. $ cart_item (& # 39; roast_option & # 39;). & # 39; гр.
& # 39 ;; } return $ item_qty; } / * ------------------------------------------------ --------------- * Save the selected slelect field value for each order item as custom metadata and display it anywhere -------------------------------------------------- ------------- * / add_action (& # 39; woocommerce_checkout_create_order_line_item & # 39 ;, & # 39; save_order_item_product_fitting_color & # 39 ;, 10, 21); Function save_order_item_product_fitting_color ($ item, $ cart_item_key, $ values, $ order) { if (isset ($ values ​​(& # 39; roast_option & # 39;))) { $ key = __ (& # 39; Roast Level & # 39 ;, & # 39; Woocommerce & # 39;); $ value = $ values ​​(& # 39; roast_option & # 39;); $ item-> update_meta_data ($ key, $ value, $ item-> get_id ()); } } add_action (& # 39; wp_footer & # 39 ;, & # 39; add_footer_script & # 39;); Function add_footer_script () { ?> <? php }

I need to add the "Roast Level" selection form to the quick view window of the content-product-quick-view.php file.

Errors occurred while adding code. The form is not displayed or the "Add to cart" button disappears.

global $product;

// If is single product page and have the "roast_checkbox" enabled we display the field
if ( is_product() && $product->get_meta( '_roast_checkbox' ) === 'yes' ) {

    echo '
'; $select = woocommerce_form_field( 'roast_custom_options', array( 'type' => 'select', 'class' => array('my-field-class form-row-wide'), 'label' => __('Roast Level'), 'required' => false, 'return' => false, 'options' => array( '' => 'Please select', 'Blue' => 'Blue', 'Rare' => 'Rare', 'Medium Rare' => 'Medium Rare', 'Medium' => 'Medium', 'Medium Well' => 'Medium Well', 'Well Done' => 'Well Done' ) ), '' ); echo $select; echo '
'; }

As a result, I was unable to insert this code into the PHP file. Additional code may need to be added here. And I ask for your help.