How to hide media menu items in my custom plugin? (Wordpress) - wordpress

How to hide items in the square? This is in a custom plugin.
Click here

You can create plugin for this (i.e. Remove attachment filed). Below are the steps to create plugin for your requirement:
1) Create one folder inside wp-content/plugin (i.e. Remove attachment filed)
2) Inside newly created folder create one file (i.e remove_attachment_details.php) with below code.
3) Activate the plugin from Admin >> Plugins
<?php
/*
Plugin Name: Remove attachment filed
*/
add_action('admin_head-post.php', 'hide_media_stuff_wpse_120894' );
add_action('admin_head-post-new.php', 'hide_media_stuff_wpse_120894' );
function hide_media_stuff_wpse_120894(){
?>
<style type="text/css">
.attachment-details [data-setting="title"],
.attachment-details [data-setting="caption"],
.attachment-details [data-setting="alt"],
.attachment-details [data-setting="description"],
div.attachment-display-settings
{
display:none
}
</style>
<?php
}
?>

Related

Link Woocommerce custom placeholder image to product page

On my woocommerce e-commerce page https://www.vattenliv.se/produkt-kategori/filter/ozon-och-proteinskimmer/ there are some products that does not have any product image set. Instead the custom placeholder image shows. Is there a way to make these placeholder images link to each product page, just like the other products?
The site uses the theme OceanpWP and Elementor page builder.
Peter
I believe the best way to do this is by using a child theme, to ovewrite the woocommerce function. This code in your child theme functions.php file should work.
<?php
if (!function_exists('woocommerce_get_product_thumbnail')) {
function woocommerce_get_product_thumbnail($size = 'shop_catalog', $deprecated1 = 0, $deprecated2 = 0) {
global $post;
if (has_post_thumbnail()) {
return ''.get_the_post_thumbnail($post->ID, $size).'';
}
elseif(wc_placeholder_img_src()) {
return ''.wc_placeholder_img( $size ).'';
}
}
}
?>

how to remove wordpress documentation menu link in dashboard

I want to customize my dashboard by removing WordPress icon and it's menu on the top bar but I have no idea of how it works because am not an expert in WordPress please help me
Create a new file in the WordPress wp-content/plugins/ folder named admin-bar.php then add the following plugin header:
<?php
/*
Plugin Name: Admin Bar
Plugin URI: http://www.sitepoint.com/
Description: Modifies the WordPress admin bar
Version: 1.0
Author: Craig Buckler
Author URI: http://twitter.com/craigbuckler
License: MIT
*/
You can now activate this plugin in the WordPress administration panel. It won’t do anything yet but you can make additions, save then refresh to view the updates.
you can remove existing items with the remove_node() method. For this, we need to create a new function named update_adminbar() which is passed an WP_Admin_Bar object ($wp_adminbar). This function is called when the admin_bar_menu action hook is activated:
// update toolbar
function update_adminbar($wp_adminbar) {
// remove unnecessary items
$wp_adminbar->remove_node('wp-logo');
$wp_adminbar->remove_node('customize');
$wp_adminbar->remove_node('comments');
}
// admin_bar_menu hook
add_action('admin_bar_menu', 'update_adminbar', 999);
https://www.sitepoint.com/customize-wordpress-toolbar/
You can create a custom plugin and upload folder to your server with this one file in it. Make sure to save the file as exact plugin name. For example, "AdminBar.php"
<?php
/*
Plugin Name: AdminBar
Plugin URI:
Description: Code to hide the admin bar for non-admins only.
Version: 1.0
Author: Name Here
Author URI:
*/
function hide_admin_bar_settings()
{
?>
<style type="text/css">
.show-admin-bar {
display: none;
}
</style>
<?php
}
function disable_admin_bar()
{
if(!current_user_can('administrator'))
{
add_filter( 'show_admin_bar', '__return_false' );
add_action( 'admin_print_scripts-profile.php', 'hide_admin_bar_settings' );
}
}
add_action('init', 'disable_admin_bar', 9);

How can I edit the header and footer of Travelify Wordpress Theme?

I want to modify the Travelify Wordpress Theme.
I want to put some options like Home|Contact Us|Search on the header.
I want to put an image on the footer.
Question
How can I achieve these changes to the theme?
If you want to make a navigation menu on header, you must setting your menu first.
Setting your navigation menu on appearance>menu
You can setting your footer on appearance>widgets
Try SiteOrigin Widgets bundle plugin for more Widgets on your wordpress.
And for a custom CSS, I use SiteOrigin CSS.
First go to 'wordpress/wp-content/theme' folder and generate an directory with similar name as your theme name.Let say theme name is 'travelify' then use child theme name as 'travelify-child'.
Now go to 'travelify-child' folder and add two files i.e.(style.css and functions.php)
Now open style.css from parent theme i.e.'travelify'
copy all css code and paste into new style.css in 'travelify-child' folder.
don't forget to change theme name,description,text domain.
Add 'Template: travelify' in to style.css.....you can add it after anyline in header like after 'Author URI'.
Now save this style.css and open functions.php in 'travelify-child' foder
and paste below code into functions.php
<?php
add_action( 'init' , 'remove_copyright' , 15 );
function remove_copyright() {
remove_action( 'travelify_footer', 'travelify_footer_info', 30 );
}
add_action( 'travelify_footer' , 'new_footer_info' , 30 );
function new_footer_info() {
$output = '<div class="copyright">Copyright © 2016 Your website name.Powered by Wordpress.
Wordpress</div>';
echo $output;
}
?>

Targeting the shop page only

This is what I need to do:
To target only the main shop page with CSS (a specific custom class I created as mentioned below).
This is what I've done and tried so far:
I have an override template of archive-product.php in my child theme.
In this override template I've added a div with a custom class custom-shop-class just before the product loop start, because I want to target the looped products specifically.
I tried targeting with class page-id-4 because if I hover over the "shop" page in wp-admin, it gave me http://.../post.php?post=4&action=edit
The problem I'm having is as follows:
From what I've discovered is that the same archive-product.php template is being used in the other various shop pages and not only in the main "shop" page (correct me if I'm wrong), so when I target my custom-shop-class with CSS, it affects all the other shop pages using the same template file, and it must not.
There is no unique identifier or class specifically for the shop page, something like the page-id-?? class in the body tag (as in the usual WP pages).
Any suggestions on the best method/solution?
Set a conditional statement to check for the primary shop page, then echo the div in question if that statement evaluates to true.
WooCommerce Conditional Tag for main shop page:
is_shop()
Example
if (is_shop()) {
echo "<div class='custom-shop-class'></div>";
} else {
echo "<div class='custom-product-category-class'></div>";
}
Alternatively:
<?php if (is_shop()):?>
<div class="custom-shop-class"></div>
<?php else: ?>
<div class="custom-product-category-class"></div>
<?php endif;?>
Conditional Tags | WooThemes Documentation
Using the filter body_class with the is_shop conditional you can target the main WooCommerce shop page.
add_filter( 'body_class', 'woo_shop_class' );
// Add WooCommerce Shop Page CSS Class
function woo_shop_class( $classes ) {
if ( is_shop() ) // Set conditional
$classes[] = 'woo-shop'; // Add Class
return $classes;
}
The code goes in your themes functions.php file.
To build on the answer provided here, how might I go further and add a unique identifier to the shop page based on the active WPML language? (I'm basically trying to reduce a font size on the German version of the shop page only - it's proving surprisingly difficult to do)

Remove Option Tree menu in admin page

I integrated option tree in my template.
I want to hide OptionTree menu item from users. How to remove Option Tree menu item in admin page?
Add this code to your theme's functions.php:
// Remove Option Tree Settings Menu
add_filter( 'ot_show_pages', '__return_false' );
That will remove the Option Tree admin menu.
Here is another solution.
function remove_ot_menu () {
remove_menu_page( "ot-settings" ); } add_action( 'admin_menu', 'remove_ot_menu' );
I know i'm late to the party but since i got to find
a solution (for an old website i restructering) i tought
i might share "a softer" solution.
2 steps
1. We ad the current user id to the admin body class
2. We add a css to hide the menu except for the intended user.
User id in the body class
/*********************************************
** CUSTOM BODY CLASS
*********************************************/
add_filter('admin_body_class', 'custom_admin_body_class');
function custom_admin_body_class($classes){
$cuserid = get_current_user_id();
return $classes. 'user-'.$cuserid;
}
Add the desired css to anytype of css loaded to wp-admin
** replace user-[number] with yours*
.wp-admin:not(.user-1) #toplevel_page_ot-settings {display: none;}
If your not loading any css to wp-admin you can use this
add_action('admin_head', 'my_custom_fonts');
function my_custom_fonts() {
echo '<style>.wp-admin:not(.user-1) #toplevel_page_ot-settings {display: none;}</style>';
}

Resources