How to get all attributes with all available labels/options in Magento2?

I did a lot of research but could not find a solution for that. so gathered some info and created this code: (it is not the best way to do it, but it works – you can use it at least one time for quick results)
the values need to be transformed if you want to see them properly in csv

Here is how to print all available attributes in backend and along with their all available options aka labels

<?php
        use \Magento\Framework\App\Bootstrap;
        error_reporting(E_ALL);
        ini_set("display_errors",1);
        include('./app/bootstrap.php');
        $bootstrap = Bootstrap::create(BP, $_SERVER);
        $objectManager = $bootstrap->getObjectManager();
        //use Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory;
        $collection= $objectManager->get('\Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory')->create();
//$attr_groups = array();
$fta=array();
$ft=array();
        foreach ($collection as $items) {
                        $attr_groups = $items->getData();
                                                if($attr_groups['frontend_input']=="select" or $attr_groups['frontend_input']=="multiselect"){
$eav=$objectManager->get('\Magento\Eav\Model\Config')->getAttribute('catalog_product',$attr_groups['attribute_code'])->getSource()->getAllOptions();
$ft[]=$attr_groups['frontend_label'];
$ft[]=$attr_groups['attribute_code'];
//echo $attr_groups['attribute_code'].'<br>'.$attr_groups['frontend_input'].'<br>'.$attr_groups['frontend_label'].'<br>'.$attr_groups['attribute_id'].'<br>';
foreach($eav as $getlabel) {
        if(is_object($getlabel['label'])){
        $r = new ReflectionObject($getlabel['label']);
$p = $r->getProperty('text');
//echo $p;
$p->setAccessible(true);
        $ft[]= $p->getValue($getlabel['label']);
        }
        else
        $ft[]= $getlabel['label'];
}
$fta[]=$ft;
$ft=array();
}

WordPress Dashboard – Introduction by newbie

Dashboard Panel

When you will log into the administration area of your blog, you’ll see the WordPress Dashboard which will display the overview of the whole website.  You can customize your needs by using some quick links such as writing quick draft, replying to latest comment, etc.

Dashboard Menu

The WordPress Dashboard provides a navigation menu that contains some menu options such as posts, media library, pages, comments, appearance options, plugins, users, tools and settings on the left side.

Welcome Section

It includes the “Customize Your Site” button which allows customizing your WordPress theme. The center column provides some of the useful links such as creating a blog post, creating a page and view the front end of your website.

Quick Draft

The Quick Draft is a mini post editor which allows writing, saving and publishing a post from the admin dashboard. It includes the title for the draft, some notes about the draft and save it as a Draft.

WordPress News

The WordPress News widget displays the latest news such as latest software version, updates, alerts, news regarding the software etc. from the official WordPress blog.

Activity

The Activity widget includes latest comments on your blog, recent posts and recently published posts. It allows you to approve, disapprove, reply, edit, or delete a comment. It also allows you to move a comment to spam.

At a Glance

This section gives an overview of your blog’s posts, number of published posts and pages, and number of comments. When you click on these links, you will be taken to the respective screen. It displays the current version of running WordPress along with the currently running theme on the site.


Extracting names from given list of URLs (using regex)

let us extract name form the URL
https://www.google.com/name?=rajiv
paste the URL in the notepad and press crtl+f , and select ‘regular expressions ‘ from search mode

find in notepad

now, enter the regex in the find tab to fetch names
.*?\?=(\w+)$

Now, the selected name will be fetched form regex as (\1).

it can work on numerous links like:-

https://www.google.com/name?=rajiv/
http://www.example.com/asdas?=borde/id=?
http://www.example.com/asdasd?=bordex
http://www.example.com/name?=bordet
http://www.example.com/asdasd?=border
http://www.example.com/jsciloji?=bordeeeee
http://www.example.com/name?=bordee
http://www.example.com/name?=bordeeeeeee
http://www.example.com/09328e?=bordeeee
http://www.example.com/name?=borde
http://www.example.com/lpaosd?=borde

And only the part after first “?=” will be fetched

How to install a new theme in WordPress using a compressed theme file

Follow these steps to install a new WordPress theme to your website using a compressed theme file(.zip,.tar,.rar etc):

Step 1: Open the wp-content folder in the root directory of WordPress and go to the themes folder.

Step 2: Upload the zip(or any other compressed file) theme file inside the theme folder.

Step 3: Go back to the theme folder, select the compressed theme file and click on extract.

Step 4: After the file is extracted you may still not see the extracted folder, so click on reload. Also, delete the zip file as it obsolete now.

Step 5: Now, go to the WordPress dashboard of your website and click on Appearance>Themes.

Step 6: You can now see your new theme in the installed themes section. Hover on your new theme and click Activate to activate the theme.

Congratulations you have finally installed and activated a new theme!

How to remove links of a learndash course which has not started yet? without code changes

jQuery(document).ready(function($){
var nost=0;
if($("body").hasClass("single-sfwd-courses")){
toba='';
$("#lessons_list a.notavailable").removeAttr("href");
$("#lessons_list a.notavailable").each(function(){
toba=$(this).parent().parent().attr("class");
toba = toba.replace("lesson post-",'');
toba = toba.replace(" is_not_sample no-topics",'');
toba = toba.replace(" is_not_sample has-topics",'');
$('#learndash_topic_dots-'+toba+" a").removeAttr("href");
});
}
});

Simple joining of data from two different tables on basis of a common key

SELECT a.user_id,a.meta_value,b.user_login FROM `e_usermeta` a,`e_users` b where a.meta_key="phoneno" and a.user_id=b.ID
SELECT a.user_id,a.meta_value,b.user_pass,b.user_login FROM `e_usermeta` a,`e_users` b where a.meta_key="phoneno" and a.user_id=b.ID order by b.user_login
UPDATE `wp_users` a,`tmptable` b SET a.`user_pass`=b.`usp` where a.`user_login`=b.`ulogin`;

How to change WordPress user roles in MySQL database using PhpMyAdmin?

We will be editing the database rows using PhpMyAdmin tool given with cPanel by many hosting companies

You can change the WordPress user roles by following the given steps:

Step 1: Open phpMyAdmin on cPanel.

Step 2: Open the wp_usermeta or xxx_usermeta table in the database as highlighted. (wp_ is just prefix, your table prefix may be different)

wordpress tables in database

Step 3: In wp_usermeta table, you can find wp_capabilities under meta_key column.

User Roles in usermeta table

Step 4: The roles are saved in form of serialized PHP array. Change the user role you want to assign to the current user by changing the meta_value as:

Subscriber
a:1:{s:10:"subscriber";b:1;}

Contributor
a:1:{s:11:"contributor";b:1;}

Author
a:1:{s:6:"author";b:1;}

Editor
a:1:{s:6:"editor";b:1;}

Administrator
a:1:{s:13:"administrator";b:1;}

Magento 2 cli commands [continued]

1. Setting GD2 as defualt image adapter from command line 

Magento >= 2.2
php bin/magento config:set dev/image/default_adapter GD2
php bin/magento cache:clean
Magento >= 2.2
 mysql --host=(host) --user=(user) --password=(password) -D (database) -e "\ UPDATE core_config_data SET value = 'GD2' WHERE 'dev/image/default_adapter' = path; \"; 

 2. Disable Minify CSS Files option from command line

Magento >= 2.2
php bin/magento config:set dev/css/minify_files 0
php bin/magento cache:clean
Magento < 2.2
mysql --host= --user= --password= -D  -e "\ UPDATE core_config_data SET value = 0 WHERE 'dev/css/minify_files' = path; \";
php bin/magento cache:clean

3. Disable Merge CSS Files option from command line

 

php bin/magento config:set dev/css/merge_css_files 0
php bin/magento cache:clean
Magento < 2.2
mysql --host= --user= --password= -D  -e "\ UPDATE core_config_data SET value = 0 WHERE 'dev/css/merge_css_files' = path; \";
php bin/magento cache:clean