| 1 |
<?php |
| 2 |
/** |
| 3 |
* WPCode integration code snippets page. |
| 4 |
* |
| 5 |
* @since 1.8.1.6 |
| 6 |
* @package Charitable/Admin/Tools |
| 7 |
* |
| 8 |
* @var array $snippets WPCode snippets list. |
| 9 |
* @var bool $action_required Indicate that user should install or activate WPCode. |
| 10 |
* @var string $action Popup button action. |
| 11 |
* @var string $plugin WPCode Lite download URL | WPCode Lite plugin slug. |
| 12 |
*/ |
| 13 |
|
| 14 |
if ( ! defined( 'ABSPATH' ) ) { |
| 15 |
exit; |
| 16 |
} |
| 17 |
?> |
| 18 |
|
| 19 |
<?php |
| 20 |
/** |
| 21 |
* @version 1.8.8.6 |
| 22 |
*/ |
| 23 |
|
| 24 |
$charitable_action_required = false; |
| 25 |
$charitable_plugin_slug = 'wpcode'; |
| 26 |
$charitable_plugin_button_html = ''; |
| 27 |
$charitable_snippets = charitable_get_intergration_wpcode()->load_charitable_snippets(); |
| 28 |
|
| 29 |
$charitable_plugins_third_party = new Charitable_Admin_Plugins_Third_Party(); |
| 30 |
|
| 31 |
$charitable_is_installed = $charitable_plugins_third_party->is_plugin_installed( $charitable_plugin_slug ); |
| 32 |
$charitable_is_activated = $charitable_plugins_third_party->is_plugin_activated( $charitable_plugin_slug ); |
| 33 |
|
| 34 |
if ( ! $charitable_is_installed ) { |
| 35 |
$charitable_action_required = true; |
| 36 |
|
| 37 |
$charitable_popup_title = esc_html__( 'Please Install WPCode to Use the Charitable Snippet Library', 'charitable' ); |
| 38 |
$charitable_popup_button_text = esc_html__( 'Install WPCode', 'charitable' ); |
| 39 |
|
| 40 |
$charitable_plugin_button_html = $charitable_plugins_third_party->get_plugin_button_html( $charitable_plugin_slug, false, '' ); |
| 41 |
|
| 42 |
} elseif ( ! $charitable_is_activated ) { |
| 43 |
$charitable_action_required = true; |
| 44 |
|
| 45 |
$charitable_popup_title = esc_html__( 'Please Activate WPCode to Use the Charitable Snippet Library', 'charitable' ); |
| 46 |
$charitable_popup_button_text = esc_html__( 'Activate WPCode', 'charitable' ); |
| 47 |
|
| 48 |
$charitable_plugin_button_html = $charitable_plugins_third_party->get_plugin_button_html( $charitable_plugin_slug, false, '' ); |
| 49 |
} |
| 50 |
|
| 51 |
$charitable_container_class = $charitable_action_required ? 'charitable-wpcode-blur' : ''; |
| 52 |
|
| 53 |
?> |
| 54 |
|
| 55 |
<div class="charitable-wpcode"> |
| 56 |
<?php if ( $charitable_action_required ) : ?> |
| 57 |
<div class="charitable-wpcode-popup"> |
| 58 |
<div class="charitable-wpcode-popup-title"><?php echo esc_html( $charitable_popup_title ); ?></div> |
| 59 |
<div class="charitable-wpcode-popup-description"> |
| 60 |
<?php esc_html_e( 'Using WPCode, you can install Charitable code snippets with 1 click right from this page or the WPCode Library in the WordPress admin.', 'charitable' ); ?> |
| 61 |
</div> |
| 62 |
|
| 63 |
<?php echo $charitable_plugin_button_html; // phpcs:ignore ?> |
| 64 |
|
| 65 |
<a |
| 66 |
href="https://wordpress.org/plugins/insert-headers-and-footers/?utm_source=charitableplugin&utm_medium=WPCode+WordPress+Repo&utm_campaign=plugin&utm_content=WPCode" |
| 67 |
target="_blank" |
| 68 |
class="charitable-wpcode-popup-link"> |
| 69 |
<?php esc_html_e( 'Learn more about WPCode', 'charitable' ); ?> |
| 70 |
</a> |
| 71 |
</div> |
| 72 |
<?php endif; ?> |
| 73 |
|
| 74 |
<div class="charitable-wpcode-container <?php echo sanitize_html_class( $charitable_container_class ); ?>"> |
| 75 |
<h4 id="code-snippets"><?php esc_html_e( 'Code Snippets', 'charitable' ); ?></h4> |
| 76 |
<div class="charitable-setting-row tools charitable-wpcode-header"> |
| 77 |
<div class="charitable-wpcode-header-meta"> |
| 78 |
<p> |
| 79 |
<?php |
| 80 |
printf( |
| 81 |
wp_kses( /* translators: %s - WPCode library website URL. */ |
| 82 |
__( 'Using WPCode, you can install <a href="%1$s" target="_blank" rel="noopener noreferrer">Charitable code snippets</a> with 1 click directly from this page or the <a href="%2$s" target="_blank" rel="noopener noreferrer">WPCode library</a>.', 'charitable' ), |
| 83 |
[ |
| 84 |
'a' => [ |
| 85 |
'href' => [], |
| 86 |
'rel' => [], |
| 87 |
'target' => [], |
| 88 |
], |
| 89 |
] |
| 90 |
), |
| 91 |
'https://library.wpcode.com/profile/wpcharitable/', |
| 92 |
esc_url( admin_url( 'admin.php?page=wpcode-library' ) ) |
| 93 |
); |
| 94 |
?> |
| 95 |
</p> |
| 96 |
<p> |
| 97 |
<?php |
| 98 |
printf( |
| 99 |
wp_kses( /* translators: %s - WPCode library website URL. */ |
| 100 |
__( '<strong>Need help?</strong> Read more on <a href="%1$s" target="_blank" rel="noopener noreferrer">how to use WPCode</a> and exmaine <a href="%2$s" target="_blank" rel="noopener noreferrer">our documentation</a> to learn more on how to customize Charitable.', 'charitable' ), |
| 101 |
[ |
| 102 |
'a' => [ |
| 103 |
'href' => [], |
| 104 |
'rel' => [], |
| 105 |
'target' => [], |
| 106 |
], |
| 107 |
'strong' => [], |
| 108 |
] |
| 109 |
), |
| 110 |
'https://www.wpcharitable.com/documentation/customizing-donation-forms-with-code-snippets-using-wpcode/', |
| 111 |
'https://www.wpcharitable.com/documentation/', |
| 112 |
); |
| 113 |
?> |
| 114 |
</p> |
| 115 |
</div> |
| 116 |
<div class="charitable-wpcode-header-search"> |
| 117 |
<label for="charitable-wpcode-snippet-search"></label> |
| 118 |
<input |
| 119 |
type="search" placeholder="<?php esc_attr_e( 'Search Snippets', 'charitable' ); ?>" |
| 120 |
id="charitable-wpcode-snippet-search"> |
| 121 |
</div> |
| 122 |
</div> |
| 123 |
|
| 124 |
<div id="charitable-wpcode-snippets-list"> |
| 125 |
<div class="charitable-wpcode-snippets-list"> |
| 126 |
<?php |
| 127 |
foreach ( $charitable_snippets as $charitable_snippet ) : |
| 128 |
$charitable_button_text = $charitable_snippet['installed'] ? __( 'Edit Snippet', 'charitable' ) : __( 'Install Snippet', 'charitable' ); |
| 129 |
$charitable_button_type_class = $charitable_snippet['installed'] ? 'button-primary' : 'button-secondary'; |
| 130 |
$charitable_button_action = $charitable_snippet['installed'] ? 'edit' : 'install'; |
| 131 |
$charitable_badge_text = $charitable_snippet['installed'] ? __( 'Installed', 'charitable' ) : ''; |
| 132 |
$charitable_library_id = ! empty( $charitable_snippet['library_id'] ) ? ( $charitable_snippet['library_id'] ) : false; |
| 133 |
?> |
| 134 |
<div class="charitable-wpcode-snippet"> |
| 135 |
<div class="charitable-wpcode-snippet-header"> |
| 136 |
<?php if ( $charitable_library_id ) : ?> |
| 137 |
<a class="charitable-wpcode-snippet-external-link" title="<?php esc_html_e( 'View this snippet on WPCode.com', 'charitable' ); ?>" href="https://library.wpcode.com/profile/wpcharitable/?code_type=all&order=popular&view=all&search=<?php echo rawurlencode( $charitable_snippet['title'] ); ?>" target="_blank"><span class="dashicons dashicons-external"></span></a> |
| 138 |
<?php endif; ?> |
| 139 |
<h3 class="charitable-wpcode-snippet-title"><?php echo esc_html( $charitable_snippet['title'] ); ?></h3> |
| 140 |
<div class="charitable-wpcode-snippet-note"><?php echo esc_html( $charitable_snippet['note'] ); ?></div> |
| 141 |
</div> |
| 142 |
<div class="charitable-wpcode-snippet-footer"> |
| 143 |
<div class="charitable-wpcode-snippet-badge"><?php echo esc_html( $charitable_badge_text ); ?></div> |
| 144 |
<a |
| 145 |
href="<?php echo esc_url( $charitable_snippet['install'] ); ?>" |
| 146 |
class="button charitable-wpcode-snippet-button <?php echo sanitize_html_class( $charitable_button_type_class ); ?>" |
| 147 |
data-action="<?php echo esc_attr( $charitable_button_action ); ?>"><?php echo esc_html( $charitable_button_text ); ?> </a> |
| 148 |
</div> |
| 149 |
</div> |
| 150 |
<?php endforeach; ?> |
| 151 |
</div> |
| 152 |
<div id="charitable-wpcode-no-results"><?php esc_html_e( "Sorry, we didn't find any snippets that match your criteria.", 'charitable' ); ?></div> |
| 153 |
</div> |
| 154 |
</div> |
| 155 |
</div> |
| 156 |
|