READY
/**
* Plugin Name: ToolSuite Pro
* Plugin URI: https://viptools.pk/
* Description: Turn Your WordPress Site Into a Scalable, SEO-Optimized Tool Powerhouse. Easily create, manage, monetize, and scale 100+ interactive web tools. Developed by MrWaseem.
* Version: 4.0.0
* Author: MrWaseem
* Author URI: https://github.com/Waseemuxui
* Text Domain: toolsuite-pro
* License: GPLv2 or later
*/
if (!defined('ABSPATH')) {
exit;
}
define('TOOLSUITE_PRO_PATH', plugin_dir_path(__FILE__));
define('TOOLSUITE_PRO_URL', plugin_dir_url(__FILE__));
// Require Core Files
require_once TOOLSUITE_PRO_PATH . 'includes/tools-library.php';
require_once TOOLSUITE_PRO_PATH . 'includes/admin-settings.php';
/**
* Register Custom Post Type 'tool' & Custom Taxonomy 'tool_category'
*/
function toolsuite_pro_register_cpt() {
// Taxonomy
$tax_labels = array(
'name' => _x('Tool Categories', 'taxonomy general name', 'toolsuite-pro'),
'singular_name' => _x('Tool Category', 'taxonomy singular name', 'toolsuite-pro'),
'search_items' => __('Search Categories', 'toolsuite-pro'),
'all_items' => __('All Categories', 'toolsuite-pro'),
'edit_item' => __('Edit Category', 'toolsuite-pro'),
'update_item' => __('Update Category', 'toolsuite-pro'),
'add_new_item' => __('Add New Category', 'toolsuite-pro'),
'new_item_name' => __('New Category Name', 'toolsuite-pro'),
'menu_name' => __('Categories', 'toolsuite-pro'),
);
register_taxonomy('tool_category', array('tool'), array(
'hierarchical' => true,
'labels' => $tax_labels,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array('slug' => 'category'),
'show_in_rest' => true,
));
// Custom Post Type
$cpt_labels = array(
'name' => _x('ToolSuite Pro', 'Post type general name', 'toolsuite-pro'),
'singular_name' => _x('Tool', 'Post type singular name', 'toolsuite-pro'),
'menu_name' => _x('ToolSuite Pro', 'Admin Menu text', 'toolsuite-pro'),
'name_admin_bar' => _x('Tool', 'Add New on Toolbar', 'toolsuite-pro'),
'add_new' => __('Add New Tool', 'toolsuite-pro'),
'add_new_item' => __('Add New Interactive Tool', 'toolsuite-pro'),
'new_item' => __('New Tool', 'toolsuite-pro'),
'edit_item' => __('Edit Tool Engine', 'toolsuite-pro'),
'view_item' => __('View Tool Live', 'toolsuite-pro'),
'all_items' => __('All Tools', 'toolsuite-pro'),
'search_items' => __('Search Tools', 'toolsuite-pro'),
);
register_post_type('tool', array(
'labels' => $cpt_labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array('slug' => '%tool%', 'with_front' => false),
'capability_type' => 'post',
'has_archive' => 'tools',
'hierarchical' => false,
'menu_position' => 5,
'menu_icon' => 'dashicons-admin-tools',
'supports' => array('title', 'editor', 'excerpt', 'thumbnail', 'custom-fields'),
'show_in_rest' => true,
));
}
add_action('init', 'toolsuite_pro_register_cpt');
/**
* Remove /tool/ prefix from tool permalinks
*/
function toolsuite_pro_remove_cpt_slug($post_link, $post) {
if ('tool' === $post->post_type && 'publish' === $post->post_status) {
return home_url('/' . $post->post_name . '/');
}
return $post_link;
}
add_filter('post_type_link', 'toolsuite_pro_remove_cpt_slug', 10, 2);
/**
* Add rewrite rules for clean root-level tool permalinks
*/
function toolsuite_pro_add_cpt_rewrite_rules($wp_rewrite) {
$rules = array();
$posts = get_posts(array(
'post_type' => 'tool',
'post_status' => 'publish',
'posts_per_page' => -1,
));
foreach ($posts as $post) {
$rules[$post->post_name . '/?$'] = 'index.php?tool=' . $post->post_name;
}
$wp_rewrite->rules = $rules + $wp_rewrite->rules;
}
add_action('generate_rewrite_rules', 'toolsuite_pro_add_cpt_rewrite_rules');
/**
* Add Tool Meta Boxes (Custom HTML/CSS/JS Engine Code & Icons)
*/
function toolsuite_pro_add_meta_boxes() {
add_meta_box(
'toolsuite_code_engine',
'⚙️ ToolSuite Pro Custom Code Engine (HTML / CSS / JS)',
'toolsuite_pro_code_engine_meta_box',
'tool',
'normal',
'high'
);
}
add_action('add_meta_boxes', 'toolsuite_pro_add_meta_boxes');
function toolsuite_pro_code_engine_meta_box($post) {
$icon = get_post_meta($post->ID, '_tool_icon', true) ?: 'fas fa-wrench';
$custom_html = get_post_meta($post->ID, '_tool_custom_html', true);
$custom_css = get_post_meta($post->ID, '_tool_custom_css', true);
$custom_js = get_post_meta($post->ID, '_tool_custom_js', true);
wp_nonce_field('toolsuite_meta_box_nonce', 'toolsuite_meta_nonce');
?>
Tool Icon Class (FontAwesome / SVG URL):
Custom HTML Markup (Overrides default layout):
Custom CSS Code:
Custom JS Logic:
}
function toolsuite_pro_save_meta_box_data($post_id) {
if (!isset($_POST['toolsuite_meta_nonce']) || !wp_verify_nonce($_POST['toolsuite_meta_nonce'], 'toolsuite_meta_box_nonce')) {
return;
}
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return;
if (!current_user_can('edit_post', $post_id)) return;
if (isset($_POST['tool_icon'])) update_post_meta($post_id, '_tool_icon', sanitize_text_field($_POST['tool_icon']));
if (isset($_POST['tool_custom_html'])) update_post_meta($post_id, '_tool_custom_html', wp_unslash($_POST['tool_custom_html']));
if (isset($_POST['tool_custom_css'])) update_post_meta($post_id, '_tool_custom_css', wp_unslash($_POST['tool_custom_css']));
if (isset($_POST['tool_custom_js'])) update_post_meta($post_id, '_tool_custom_js', wp_unslash($_POST['tool_custom_js']));
}
add_action('save_post_tool', 'toolsuite_pro_save_meta_box_data');
/**
* Increment Tool Page View Counter
*/
function toolsuite_pro_track_views($post_id) {
if (!is_single() || get_post_type($post_id) !== 'tool') return;
$views = (int) get_post_meta($post_id, '_tool_views_count', true);
update_post_meta($post_id, '_tool_views_count', $views + 1);
}
add_action('wp_head', function() {
if (is_single()) {
global $post;
if ($post && $post->post_type === 'tool') {
toolsuite_pro_track_views($post->ID);
}
}
});
/**
* Enqueue Assets
*/
function toolsuite_pro_assets() {
wp_enqueue_style('font-awesome-plugin', 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css', array(), '6.5.0');
wp_enqueue_style('toolsuite-tools-style', TOOLSUITE_PRO_URL . 'assets/css/tools-style.css', array(), '4.0.0');
wp_enqueue_script('qrcode-js', 'https://cdnjs.cloudflare.com/ajax/libs/qrcodejs/1.0.0/qrcode.min.js', array(), '1.0.0', true);
wp_enqueue_script('toolsuite-tools-handler', TOOLSUITE_PRO_URL . 'assets/js/tools-handler.js', array('jquery'), '4.0.0', true);
}
add_action('wp_enqueue_scripts', 'toolsuite_pro_assets');
/**
* Activation
*/
function toolsuite_pro_activate() {
toolsuite_pro_register_cpt();
flush_rewrite_rules();
}
register_activation_hook(__FILE__, 'toolsuite_pro_activate');
Vip Tools
VipTools.pk: 100+ Free Online Tools & Pakistani Calculators
100+ Free Web Tools & Pakistani Utilities
100+ Free Online Tools & Pakistani Utility Calculators
Fast, free, and secure online tools for FBR Income Tax (2024-25), WAPDA & K-Electric Bill Estimators, Zakat Nisab, Gold Tola Rates, Text Editing, Image Tools, and Developer Utilities.
100+ Real Tools
100% Free No Subscriptions
Pakistani Tax & Utility Calculators
100% Safe Client-Side Logic