{"id":311,"date":"2020-03-13T06:16:59","date_gmt":"2020-03-13T06:16:59","guid":{"rendered":"https:\/\/stockpack.co\/blog\/?p=311"},"modified":"2020-06-11T16:23:37","modified_gmt":"2020-06-11T16:23:37","slug":"stop-stockpack-from-loading-with-stockpack-load-filter","status":"publish","type":"post","link":"https:\/\/stockpack.co\/blog\/stop-stockpack-from-loading-with-stockpack-load-filter\/","title":{"rendered":"Stop stockpack from loading with stockpack load filter"},"content":{"rendered":"\n<p>You can prevent the StockPack plugin from loading on pages you do not want it to load, by default it will only load in the admin side since you might use a image field on any page. You configure where the StockPack plugin will load with the <code>stockpack_load<\/code> filter. <\/p>\n\n\n\n<!--more-->\n\n\n\n<p>Here&#8217;s the default for the plugin done via the filter:<\/p>\n\n\n\n<div style=\"height: 250px; position:relative; margin-bottom: 50px;\" class=\"wp-block-simple-code-block-ace\"><pre class=\"wp-block-simple-code-block-ace\" style=\"position:absolute;top:0;right:0;bottom:0;left:0\" data-mode=\"php\" data-theme=\"monokai\" data-fontsize=\"14\" data-lines=\"Infinity\" data-showlines=\"true\" data-copy=\"false\">&lt;?php\n\nadd_filter( 'load_stockpack', 'stockpack_load', 10, 1 );\n\nfunction stockpack_load( $load ) {\n\tif ( ! is_admin() ) {\n\t\treturn false;\n\t}\n\n\treturn $load;\n}<\/pre><\/div>\n\n\n\n<p>This filter can also be used to limit the plugin for certain users in a more performant way as mentioned by our friends at <a href=\"https:\/\/www.cloudmedialab.com\/\">https:\/\/www.cloudmedialab.com\/&nbsp;<\/a><\/p>\n\n\n\n<div style=\"height: 250px; position:relative; margin-bottom: 50px;\" class=\"wp-block-simple-code-block-ace\"><pre class=\"wp-block-simple-code-block-ace\" style=\"position:absolute;top:0;right:0;bottom:0;left:0\" data-mode=\"php\" data-theme=\"monokai\" data-fontsize=\"14\" data-lines=\"Infinity\" data-showlines=\"true\" data-copy=\"false\">&lt;?php\n\n\/\/ Soft Load Stockpack\nadd_filter( 'load_stockpack', 'cmldmu_stockpack_load', 10, 1 );\nfunction cmldmu_stockpack_load( $load ) {\n\t\/\/Only load StockPack to back end\n\tif ( ! is_admin() ) {\n\t\treturn false;\n\t}\n\t\/\/Do not load StockPack unless user has custom capability, or is Administrator (via update_core capability)\n\tif ( ! ( current_user_can( 'cml_use_adobestock' ) || current_user_can( 'update_core' ) ) ) {\n\t\treturn false;\n\t}\n\n\treturn $load;\n}<\/pre><\/div>\n\n\n\n<p>If you have any questions, feel free to contact us via <a href=\"https:\/\/stockpack.co\/contact\">https:\/\/stockpack.co\/contact<\/a> <\/p>\n","protected":false},"excerpt":{"rendered":"<p>You can prevent the StockPack plugin from loading on pages you do not want it to load, by default it will only load in the admin side since you might use a image field on any page. You configure where the StockPack plugin will load with the stockpack_load filter.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-311","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/stockpack.co\/blog\/wp-json\/wp\/v2\/posts\/311","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/stockpack.co\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/stockpack.co\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/stockpack.co\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/stockpack.co\/blog\/wp-json\/wp\/v2\/comments?post=311"}],"version-history":[{"count":3,"href":"https:\/\/stockpack.co\/blog\/wp-json\/wp\/v2\/posts\/311\/revisions"}],"predecessor-version":[{"id":496,"href":"https:\/\/stockpack.co\/blog\/wp-json\/wp\/v2\/posts\/311\/revisions\/496"}],"wp:attachment":[{"href":"https:\/\/stockpack.co\/blog\/wp-json\/wp\/v2\/media?parent=311"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/stockpack.co\/blog\/wp-json\/wp\/v2\/categories?post=311"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/stockpack.co\/blog\/wp-json\/wp\/v2\/tags?post=311"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}