shortcode-vc-wp-links.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. if ( ! defined( 'ABSPATH' ) ) {
  3. die( '-1' );
  4. }
  5. if ( 'vc_edit_form' === vc_post_param( 'action' ) && vc_verify_admin_nonce() ) {
  6. $link_category = array( esc_html__( 'All Links', 'js_composer' ) => '' );
  7. $link_cats = get_terms( 'link_category' );
  8. if ( is_array( $link_cats ) && ! empty( $link_cats ) ) {
  9. foreach ( $link_cats as $link_cat ) {
  10. if ( is_object( $link_cat ) && isset( $link_cat->name, $link_cat->term_id ) ) {
  11. $link_category[ $link_cat->name ] = $link_cat->term_id;
  12. }
  13. }
  14. }
  15. } else {
  16. $link_category = array();
  17. }
  18. return array(
  19. 'name' => 'WP ' . esc_html__( 'Links' ),
  20. 'base' => 'vc_wp_links',
  21. 'icon' => 'icon-wpb-wp',
  22. 'category' => esc_html__( 'WordPress Widgets', 'js_composer' ),
  23. 'class' => 'wpb_vc_wp_widget',
  24. 'content_element' => (bool) get_option( 'link_manager_enabled' ),
  25. 'weight' => - 50,
  26. 'description' => esc_html__( 'Your blogroll', 'js_composer' ),
  27. 'params' => array(
  28. array(
  29. 'type' => 'dropdown',
  30. 'heading' => esc_html__( 'Link Category', 'js_composer' ),
  31. 'param_name' => 'category',
  32. 'value' => $link_category,
  33. 'admin_label' => true,
  34. ),
  35. array(
  36. 'type' => 'dropdown',
  37. 'heading' => esc_html__( 'Order by', 'js_composer' ),
  38. 'param_name' => 'orderby',
  39. 'value' => array(
  40. esc_html__( 'Link title', 'js_composer' ) => 'name',
  41. esc_html__( 'Link rating', 'js_composer' ) => 'rating',
  42. esc_html__( 'Link ID', 'js_composer' ) => 'id',
  43. esc_html__( 'Random', 'js_composer' ) => 'rand',
  44. ),
  45. ),
  46. array(
  47. 'type' => 'checkbox',
  48. 'heading' => esc_html__( 'Options', 'js_composer' ),
  49. 'param_name' => 'options',
  50. 'value' => array(
  51. esc_html__( 'Show Link Image', 'js_composer' ) => 'images',
  52. esc_html__( 'Show Link Name', 'js_composer' ) => 'name',
  53. esc_html__( 'Show Link Description', 'js_composer' ) => 'description',
  54. esc_html__( 'Show Link Rating', 'js_composer' ) => 'rating',
  55. ),
  56. ),
  57. array(
  58. 'type' => 'textfield',
  59. 'heading' => esc_html__( 'Number of links to show', 'js_composer' ),
  60. 'param_name' => 'limit',
  61. 'value' => - 1,
  62. ),
  63. array(
  64. 'type' => 'el_id',
  65. 'heading' => esc_html__( 'Element ID', 'js_composer' ),
  66. 'param_name' => 'el_id',
  67. 'description' => sprintf( esc_html__( 'Enter element ID (Note: make sure it is unique and valid according to %sw3c specification%s).', 'js_composer' ), '<a href="https://www.w3schools.com/tags/att_global_id.asp" target="_blank">', '</a>' ),
  68. ),
  69. array(
  70. 'type' => 'textfield',
  71. 'heading' => esc_html__( 'Extra class name', 'js_composer' ),
  72. 'param_name' => 'el_class',
  73. 'description' => esc_html__( 'Style particular content element differently - add a class name and refer to it in custom CSS.', 'js_composer' ),
  74. ),
  75. ),
  76. );