1 Pick an icon
Goto: http://fontawesome.io/icons/
2. You will get the SVG version here:
https://github.com/encharm/Font-Awesome-SVG-PNG
You will see folder named “black” (if you need black icon), under that folder, click the folder “svg”, you will see the icons list, you will have to get the raw code of particular svg icon.
Example Raw code:
<?xml version="1.0" encoding="utf-8"?> <svg width="1792" height="1792" viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg"><path d="M1551 1476q15-6 26-3t11 17.5-15 33.5q-13 16-44 43.5t-95.5 68-141 74-188 58-229.5 24.5q-119 0-238-31t-209-76.5-172.5-104-132.5-105-84-87.5q-8-9-10-16.5t1-12 8-7 11.5-2 11.5 4.5q192 117 300 166 389 176 799 90 190-40 391-135zm207-115q11 16 2.5 69.5t-28.5 102.5q-34 83-85 124-17 14-26 9t0-24q21-45 44.5-121.5t6.5-98.5q-5-7-15.5-11.5t-27-6-29.5-2.5-35 0-31.5 2-31 3-22.5 2q-6 1-13 1.5t-11 1-8.5 1-7 .5h-10l-3-.5-2-1.5-1.5-3q-6-16 47-40t103-30q46-7 108-1t76 24zm-394-443q0 31 13.5 64t32 58 37.5 46 33 32l13 11-227 224q-40-37-79-75.5t-58-58.5l-19-20q-11-11-25-33-38 59-97.5 102.5t-127.5 63.5-140 23-137.5-21-117.5-65.5-83-113-31-162.5q0-84 28-154t72-116.5 106.5-83 122.5-57 130-34.5 119.5-18.5 99.5-6.5v-127q0-65-21-97-34-53-121-53-6 0-16.5 1t-40.5 12-56 29.5-56 59.5-48 96l-294-27q0-60 22-119t67-113 108-95 151.5-65.5 190.5-24.5q100 0 181 25t129.5 61.5 81 83 45 86 12.5 73.5v589zm-672 21q0 86 70 133 66 44 139 22 84-25 114-123 14-45 14-101v-162q-59 2-111 12t-106.5 33.5-87 71-32.5 114.5z" fill="#fff"/></svg>
If You need white version icon, click the folder named “white”
3. Now using the custom icon in my wordpress plugin
class ZerinPlugin
{
function __construct() {
add_action( 'init', array( $this, 'custom_post_type' ) );
}
function register() {
add_action( ‘admin_enqueue_scripts’, array( $this, ‘enqueue’ ) );
add_action( ‘admin_menu’, array( $this, ‘add_admin_pages’ ) );
}
function activate() {
// generated a CPT
$this->custom_post_type();
// flush rewrite rules
flush_rewrite_rules();
}
function deactivate() {
// flush rewrite rules
flush_rewrite_rules();
}
function custom_post_type() {
register_post_type( ‘book’, [‘public’ => true, ‘label’ => ‘Books’, ‘menu_icon’ =>’data:image/svg+xml;base64,’ . base64_encode(‘<svg width=”2304″ height=”1792″ viewBox=”0 0 2304 1792″ xmlns=”http://www.w3.org/2000/svg”><path d=”M762 1152h-314q-40 0-57.5-35t6.5-67l188-251q-65-31-137-31-132 0-226 94t-94 226 94 226 226 94q115 0 203-72.5t111-183.5zm-186-128h186q-18-85-75-148zm480 0l288-384h-480l-99 132q105 103 126 252h165zm1120 64q0-132-94-226t-226-94q-60 0-121 24l174 260q15 23 10 49t-27 40q-15 11-36 11-35 0-53-29l-174-260q-93 95-93 225 0 132 94 226t226 94 226-94 94-226zm128 0q0 185-131.5 316.5t-316.5 131.5-316.5-131.5-131.5-316.5q0-97 39.5-183.5t109.5-149.5l-65-98-353 469q-18 26-51 26h-197q-23 164-149 274t-294 110q-185 0-316.5-131.5t-131.5-316.5 131.5-316.5 316.5-131.5q114 0 215 55l137-183h-224q-26 0-45-19t-19-45 19-45 45-19h384v128h435l-85-128h-222q-26 0-45-19t-19-45 19-45 45-19h256q33 0 53 28l267 400q91-44 192-44 185 0 316.5 131.5t131.5 316.5z” fill=”#fff”/></svg>”)]);
}
function enqueue() {
// enqueue all our scripts
wp_enqueue_style( ‘mypluginstyle’, plugins_url( ‘/assets/mystyle.css’, __FILE__ ) );
wp_enqueue_script( ‘mypluginscript’, plugins_url( ‘/assets/myscript.js’, __FILE__ ) );
}
public function add_admin_pages() {
add_menu_page( ‘NOVA’, ‘NOVA – Sub Menu’, ‘manage_options’, ‘alecaddd_plugin’, array( $this, ‘admin_index’ ), ‘dashicons-store’, 110 );
/*
add_menu_page( ‘NOVA’, ‘NOVA – Sub Menu’, ‘manage_options’, ‘alecaddd_plugin’, array( $this, ‘admin_index’ ), ‘data:image/svg+xml;base64,’ . base64_encode(‘<svg width=”2304″ height=”1792″ viewBox=”0 0 2304 1792″ xmlns=”http://www.w3.org/2000/svg”><path d=”M762 1152h-314q-40 0-57.5-35t6.5-67l188-251q-65-31-137-31-132 0-226 94t-94 226 94 226 226 94q115 0 203-72.5t111-183.5zm-186-128h186q-18-85-75-148zm480 0l288-384h-480l-99 132q105 103 126 252h165zm1120 64q0-132-94-226t-226-94q-60 0-121 24l174 260q15 23 10 49t-27 40q-15 11-36 11-35 0-53-29l-174-260q-93 95-93 225 0 132 94 226t226 94 226-94 94-226zm128 0q0 185-131.5 316.5t-316.5 131.5-316.5-131.5-131.5-316.5q0-97 39.5-183.5t109.5-149.5l-65-98-353 469q-18 26-51 26h-197q-23 164-149 274t-294 110q-185 0-316.5-131.5t-131.5-316.5 131.5-316.5 316.5-131.5q114 0 215 55l137-183h-224q-26 0-45-19t-19-45 19-45 45-19h384v128h435l-85-128h-222q-26 0-45-19t-19-45 19-45 45-19h256q33 0 53 28l267 400q91-44 192-44 185 0 316.5 131.5t131.5 316.5z” fill=”#fff”/></svg>’), 110 );
*/
}
public function admin_index() {
require_once plugin_dir_path( __FILE__ ) . ‘templates/admin.php’;
}
}
if ( class_exists( ‘ZerinPlugin’ ) ) {
$zerinPlugin = new ZerinPlugin();
$zerinPlugin->register();
}
// activation
register_activation_hook( __FILE__, array( $zerinPlugin, ‘activate’ ) );
// deactivation
register_deactivation_hook( __FILE__, array( $zerinPlugin, ‘deactivate’ ) );
There are 0 comments