<?php
/**
 * Plugin Name:       Create Post by Google Document
 * Description:       This plugin streamlines your WordPress content management by integrating with Google Docs. Using the Google Docs API, the plugin retrieves document data directly from Google Docs and converts it into WordPress posts, saving time and effort for content creators.
 * Version:           1.0.0
 * Requires at least: 5.0
 * Author:            Webnotics Pvt Ltd.
 * Author URI:        https://webnotics.solutions/
 * Text Domain:       create-post-by-google-document
 * License:           GPLv2 or later
 * Domain Path:       /languages
 * Donate link: https://donate.stripe.com/3cI5kE7sv6ex30s5LB5kk2x
 */


if (!defined('ABSPATH')) {
	exit; // Exit if accessed directly
}

/**
 * Currently plugin version.
 * Start at version 1.0.0 and use SemVer - https://semver.org
 * Rename this for your plugin and update it as you release new versions.
 */
define( 'CPBGD_VERSION', '1.0.0' );


/**
 * Define the root URL of the plugin directory for easy access to assets and other resources.
 * This uses __FILE__ to dynamically get the URL based on the current file's location.
 */
define( 'CPBGD_ROOT_URL', plugin_dir_url( __FILE__ ) );


/**
 * Define the root path of the plugin directory on the server's filesystem.
 * This is useful for including or requiring files using absolute paths within the plugin.
 */
define( 'CPBGD_ROOT_PATH', plugin_dir_path( __FILE__ ) );


/**
 * Define the base name of the plugin file relative to the plugins directory.
 * This is useful for referencing the plugin in hooks like register_activation_hook or for plugin-specific operations.
 */
define( 'CPBGD_BASE_NAME', plugin_basename(__FILE__) );


/**
 * The code that runs during plugin deactivation.
 * This action is documented in includes/class-create-post-by-google-document-deactivator.php
 */
function cpbgd_dctvte() {
	require_once CPBGD_ROOT_PATH . 'includes/class-cpbgd-post-by-google-document-deactivator.php';
	CPBGD_Deactivator::cpbgd_deactivaat();
}

register_deactivation_hook( __FILE__, 'cpbgd_dctvte' );


/**
 * The core plugin class that is used to define internationalization,
 * admin-specific hooks, and public-facing site hooks.
 */
require CPBGD_ROOT_PATH . 'includes/class-cpbgd-post-by-google-document.php';



// Add custom action links to the plugin row in the Plugins admin page
add_filter( 'plugin_action_links_' . CPBGD_BASE_NAME, 'cpbgd_settings_link' );

/**
 * Adds custom "Settings" and "Documentation" links to the plugin actions row.
 *
 * @param array $links Existing action links.
 * @return array Modified action links with additional entries.
 */
function cpbgd_settings_link( $links ) {
    $settings_url = admin_url( 'admin.php?page=cpbgd_api_settings' );
    $documentation_url = admin_url( 'admin.php?page=cpbgd_plugin_documentation' );

    $settings_link = '<a href="' . esc_url( $settings_url ) . '">' . esc_html__('Settings', 'create-post-by-google-document') . '</a>';
    $documentation_link = '<a href="' . esc_url( $documentation_url ) . '">' . esc_html__('Documentation', 'create-post-by-google-document') . '</a>';

    array_unshift( $links, $documentation_link );
    array_unshift( $links, $settings_link );

    return $links;
}




/**
 * Begins execution of the plugin.
 *
 * Since everything within the plugin is registered via hooks,
 * then kicking off the plugin from this point in the file does
 * not affect the page life cycle.
 *
 * @since    1.0.0
 */

if (!function_exists('cpbgd_runner')) {
	function cpbgd_runner() {

		$plugin = new CPBGD_Main();
		$plugin->cpbgd_ruunn();
	}
}



cpbgd_runner();
