Docs - WPCode https://wpcode.com The Best WordPress Code Snippets Plugin Wed, 07 May 2025 12:34:18 +0000 en-US hourly 1 https://wpcode.com/wp-content/uploads/2022/06/favicon-150x150.png Docs - WPCode https://wpcode.com 32 32 Why Are My PHP Snippets Not Being Executed in WPCode? https://wpcode.com/docs/why-are-my-php-snippets-not-being-executed-in-wpcode/?utm_source=rss&utm_medium=rss&utm_campaign=why-are-my-php-snippets-not-being-executed-in-wpcode Wed, 07 May 2025 12:33:47 +0000 https://wpcode.com/?post_type=wpcode_doc&p=4394 Are you facing issues with your PHP snippets not executing properly in WPCode? The most common cause for this issue is incorrect usage of closing PHP tags (?>) or opening comment tags (/*) in your snippets. In this guide, we’ll explain how these elements can impact your snippets and how WPCode handles them. Understanding PHP […]

The post Why Are My PHP Snippets Not Being Executed in WPCode? first appeared on WPCode.

]]>
Are you facing issues with your PHP snippets not executing properly in WPCode? The most common cause for this issue is incorrect usage of closing PHP tags (?>) or opening comment tags (/*) in your snippets. In this guide, we’ll explain how these elements can impact your snippets and how WPCode handles them.

Understanding PHP Closing Tags

The closing ?> tag in PHP marks the end of a PHP block. If this tag is used as the last thing in a PHP snippet within WPCode, it might affect the execution of other snippets. Why? Because WPCode loads snippets in the same instance, attempting to produce more accurate error messages.

Impact of Comment Tags

An opening comment tag /* can also impact multiple snippets. This is because the comment might not be properly closed before another snippet starts, leading to unexpected behavior. It’s essential to ensure every comment is properly terminated.

How WPCode Handles Snippets

WPCode is designed to automatically remove closing PHP tags when a snippet is edited. However, there are instances, such as when snippets are imported, where these tags may not be removed. This can lead to execution issues since PHP closing tags can interfere with additional snippets loaded in the same instance.

Common Solutions

  1. Edit and Remove Closing Tags: Ensure that no snippet ends with a ?> closing PHP tag.
  2. Check Comment Closures: Verify that all comments are appropriately closed with */ before another snippet begins.
  3. Review Imported Snippets: Double-check snippets imported into WPCode to manually remove any excess tags or open comments.

Frequently Asked Questions

Why does WPCode load snippets in the same instance?
WPCode loads snippets together to create precise error messages that match the exact line where an error is detected. Read more on debugging PHP errors in WPCode.
What should I do if WPCode fails to remove closing tags on import?
If WPCode doesn’t automatically remove a closing PHP tag during an import, manually edit the snippet to delete the tag and save your changes.

Conclusion

That’s it! You now understand why PHP snippets might not be executing and how to handle them effectively within WPCode. Remember, checking and editing your snippets for closing PHP tags and open comments will ensure smoother execution.

The post Why Are My PHP Snippets Not Being Executed in WPCode? first appeared on WPCode.

]]>
Enable Permissions to Deploy From Library https://wpcode.com/docs/deploy-from-library-missing-permissions/?utm_source=rss&utm_medium=rss&utm_campaign=deploy-from-library-missing-permissions Fri, 19 Jul 2024 08:44:40 +0000 https://wpcode.com/?post_type=wpcode_doc&p=3497 Starting with version 2.2.0 of WPCode you can use the WPCode library to deploy code snippets from the WPCode library to your website using the WPCode plugin without having to login to your website admin. This is a great way to manage updates to your snippets for multiple sites but we are also aware that […]

The post Enable Permissions to Deploy From Library first appeared on WPCode.

]]>
Starting with version 2.2.0 of WPCode you can use the WPCode library to deploy code snippets from the WPCode library to your website using the WPCode plugin without having to login to your website admin.

This is a great way to manage updates to your snippets for multiple sites but we are also aware that not all of our users need or want this feature and they may be concerned about security since WPCode is so powerful.

How to enable deploying snippets from the library to your site

Step 1

Go to the Settings page of the WPCode plugin your site’s administration panel (wp-admin > Code Snippets > Settings).

Step 2

Disconnect your site from the WPCode library. If your site is not connected you can skip to Step 3.

Click disconnect from library

Step 3

Click the “Connect to the WPCode Library” button.

Click the Connect to Library button

Step 4

In the window that pops up, login to your WPCode account if needed and check the option to “Enable pushing snippets from the library to your site.”.

Check the option to deploy snippets from the library to your site

Step 5

Click on “Connect to WordPress”, the window will close once the authentication data is saved and the settings page for your site will reload.

Click Connect to WordPress

Done! Now you can deploy snippets from the library to the website. Please read further if you want to learn more about how this feature works.

Opt-in only deployment

As you can see, deploying snippets from the library to your site is opt-in. This means that when you connect your site to the WPCode website using the WPCode plugin you will have to check a box to enable deploying snippets to your site from the library.

This ensures that you only enable this option on the sites that you choose.

It also means that you can always change that setting by reconnecting your site to the library. So if you change your mind you can always enable or disable pushing snippets from the library to your site while keeping your access to the other features provided with the WPCode library like: access to the full snippet library, your private snippet library, AI features, and updating snippets from the plugin on the library.

The post Enable Permissions to Deploy From Library first appeared on WPCode.

]]>
Run Code Snippets on Demand https://wpcode.com/docs/run-code-snippets-on-demand/?utm_source=rss&utm_medium=rss&utm_campaign=run-code-snippets-on-demand Tue, 30 Apr 2024 12:25:20 +0000 https://wpcode.com/?post_type=wpcode_doc&p=3093 Starting with version 2.1.12 of WPCode you can execute PHP snippets on demand. This is especially useful when you want to run pieces of code that you need to be sure are only executed once or that you need to control when they are executed. In order to run snippets on demand, you need to […]

The post Run Code Snippets on Demand first appeared on WPCode.

]]>
Starting with version 2.1.12 of WPCode you can execute PHP snippets on demand.

This is especially useful when you want to run pieces of code that you need to be sure are only executed once or that you need to control when they are executed.

In order to run snippets on demand, you need to follow a few simple steps:

1. Choose the PHP Code Type for your snippet, in order to do that please click the Code Type dropdown as shown below and select PHP Snippet.

Change code type

2. Choose the “On Demand” location in the Insertion settings:

First, click the Location picker:

And from the menu select “On Demand” under the “PHP Snippets Only” locations list:

Choose the On Demand location

3. Finally, with that selected you will see that the status toggle next to the Save button has been replaced with a button “Execut Snippet Now”. Clicking this button will save the snippet with its code and settings and immediately execute the snippet. If you wish to save the snippet without executing it you can always use the “Save Snippet” or “Update” button as usual.

Execute snippet now button

The post Run Code Snippets on Demand first appeared on WPCode.

]]>
How to use Snippet Files for JavaScript and CSS https://wpcode.com/docs/snippet-files/?utm_source=rss&utm_medium=rss&utm_campaign=snippet-files Wed, 03 Apr 2024 11:12:17 +0000 https://wpcode.com/?post_type=wpcode_doc&p=3029 Version 2.1.11 of WPCode introduced a new feature that enables you to load JavaScript and CSS snippets as files. This means that when this option is enabled, your snippet’s code will be loaded using wp_enqueue_script or wp_enqueue_style respectively. The way this works behind the scenes is that when you save your snippet, WPCode automatically generates […]

The post How to use Snippet Files for JavaScript and CSS first appeared on WPCode.

]]>
Version 2.1.11 of WPCode introduced a new feature that enables you to load JavaScript and CSS snippets as files.

This means that when this option is enabled, your snippet’s code will be loaded using wp_enqueue_script or wp_enqueue_style respectively.

The way this works behind the scenes is that when you save your snippet, WPCode automatically generates a file that is unique to your snippet and then the file is enqueued in the location you selected.

This brings several advantages: performance plugins can now handle those files better as opposed to inline styles/scripts and you can reference the files as dependencies for other scripts/styles in PHP snippets. You can also add localization parameters using wp_localize_script.

How to enable Loading Snippets as Files

The first step is to make sure you are using one of the file types supported: JavaScript or CSS.

Choose the code type for a snippet in WPCode.

Once you selected either of them, you will see a new option in the Insertion section of your snippet’s settings called “Load as File”.

Enable the "Load as File" option

After you enable this option, you will have to save the snippet to get the file generated.

Please note: the file is only generated if your snippet is also marked as active.

Activate and save snippet

Once your snippet is saved, you can also quickly see a preview of the file by clicking the “View File” button next to the option to enable loading the snippet as a file.

Click on View File to see the file generated for your snippet.

How to reference a snippet in another snippet

When you are registering scripts or styles in WordPress for enqueuing, each file has its own unique name that can then be used to mark that file as a dependency for another file or, for JavaScript files, you can also add data from PHP using wp_localize_script.

Snippets in WPCode are enqueued using the following naming convention:

wpcode-snippet-[snippet-id]

In case you want to reference a snippet as a dependency for another script or style, you can use the above format. For example, if your snippet’s id is 34 you would use “wpcode-snippet-34”.

The post How to use Snippet Files for JavaScript and CSS first appeared on WPCode.

]]>
How to Generate an Invoice For Your WPCode Purchase https://wpcode.com/docs/how-to-generate-an-invoice/?utm_source=rss&utm_medium=rss&utm_campaign=how-to-generate-an-invoice Fri, 22 Mar 2024 14:21:47 +0000 https://wpcode.com/?post_type=wpcode_doc&p=2988 If you want to generate an invoice after your WPCode purchase, please follow the steps below. 1. First, go to your WPCode Account and Log in. 2. In the account area, go to the Billing page using the menu at the top. 3. On the Billing page, find your payment in the “Billing History” table […]

The post How to Generate an Invoice For Your WPCode Purchase first appeared on WPCode.

]]>
If you want to generate an invoice after your WPCode purchase, please follow the steps below.

1. First, go to your WPCode Account and Log in.

2. In the account area, go to the Billing page using the menu at the top.

Click the Billing menu item

3. On the Billing page, find your payment in the “Billing History” table and click the Generate Invoice link.

Click the Generate Invoice button

4. That will open up a page where you can fill in your Billing details, including

Click on the Generate Invoice button

The post How to Generate an Invoice For Your WPCode Purchase first appeared on WPCode.

]]>
How to Upgrade Your WPCode License https://wpcode.com/docs/how-to-upgrade-your-wpcode-license/?utm_source=rss&utm_medium=rss&utm_campaign=how-to-upgrade-your-wpcode-license Fri, 22 Mar 2024 13:52:24 +0000 https://wpcode.com/?post_type=wpcode_doc&p=2979 WPCode comes with multiple pricing plans for different types of users. You can unlock more features by upgrading your WPCode license. Upgrading your license 1. First, you need to login to your WPCode account. 2. Once you are in, navigate to the Downloads area. 3. Next, click the Upgrade button next to your current Plan […]

The post How to Upgrade Your WPCode License first appeared on WPCode.

]]>
WPCode comes with multiple pricing plans for different types of users. You can unlock more features by upgrading your WPCode license.

Upgrading your license

1. First, you need to login to your WPCode account.

2. Once you are in, navigate to the Downloads area.

Click on Downloads in the WPCode account area

3. Next, click the Upgrade button next to your current Plan name on the Downloads page.

4. That will take you to the Upgrade pricing page where you’ll choose your new plan that you want to upgrade to by clicking the Upgrade button.

Click the Upgrade button for the plan you want

All upgrades are pro-rate, this means that the upgrade cose is the difference between the price of your new licenses and the current license. That price is also pro-rated by time.

More Info on Upgrades Pro-Rated Pricing

The pro-rated costs are calculated in this way:

When you upgrade, you pay just the difference between your current plan cost and the new plan cost. If the current plan costs $99 per year and the new plan is $149, you will pay just $50.

But that’s not all. The price is also pro-rated by time. This means that your renewal date stays the same, so if you only have 6 months left in your renewal, you will pay just half of the difference.

To go back to our example, if the difference in plans is $50 and you upgrade at 6 months after the initial purchase, you will only pay $25.

Refreshing your license in the plugin

After your upgrade if you don’t immediately see the new license level you have to go to the WPCode Settings page in your site’s WordPress admin.

Go to the WPCode Settings page

Click on the Deactivate Key button next to your License key field.

Next, paste your License key in the License Key field again and click the Verify Key button.

Click the verify key button

That’s it! Your license is now upgraded an you can start using your new license level benefits right away.

The post How to Upgrade Your WPCode License first appeared on WPCode.

]]>
How to Log in If You’ve Lost Your Username or Password https://wpcode.com/docs/how-to-log-in-if-youve-lost-your-username-or-password/?utm_source=rss&utm_medium=rss&utm_campaign=how-to-log-in-if-youve-lost-your-username-or-password Fri, 22 Mar 2024 13:25:54 +0000 https://wpcode.com/?post_type=wpcode_doc&p=2973 The username to login to your WPCode account is the email address you used to register on WPCode. If you use multiple emails and you are not sure which one you used to register for WPCode you can search for emails from “wpcode.com” to narrow down the search. In order to reset your password all […]

The post How to Log in If You’ve Lost Your Username or Password first appeared on WPCode.

]]>
The username to login to your WPCode account is the email address you used to register on WPCode.

If you use multiple emails and you are not sure which one you used to register for WPCode you can search for emails from “wpcode.com” to narrow down the search.

In order to reset your password all you have to do is:

1. Go to the WPCode login page

2. Click on the  “Forgot your password?” link.

Click the Forgot your password link

3. Fill in your email and click on the “Reset Password” button.

Fill in your email and click on the Reset Password button

You’ll receive an email with a password reset link that you can click and it will enable you to set a new password for your account and login.

 

The post How to Log in If You’ve Lost Your Username or Password first appeared on WPCode.

]]>
How to use the Multisite Addon https://wpcode.com/docs/how-to-use-the-multisite-addon/?utm_source=rss&utm_medium=rss&utm_campaign=how-to-use-the-multisite-addon Thu, 29 Feb 2024 14:43:02 +0000 https://wpcode.com/?post_type=wpcode_doc&p=2848 The WPCode Multisite addon enables you to manage snippets in a network-level interface. This makes it possible to execute snippets across all sites of a multisite network from one single panel.  In this article we’ll dive into how to set up the multisite addon and which network-specific options you have available. Please note: the multisite […]

The post How to use the Multisite Addon first appeared on WPCode.

]]>
The WPCode Multisite addon enables you to manage snippets in a network-level interface. This makes it possible to execute snippets across all sites of a multisite network from one single panel.  In this article we’ll dive into how to set up the multisite addon and which network-specific options you have available.

Please note: the multisite addon is currently only available on the WPCode Elite plan.

Setting Up the Multisite Addon

Getting started with the multisite addon is easily from the WPCode settings panel. To get started please install and Network Activate the WPCode premium plugin. Once the plugin is network-activated you’ll see a new WPCode menu under the Network Settings menu (make sure you are in the Network admin, not the subsite admin). You can also access the settings from the list of plugins by clicking on the Settings item under the WPCode Pro plugin as shown below.

wpcode multisite settings

On the settings page, paste your license key and click on the Verify Key button. You can grab your license key at any time from your purchase receipt email or the Downloads page in your WPCode account.

Once your key is activated and confirmed, the page will reload and the only thing left is to click the “Install Addon Now” button – that will automatically install and activate the WPCode multisite addon. Once the addon is activated you’ll see a familiar Code Snippets menu in the network admin where you can manage network-wide snippets.

In case the automatic addon installation fails for any reason you can always download the addon from the Downloads area in your WPCode account.

Install the multisite addon by clicking the Install Addon Now button

Multisite Network specific conditional logic

Adding a snippet at the network level is mostly the same as using the WPCode plugin regularly but there are some changes. You cannot use site-specific conditional logic in the network context (page-specific conditions, specific taxonomy terms, categories, etc.).

There is also a new type of conditional logic that allows you to choose on which sites the snippet will be inserted to:

Network conditional logic options for choosing sites

This allows you to limit network-wide snippets to specific sites for greater control.

Network-specific settings

When you enable the multisite addon you can only manage Access Control settings at network level. On the Access Control settings page you will notice that you can also choose the Administrator role in this context since for a multisite network there is also the Super Administrator role – the role you have if you can access the network admin panel. This setting enables you to control if site-level administrators can manage WPCode snippets and which features they have access to in the subsites.

Network specific settings

You also have 2 extra settings that are network-specific:

1. Hide WPCode on subsites: this option will hide the WPCode menu from all subsites and you will only be able to manage WPCode at network level.

2. Disable access for Administrators: enabling this will reset the permissions for administrators so that only super-administrators can manage WPCode and you will be able to choose using the role picker fields above exactly which features administrators will be allowed to manage.

The post How to use the Multisite Addon first appeared on WPCode.

]]>
How to Renew your WPCode License https://wpcode.com/docs/how-to-renew-your-wpcode-license/?utm_source=rss&utm_medium=rss&utm_campaign=how-to-renew-your-wpcode-license Thu, 16 Nov 2023 10:09:23 +0000 https://wpcode.com/?post_type=wpcode_doc&p=2508 Are you trying to renew your WPCode license, but not sure how? Making sure your license stays active ensures you have access to important plugin updates. This tutorial will show you the steps to renew any paid WPCode license. Renewing an Expired License In order to renew your expired license you have to follow a […]

The post How to Renew your WPCode License first appeared on WPCode.

]]>
Are you trying to renew your WPCode license, but not sure how? Making sure your license stays active ensures you have access to important plugin updates.

This tutorial will show you the steps to renew any paid WPCode license.

Renewing an Expired License

In order to renew your expired license you have to follow a few simple steps outlined below:

To begin, log in to your account on the WPCode website and click on the Billing tab at the top.

On that page, you’ll see a list of your subscriptions in the Subscriptions table, click on the Resubscribe link next to the subscription your want to renew.

All that’s left now is to complete the checkout process on the Checkout page.

 

The post How to Renew your WPCode License first appeared on WPCode.

]]>
Access Control https://wpcode.com/docs/access-control/?utm_source=rss&utm_medium=rss&utm_campaign=access-control Tue, 29 Aug 2023 08:51:32 +0000 https://wpcode.com/?post_type=wpcode_doc&p=2364 Using the Access Control settings in WPCode allows you to limit which features in the WPCode plugin users of your site can manage. There are 2 main types of settings in the access control area: role-based feature access and site-wide PHP snippet control. Please note: Access Control settings are only available to license levels Pro […]

The post Access Control first appeared on WPCode.

]]>
Using the Access Control settings in WPCode allows you to limit which features in the WPCode plugin users of your site can manage.

There are 2 main types of settings in the access control area: role-based feature access and site-wide PHP snippet control.

Please note: Access Control settings are only available to license levels Pro and Elite.

Role-based feature access

Role-based access-control settings

The main settings area of the Access Control panel enables you to control which user roles can manage different types of snippets based on the code type or access other features not snippet-based.

The first three settings allow you to choose which user roles are allowed to edit snippets based on their code type:

  • Text/Blocks snippets: these are snippets that are text-based and no code is allowed except for basic HTML that you can use to format text like you would in a WordPress editor.
  • HTML, JavaScript, CSS – these gives users access to edit any type of HTML and add scripts, by granting them this permission they also get access to the Global Header & Footer area. Since this capability grants them more access they also get access to Text/Blocks snippets editing.
  • PHP Snippets – This grants users access to use PHP & Universal snippets along with all the other snippet types and also grants users access to the Snippet Library and the Snippet Generator.

The other two settings grant users access to the Conversion Pixels settings and using the File Editor as follows:

  • Manage Conversion Pixels Settings – giving users this permission will allow them to manage all the Conversion Pixels settings for all the pixel types and create custom click events. Granting just this permission will not give them access to any other WPCode feature.
  • Use the File Editor – this will enable users to access just the File Editor area in the WPCode plugin and update files like ads.txt, app-ads.txt, service-worker.js and robots.txt. Similar to the Conversion Pixels permission this will only allow users to access the File Editor area in the WPCode plugin.

None of the permissions mentioned above will allow other roles to manage the plugin settings or the connection to the WPCode Library.

Please note that granting access to PHP snippets with the library connected to your account, users will be able to also manage the snippets in your private library. If you want to prevent that, simply disconnect the plugin from the library in the plugin settings.

PHP Snippet Control

Setting to disable PHP snippets in WPCode

The 2nd setting available in the Access Control panel allows you as administrator to completely disable PHP snippets throughout the site. This means that nobody will be allowed to add or edit PHP snippets and existing PHP snippets will no longer be executed. This can be useful if you want to avoid using PHP snippets or simply debug disabling all the PHP snippets in a single place.

The PHP snippets can also be disabled site-wide using a PHP constant that you can add in the code of your site: WPCODE_DISABLE_PHP. Adding this constant to the wp-config.php file of your site will completely disable PHP snippets in WPCode and not even administrators will be able do disable it without access to wp-config.php.


define( 'WPCODE_DISABLE_PHP', true );

PHP-related settings in the Access Control panel will no longer be visible if PHP snippets are disabled.

The post Access Control first appeared on WPCode.

]]>